From 0f130ad7e5843638cd3386605c6e3e841f23f3d5 Mon Sep 17 00:00:00 2001 From: TorgaW Date: Sat, 13 Apr 2024 21:20:59 +0300 Subject: [PATCH] GameObject base class is implemented --- src/Game/GameObject/GameObject.js | 45 +++++++++++++++++++++++++++++++ src/Game/Sound/Sound.js | 1 + 2 files changed, 46 insertions(+) create mode 100644 src/Game/GameObject/GameObject.js diff --git a/src/Game/GameObject/GameObject.js b/src/Game/GameObject/GameObject.js new file mode 100644 index 0000000..0b7e833 --- /dev/null +++ b/src/Game/GameObject/GameObject.js @@ -0,0 +1,45 @@ +import * as PIXI from "../../pixi/pixi.mjs" + +/** + * Base class for all game objects. + * Contains only necessary functions + */ +export class GameObject { + + id = -1; + tickEnabled = true; + // markedAsWaitingForDestruction = false; + // markedAsInitialized = false; + + /** + * GameObject id + * @param {Number} id + * @param {Boolean} tickAble + */ + constructor(id, tickAble) + { + this.id = id; + this.tickEnabled = tickAble; + }; + + /** + * called before object's destruction + */ + preDestroy(){}; + + /** + * called after spawn + */ + afterSpawn(){}; + + /** + * called before spawn + */ + preSpawn(){}; + + /** + * called every frame + * @param {PIXI.Ticker} ticker + */ + tick(ticker){}; +}; \ No newline at end of file diff --git a/src/Game/Sound/Sound.js b/src/Game/Sound/Sound.js index 4fd3459..1c32515 100644 --- a/src/Game/Sound/Sound.js +++ b/src/Game/Sound/Sound.js @@ -61,6 +61,7 @@ let nightAmbientSoundCue = new NumberCue( ); export function handleSounds(tick) { + // console.log(tick); let p = getDayPhase(); ambientDay.volume(dayAmbientSoundCue.getValueAt(p) * globalSoundVolume * ambientSoundVolume * 0.6); ambientNight.volume(nightAmbientSoundCue.getValueAt(p) * globalSoundVolume * ambientSoundVolume * 0.6);