diff --git a/js/main.js b/js/main.js index 470345e..6747c8e 100644 --- a/js/main.js +++ b/js/main.js @@ -98,8 +98,15 @@ function GameState(){ queue.loadFile( {id: "res/screens/KitchenScreen/OvenTurnRedState.png", src:"res/screens/KitchenScreen/OvenTurnRedState.png"}); queue.loadFile( {id: "res/screens/KitchenScreen/LightButtonDepressed.png", src:"res/screens/KitchenScreen/LightButtonDepressed.png"}); - // Market Items + // Kitchen Sounds + queue.loadFile( {id: "res/sound/Kitchen/Oven_Door_Full_Open.mp3", src:"res/sound/Kitchen/Oven_Door_Full_Open.mp3"}); + queue.loadFile( {id: "res/sound/Kitchen/Oven_Door_Full_Close.mp3", src:"res/sound/Kitchen/Oven_Door_Full_Close.mp3"}); + queue.loadFile( {id: "res/sound/Kitchen/Oven_Door_Peek_Close.mp3", src:"res/sound/Kitchen/Oven_Door_Peek_Close.mp3"}); + queue.loadFile( {id: "res/sound/Kitchen/Oven_Door_Peek_Open.mp3", src:"res/sound/Kitchen/Oven_Door_Peek_Open.mp3"}); + + + // Market Items queue.loadFile( {id: "res/screens/MarketScreen/MarketTopShelf.png", src:"res/screens/MarketScreen/MarketTopShelf.png"}); queue.loadFile( {id: "res/items/Clipboard.png", src:"res/items/Clipboard.png"}); diff --git a/js/screens.js b/js/screens.js index 869c11a..a42bc16 100644 --- a/js/screens.js +++ b/js/screens.js @@ -179,6 +179,47 @@ function DifficultyScreen( stage, gameState ){ this.femaleSelection.alpha = 0; stage.addChild( this.femaleSelection ); + var nameInput = new createjs.Text( "", "48px Arial", "#00000000" ); + nameInput.x = 47; + nameInput.y = 85; + nameInput.lineWidth = 175; + + stage.addChild( nameInput ); + + // handle keyboard typing + document.onkeyup = function(event){ + // keycode + var keynum = 0; + if(window.event){ // IE + keynum = event.keyCode; + } + else{ + if(event.which){ // Netscape/Firefox/Opera + keynum = event.which; + } + } + + if( keynum != 8 && nameInput.text.length < 22 ) + nameInput.text += String.fromCharCode(keynum); + }; + + + // Backspace gets special treatment + document.onkeydown = function(event){ + var keynum = 0; + if(window.event){ // IE + keynum = event.keyCode; + } + else{ + if(event.which){ // Netscape/Firefox/Opera + keynum = event.which; + } + } + + if(keynum == 8 && nameInput.text.length > 0 ) + nameInput.text = nameInput.text.substr(0, nameInput.text.length-1); + } + // Easy/Hard Button stage.addChild( new Button( stage, gameState, 500, 235, 100, 55, "ChangeGender", "Male" ) ); stage.addChild( new Button( stage, gameState, 500, 300, 100, 55, "ChangeGender", "Female" ) ); @@ -278,7 +319,7 @@ function MarketScreen( stage, gameState ){ var clipboardText = new createjs.Text( "Turkey", "16px Arial", "#00000000" ); clipboardText.x = 23; clipboardText.y = 425; - clipboardText.lineWidth = 175; + clipboardText.lineWidth = 173; var clipboardWeight = new createjs.Text( "", "16px Arial", "#00000000" ); clipboardWeight.x = 120; diff --git a/js/soundmanager.js b/js/soundmanager.js index 2368196..54fcd0f 100644 --- a/js/soundmanager.js +++ b/js/soundmanager.js @@ -3,7 +3,7 @@ function SoundInstance( soundObj, loop ){ } function SoundManager( gameState ){ var that = this; - var soundCache = []; + var soundCache = {}; var AUDIO_OUT = 1; var AUDIO_IN = 2; @@ -14,7 +14,7 @@ function SoundManager( gameState ){ // Register all sounds loaded in gameState createjs.Sound.registerSound("res/sound/turkey_in_the_straw.mp3", "TitleMusic"); createjs.Sound.registerSound("res/sound/Store/supermarket.mp3", "MarketBackgroundSound"); - createjs.Sound.registerSound("res/sound/Music/Waterford.mp3", "MarketMusic"); + createjs.Sound.registerSound("res/sound/Store/Waterford.mp3", "MarketMusic"); createjs.Sound.registerSound("res/sound/GUI/pop.mp3", "Pop"); createjs.Sound.registerSound("res/sound/GUI/lowclick.mp3", "LowClick"); createjs.Sound.registerSound("res/sound/GUI/click.mp3", "Click"); @@ -22,6 +22,12 @@ function SoundManager( gameState ){ createjs.Sound.registerSound("res/sound/Store/buy.mp3", "Buy"); createjs.Sound.registerSound("res/sound/Store/entrance.mp3", "Entrance"); + // Kitchen sound + createjs.Sound.registerSound("res/sound/Kitchen/Oven_Door_Full_Open.mp3", "Oven_Door_Full_Open"); + createjs.Sound.registerSound("res/sound/Kitchen/Oven_Door_Full_Close.mp3", "Oven_Door_Full_Close"); + createjs.Sound.registerSound("res/sound/Kitchen/Oven_Door_Peek_Close.mp3", "Oven_Door_Peek_Close"); + createjs.Sound.registerSound("res/sound/Kitchen/Oven_Door_Peek_Open.mp3", "Oven_Door_Peek_Open"); + this.backgroundSounds = []; this.backgroundSoundsQueue = []; @@ -33,10 +39,12 @@ function SoundManager( gameState ){ this.play = function( soundName ){ var channel = createjs.Sound.createInstance("Pop"); if( typeof soundName != "object" ){ - channel = soundCache[soundName] ? soundCache[soundName] : soundCache[soundName] = createjs.Sound.createInstance(soundName); + + channel = ( soundCache[soundName] ? soundCache[soundName] : soundCache[soundName] = createjs.Sound.createInstance(soundName) ); + channel.volume = 1; } else{ - channel = soundCache[soundName.name] ? soundCache[soundName.name] : soundCache[soundName.name] = createjs.Sound.createInstance(soundName.name); + channel = ( soundCache[soundName.name] ? soundCache[soundName.name] : soundCache[soundName.name] = createjs.Sound.createInstance(soundName.name) ); channel.volume = soundName.volume; } channel.play(); diff --git a/js/ui.js b/js/ui.js index 2cffdc0..c41f8ee 100644 --- a/js/ui.js +++ b/js/ui.js @@ -146,8 +146,10 @@ function OvenUI( stage, gameState ){ doorPeekLightOff.alpha = doorClosedLightOff.alpha = 0; doorOpen.alpha = 1; handleBar.y = 330; + gameState.pubsub.publish( "Play", "Oven_Door_Full_Open" ); }else if (that.ovenDoor == OVEN_OPEN ){ that.ovenDoor = OVEN_PEEK; + gameState.pubsub.publish( "Play", "Oven_Door_Full_Close" ); ovenPeek(); } } @@ -155,13 +157,15 @@ function OvenUI( stage, gameState ){ handleBar.addEventListener( "click", ovenPeek ); function ovenPeek(){ - if( that.ovenDoor == OVEN_CLOSED || that.ovenDoor == OVEN_OPEN ){ + if( that.ovenDoor == OVEN_CLOSED && that.ovenDoor != OVEN_OPEN ){ + gameState.pubsub.publish( "Play", "Oven_Door_Peek_Open" ); doorPeekLightOn.alpha = lightPressedImg.alpha == 0 ? 0 : 1; doorPeekLightOff.alpha = lightPressedImg.alpha == 0 ? 1 : 0; doorClosedLightOn.alpha = 0; doorClosedLightOff.alpha = 0; doorOpen.alpha = 0; that.ovenDoor = OVEN_PEEK; + handleBar.y = 48; } else if (that.ovenDoor == OVEN_PEEK){ @@ -170,6 +174,7 @@ function OvenUI( stage, gameState ){ doorPeekLightOn.alpha = 0; doorPeekLightOff.alpha = 0; that.ovenDoor = OVEN_CLOSED; + gameState.pubsub.publish( "Play", "Oven_Door_Peek_Close" ); doorOpen.alpha = 0; handleBar.y = 0; } @@ -185,28 +190,29 @@ function OvenUI( stage, gameState ){ setInterval(this.secondTick, 1000); - stage.addChild( this.text ); - stage.addChild(lightPressedImg); - // Turkey goes here - - stage.addChild(doorPeekLightOn); - stage.addChild(doorPeekLightOff); - - stage.addChild(doorClosedLightOn); - stage.addChild(doorClosedLightOff); - - stage.addChild(doorOpen); - stage.addChild(handleBar); return { tick: function(){}, render: function(){ - //Set position of Shape instance. + stage.addChild( ovenLight ); + stage.addChild( temperatureText ); + + stage.addChild( this.text ); + stage.addChild( lightPressedImg); + // Turkey goes here + + stage.addChild( doorPeekLightOn); + stage.addChild( doorPeekLightOff); + + stage.addChild( doorClosedLightOn); + stage.addChild( doorClosedLightOff); + + stage.addChild( doorOpen); stage.addChild( new Button( stage, gameState, 45, 163, 41, 17, "ChangeTemperature", "Up" ) ); stage.addChild( new Button( stage, gameState, 95, 163, 41, 17, "ChangeTemperature", "Down" ) ); stage.addChild( new Button( stage, gameState, 145, 163, 41, 17, "OvenLightToggle", "" ) ); - stage.addChild( temperatureText ); + stage.addChild( handleBar); return this; } } @@ -263,7 +269,7 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, fun gameState.pubsub.publish("WalletAmount", gameState.wallet - Math.abs(cost)) } // can we buy this? Only possible if you already bought a turkey - else if( !that.name.indexOf("Turkey") != -1 && gameState.turkeyBought == true ){ + else if( that.name.indexOf("Turkey") == -1 && gameState.turkeyBought == true ){ gameState.purchasedItems.push( objReturn ); gameState.marketItems[ that.name ].delete(); that.bought = true; @@ -341,7 +347,9 @@ function Button( stage, gameState, x_orig, y_orig, x_dest, y_dest, eventCmd, arg button.addEventListener( "click", function(){ gameState.pubsub.publish( eventCmd, arg ) } ); button.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } ); button.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } ); - gameState.pubsub.publish( "Play", "Click" ); - return button; + button.addEventListener( "click", function(){ + gameState.pubsub.publish( "Play", "Click" ); + }); + return button; } \ No newline at end of file diff --git a/res/Difficulty-Selection.png b/res/Difficulty-Selection.png deleted file mode 100644 index 5dc729d..0000000 Binary files a/res/Difficulty-Selection.png and /dev/null differ diff --git a/res/Loading-Title.png b/res/Loading-Title.png deleted file mode 100644 index 98a8e89..0000000 Binary files a/res/Loading-Title.png and /dev/null differ diff --git a/res/screens/.DS_Store b/res/screens/.DS_Store index 6feaaa8..c9758ab 100644 Binary files a/res/screens/.DS_Store and b/res/screens/.DS_Store differ diff --git a/res/sound/.DS_Store b/res/sound/.DS_Store index 20a4de0..ad5c995 100644 Binary files a/res/sound/.DS_Store and b/res/sound/.DS_Store differ diff --git a/res/sound/Events/.DS_Store b/res/sound/Events/.DS_Store index f166e1b..c8e453f 100644 Binary files a/res/sound/Events/.DS_Store and b/res/sound/Events/.DS_Store differ diff --git a/res/sound/Events/Fire/.DS_Store b/res/sound/Events/Fire/.DS_Store index c309567..29225a2 100644 Binary files a/res/sound/Events/Fire/.DS_Store and b/res/sound/Events/Fire/.DS_Store differ diff --git a/res/sound/GUI/.DS_Store b/res/sound/GUI/.DS_Store index 8d7ac03..41bd8e0 100644 Binary files a/res/sound/GUI/.DS_Store and b/res/sound/GUI/.DS_Store differ diff --git a/res/sound/Music/.DS_Store b/res/sound/Kitchen/.DS_Store similarity index 89% rename from res/sound/Music/.DS_Store rename to res/sound/Kitchen/.DS_Store index 86f5115..29d6dcc 100644 Binary files a/res/sound/Music/.DS_Store and b/res/sound/Kitchen/.DS_Store differ diff --git a/res/sound/Kitchen/Oven_Door_Full_Close.mp3 b/res/sound/Kitchen/Oven_Door_Full_Close.mp3 new file mode 100644 index 0000000..66e382b Binary files /dev/null and b/res/sound/Kitchen/Oven_Door_Full_Close.mp3 differ diff --git a/res/sound/Kitchen/Oven_Door_Full_Open.mp3 b/res/sound/Kitchen/Oven_Door_Full_Open.mp3 new file mode 100644 index 0000000..567a8b9 Binary files /dev/null and b/res/sound/Kitchen/Oven_Door_Full_Open.mp3 differ diff --git a/res/sound/Kitchen/Oven_Door_Peek_Close.mp3 b/res/sound/Kitchen/Oven_Door_Peek_Close.mp3 new file mode 100644 index 0000000..cd96349 Binary files /dev/null and b/res/sound/Kitchen/Oven_Door_Peek_Close.mp3 differ diff --git a/res/sound/Kitchen/Oven_Door_Peek_Open.mp3 b/res/sound/Kitchen/Oven_Door_Peek_Open.mp3 new file mode 100644 index 0000000..29538d0 Binary files /dev/null and b/res/sound/Kitchen/Oven_Door_Peek_Open.mp3 differ diff --git a/res/sound/Music/Waterford.mp3 b/res/sound/Music/Waterford.mp3 deleted file mode 100755 index 7761dcc..0000000 Binary files a/res/sound/Music/Waterford.mp3 and /dev/null differ