content/hifi-content/caitlyn/dev/whackamole/wam_build/WhackAMole_Main.js
2022-02-13 22:19:19 +01:00

82 lines
2.7 KiB
JavaScript

(function() {
Script.include("http://hifi-public.s3.amazonaws.com/scripts/libraries/utils.js");
var _this;
whackamole = function(){
_this = this;
return;
};
whackamole.prototype = {
musicClip:null,
musicInjector:null,
preload: function(entityID) {
this.entityID = entityID;
this.musicClip = SoundCache.getSound("http://hifi-content.s3.amazonaws.com/caitlyn/dev/whackamole/wam_build/223196__rap2h__3-revoltant.wav");
var posProperties = Entities.getEntityProperties(this.entityID, ["position", "rotation"]);
var emitPoint = posProperties.position;
if (this.musicClip.downloaded){
var options = { volume: 0.0045, loop: true, position: emitPoint, localOnly: true }
this.musicInjector = Audio.playSound(this.musicClip, options);
}
},
unload: function(){
this.musicInjector.stop();
},
}; // entity scripts always need to return a newly constructed object of our type
return new whackamole();
});
// WAM Script pseudocode
// Caitlyn Meeks
// Problems - you can't reference items in code, hardcoded by their UIDs
// Instead, you should get children by the "Find my children" method
// And use UserData tags to more easily identify the relevant children
// ** Constants and variables
// Score - Int
// ElapsedTime - Int - amount of time since the player started
// GameSpeed - int - Current speed of the game, which starts slow and increases
// MoleArray [9] Array to store UIDs for the moles
// SESSION_TIME - Default time of a game (30s)
// GAMESPEED_START - Speed at which the game begins before beginning to increases
// POPUP_FRAME_START, POPUP_FRAME_END - Frame numbers for popping animation
// ATTRACT_FRAME_START, ATTRACT_FRAME_END - Frame numbers for attract animation
// **Initialize
// Get the UIDs of all my concerned children and make sure they are all there
// ** Set up the game
// Put UID of each mole in MoleArray
// Instantiate an invisible sphere on each mole joint
// Set each mole joint to the default animation frame of 0 (hidden)
// Pull the mallet into place
// ** Attract mode
// Play music
// Intermittently play ATTRACT mode animations on one or two moles at a time, play taunt sound
// Flash the lights
// Play intermittent random attract sounds
// ** Start mole gameplay
// Start timer
// Loop:
// Is there still time? No, go to gameover. Yes, continue.
// Randomly select a mole which isn't currently playing an animation
// Play that mole's animation and a sound
// Is there collision between the mole's sphere and the mallet? score++ and a sound
// Wait gamespeed
// gamespeed ++
// end loop
// ** gameover - you've run out of time