Browse Source

Added sounds.

master
revolverpunk 4 years ago
parent
commit
628641e1c3
10 changed files with 28 additions and 7 deletions
  1. +6
    -2
      README.md
  2. BIN
      assets/audio/meow.wav
  3. BIN
      assets/audio/meow1.wav
  4. BIN
      assets/audio/meow2.wav
  5. BIN
      assets/audio/meow3.wav
  6. BIN
      assets/audio/nom.wav
  7. +5
    -0
      index.html
  8. +7
    -1
      src/catai.js
  9. +8
    -2
      src/food.js
  10. +2
    -2
      src/utils.js

+ 6
- 2
README.md View File

@ -4,10 +4,14 @@ Cat Flat is a brutally realistic virtual reality simulation game, about a large
\* by aiming at the bowl and clicking or just gazing for a bit in VR.
Other
-----
Credits
-------
This project uses [A-Frame](https://aframe.io/) which is great and makes WebVR dev very similar to normal web dev.
The sounds are from Freesound.org by the following people:
* [Meows by theshaggyfreak](http://freesound.org/people/theshaggyfreak/sounds/274989/)
* [Noms by niwki](http://freesound.org/people/niwki/sounds/162822/)
License
-------
The code is licensed under the [MIT License](https://opensource.org/licenses/MIT). The 3D art is licensed under the [Creative Commons Attribution 4.0 license](http://creativecommons.org/licenses/by/4.0/). So basically copy as much as you like, as long as you give credit to "Revolverpunk".

BIN
assets/audio/meow.wav View File


BIN
assets/audio/meow1.wav View File


BIN
assets/audio/meow2.wav View File


BIN
assets/audio/meow3.wav View File


BIN
assets/audio/nom.wav View File


+ 5
- 0
index.html View File

@ -31,6 +31,11 @@
<a-asset-item id="CatDead" src="assets/mesh/Cat_Dead.ply"></a-asset-item>
<a-asset-item id="FoodCup" src="assets/mesh/FoodCup.dae"></a-asset-item>
<a-asset-item id="Food" src="assets/mesh/Food.dae"></a-asset-item>
<audio id="meow0" src="assets/audio/meow.wav"></audio>
<audio id="meow1" src="assets/audio/meow1.wav"></audio>
<audio id="meow2" src="assets/audio/meow2.wav"></audio>
<audio id="meow3" src="assets/audio/meow3.wav"></audio>
<audio id="nom" src="assets/audio/nom.wav"></audio>
</a-assets>
<a-entity id="playerCam" camera="userHeight:1" look-controls wasd-controls confined>
<a-entity cursor="fuseTimeout: 500" position="0 0 -0.01" scale="1 1 1"


+ 7
- 1
src/catai.js View File

@ -13,6 +13,9 @@ AFRAME.registerComponent("catai", {
alive: { default: true }
},
init: function() {
this.el.addEventListener("click", function() {
this.el.dispatchEvent(new CustomEvent("meow"));
});
},
tick: function(time, delta) {
var position = this.el.getAttribute("position");
@ -37,6 +40,9 @@ AFRAME.registerComponent("catai", {
(this.data.activity != "eating" && this.data.hunger < this.data.hungerThreshold) ||
// Currently eating but no food in current target food cup
(this.data.activity == "eating" && this.data.targetFood == null)) {
if (Math.random() < 0.2) {
this.el.dispatchEvent(new CustomEvent("meow"));
}
var activityReconsidered = false;
this.data.boredness = 0;
if (this.data.hunger < this.data.hungerThreshold) {
@ -98,7 +104,7 @@ AFRAME.registerComponent("catai", {
this.el.setAttribute("catmove", "targetReachDistance", 0.1);
}
// Test if dead
// Die if dead
if (this.data.hunger <= 0) {
this.data.alive = false;
this.el.setAttribute("catmove", "targetPosition", {x: position.x, z: position.z});


+ 8
- 2
src/food.js View File

@ -4,17 +4,23 @@ AFRAME.registerComponent("food", {
dependencies: ["ply-model", "position"],
schema: {
amount: { default: 5.0 },
maxAmount: { default: 5.0 }
maxAmount: { default: 5.0 },
lastFoodAmount: { default: 5.0}
},
init: function() {
this.data.maxAmount = this.data.amount;
this.data.lastFoodAmount = this.data.amount;
foods.push(this.el);
this.el.addEventListener("click", function() {
this.setAttribute("food", "amount", this.getComputedAttribute("food").maxAmount);
});
},
tick: function(time, delta) {
this.el.setAttribute("scale", {x: 1, y: Math.ceil(10.0 * (this.data.amount / this.data.maxAmount)) / 10.0, z: 1})
this.el.setAttribute("scale", {x: 1, y: Math.ceil(10.0 * (this.data.amount / this.data.maxAmount)) / 10.0, z: 1});
if (this.data.lastFoodAmount - this.data.amount > this.data.maxAmount / 10.0) {
this.el.setAttribute("food", "lastFoodAmount", this.data.amount);
this.el.dispatchEvent(new CustomEvent("nom"));
}
}
});
AFRAME.registerComponent("foodcup", {


+ 2
- 2
src/utils.js View File

@ -32,7 +32,7 @@ function spawnCat(position, rotation) {
var hunger = 0.8 + Math.random() * 1.2;
spawnEntity([["ply-model", "src: #Cat"], ["position", position],
["rotation", rotation], ["scale", {x: 0.02, y: 0.02, z: 0.02}],
["catmove", ""], ["catanim", ""],
["sound", "src: #meow" + Math.floor(Math.random() * 4) + "; on: meow"], ["catmove", ""], ["catanim", ""],
["catai", "hungerDelta: " + hungerDelta +
";eatingSpeed: " + eatingSpeed +
";boredDelta: " + boredDelta +
@ -69,7 +69,7 @@ function spawnFood(position, rotation) {
spawnedFoodPositions.push(position);
rotation = rotation || {x: 0, y: Math.floor(Math.random() * 8) * 45, z: 0};
spawnEntity([["collada-model", "#Food"], ["position", {x: position.x, y: 0.0249, z: position.z}],
["rotation", rotation], ["food", ""]]);
["rotation", rotation], ["food", ""], ["sound", "src: #nom; volume: 0.1; on: nom"]]);
spawnEntity([["collada-model", "#FoodCup"], ["position", position],
["rotation", rotation], ["foodcup", ""]]);
}

Loading…
Cancel
Save