Browse Source

Massive progress: main menu, sound, dialog

Load_Fix
Robert Chen 11 years ago
parent
commit
695264d6e1
  1. 3
      index.html
  2. 125
      js/dialogue.js
  3. 148
      js/main.js
  4. 3
      js/model.js
  5. 89
      js/screens.js
  6. 101
      js/soundmanager.js
  7. 11
      js/stories.js
  8. 42
      js/ui.js
  9. BIN
      res/Grass.png
  10. BIN
      res/Loading/.DS_Store
  11. BIN
      res/Loading/Loading-Title-Mockup.png
  12. BIN
      res/Loading/Loading-Title.png
  13. BIN
      res/Loading/PanFront.png
  14. BIN
      res/Loading/TextCooking.png
  15. BIN
      res/Loading/TextDone.png
  16. BIN
      res/Loading/Turkey0.png
  17. BIN
      res/Loading/Turkey25.png
  18. BIN
      res/Loading/Turkey50.png
  19. BIN
      res/Loading/Turkey75.png
  20. BIN
      res/Loading/TurkeyDone.png
  21. BIN
      res/Main-Screen.png
  22. BIN
      res/Main.png
  23. BIN
      res/MainScreen/.DS_Store
  24. BIN
      res/MainScreen/ButtonCredits.png
  25. BIN
      res/MainScreen/ButtonHelp.png
  26. BIN
      res/MainScreen/ButtonStart.png
  27. BIN
      res/TurkeySprite.png
  28. BIN
      res/items/.DS_Store
  29. BIN
      res/people/.DS_Store
  30. BIN
      res/people/Brother.png
  31. BIN
      res/screens/.DS_Store
  32. BIN
      res/screens/MarketScreen.png
  33. BIN
      res/screens/MarketTopShelf.png
  34. BIN
      res/sound/.DS_Store
  35. 35
      res/sound/Audio Sources.txt
  36. BIN
      res/sound/Events/.DS_Store
  37. BIN
      res/sound/Events/Fire/.DS_Store
  38. BIN
      res/sound/Events/Fire/87564__sgak__fire Fire Start Louder.mp3
  39. BIN
      res/sound/Events/Fire/87564__sgak__fire Loop.mp3
  40. BIN
      res/sound/GUI/.DS_Store
  41. BIN
      res/sound/GUI/buzz.mp3
  42. BIN
      res/sound/GUI/click.mp3
  43. BIN
      res/sound/GUI/lowclick.mp3
  44. BIN
      res/sound/GUI/pop.mp3
  45. BIN
      res/sound/Music/.DS_Store
  46. BIN
      res/sound/Music/Waterford.mp3
  47. BIN
      res/sound/Store/.DS_Store
  48. BIN
      res/sound/Store/Background Sounds/.DS_Store
  49. BIN
      res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 2.ogg
  50. BIN
      res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 3.mp3
  51. BIN
      res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 3.ogg
  52. BIN
      res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 4.ogg
  53. BIN
      res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 5.ogg
  54. BIN
      res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 6.ogg
  55. BIN
      res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop1.mp3
  56. BIN
      res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop1.ogg
  57. BIN
      res/sound/Store/backgroundSound.mp3
  58. BIN
      res/sound/Store/buy.mp3
  59. BIN
      res/sound/Store/entrance.mp3
  60. BIN
      res/sound/Waterford.mp3
  61. BIN
      res/sound/supermarket.mp3
  62. BIN
      res/sound/turkey_in_the_straw.ogg

3
index.html

@ -1,6 +1,6 @@ @@ -1,6 +1,6 @@
<html>
<head>
<title>Turkey Banking Simulator</title>
<title>Turkey Baking Simulator</title>
</head>
<body>
<br/><br/><br/><br/>
@ -40,4 +40,5 @@ @@ -40,4 +40,5 @@
/* do something with mouseX/mouseY */
}
</script>
<!-- Load all the things! -->
</html>

125
js/dialogue.js

@ -1,11 +1,130 @@ @@ -1,11 +1,130 @@
function DialogueSequence(){
function DialogueSequence( sequence ){
var targetStory = story[sequence].slice(0);
return {
next: function(){
return story.shift().split(": ")[1];
return targetStory.shift().split(": ")[1];
},
more: function(){
return story.length > 0;
return targetStory.length > 0;
}
}
}
function DialogUI( stage, gameState ){
var that = this;
// Dialog States
var DIALOG_RECEDING = 0;
var DIALOG_SHOWING = 1;
var DIALOG_PAUSING = 2;
var MILLIS_PER_CHAR = 100;
this.dialogSpeed = 30;
this.dialogState = DIALOG_PAUSING;
this.dialogMotionQueue = [DIALOG_RECEDING];
this.currDialogueSeq = new DialogueSequence("Null");
dialogQueue = [];
this.dialogBox = new createjs.Bitmap("res/DialogueBox.png");
this.dialogBox.x = 10;
this.dialogBox.y = 675;
this.textContent = new createjs.Text( "", "24px Arial", "#00000000" );
this.textContent.x = 205;
this.textContent.y = 705;
this.textContent.lineWidth = 565;
this.textContent.lineHeight = 30;
this.textContent.textBaseline = "alphabetic";
this.dialogBox.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } );
this.dialogBox.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } );
this.dialogBox.addEventListener( "click", function(){ setTimeout( clickEvent, 100); });
this.textContent.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } );
this.textContent.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } );
this.textContent.addEventListener( "click", function(){ setTimeout( clickEvent, 100); });
this.showDialog= function( textSeq ){
that.currDialogueSeq = new DialogueSequence( textSeq.seq );
that.textContent.text=that.currDialogueSeq.next();
that.autoAdvance = textSeq.autoAdvance;
that.dialogMotionQueue = [DIALOG_SHOWING];
}
gameState.pubsub.subscribe( "ShowDialog", this.showDialog );
// negate double setTimeout if clicked
var oldTime = new Date().getTime();
var delayCounter = 0;
var clickEvent = function( timer ){
// if there is more dialogue text, then keep going, otherwise, recede
if( that.currDialogueSeq.more() ){
setTimeout( function(){ that.dialogMotionQueue.push(DIALOG_SHOWING) }, 500);
that.textContent.text=that.currDialogueSeq.next();
delayCounter = 0;
oldTime = new Date().getTime()
}else{
// pause and close dialog
setTimeout( function(){that.dialogMotionQueue.push(DIALOG_RECEDING)}, 500 );
}
}
stage.addChild( this.dialogBox );
stage.addChild( this.textContent );
return {
tick: function(){
delayCounter = new Date().getTime() - oldTime;
if( that.autoAdvance == true && that.dialogBox.y ==435 && delayCounter > ( that.textContent.text.length * MILLIS_PER_CHAR ) ){
clickEvent();
}
if( that.dialogState == DIALOG_RECEDING ){
that.dialogBox.y+=that.dialogSpeed;
that.textContent.y +=that.dialogSpeed;
console.log( "Receding" + that.dialogBox.y );
}
if( that.dialogState == DIALOG_SHOWING ){
that.dialogBox.y-=that.dialogSpeed;
that.textContent.y -=that.dialogSpeed;
console.log( "Advancing" + that.dialogBox.y );
}
// toggle states
if( that.dialogBox.y > 675 && that.dialogState == DIALOG_RECEDING ){
that.dialogBox.y = 675;
that.textContent.y = 735;
that.dialogState = DIALOG_PAUSING;
console.log( "Pausing on recede" + that.dialogBox.y );
}
if( that.dialogBox.y < 435 && that.dialogState == DIALOG_SHOWING ){
that.dialogBox.y = 435;
that.textContent.y = 480;
that.dialogState = DIALOG_PAUSING;
console.log( "Pausing on showing" + that.dialogBox.y );
}
/* next states if there are any on the queue */
if( that.dialogMotionQueue.length > 0 && that.dialogState == DIALOG_PAUSING ){
that.dialogState = that.dialogMotionQueue.shift();
}
},
minDialog: function(){
that.dialogMotionQueue.push( DIALOG_RECEDING );
},
maxDialog: function(){
that.dialogMotionQueue.push( DIALOG_SHOWING );
},
render: function(){
stage.addChild( that.dialogBox );
stage.addChild( that.textContent );
}
}
}

148
js/main.js

@ -6,13 +6,19 @@ function GameState(){ @@ -6,13 +6,19 @@ function GameState(){
this.currentTime = new Date().getTime();
this.oldTime = new Date().getTime();
this.name = "";
this.gender = "";
this.wallet = 1000;
// Load all our resources:
var queue = new createjs.LoadQueue(true);
queue.installPlugin(createjs.Sound);
//queue.addEventListener("fileload", handleFileComplete);
queue.loadFile( {id: "TitleMusicFile", src:"res/sound/turkey_in_the_straw.mp3"} );
queue.loadFile( {id: "MarketBackgroundSoundFile", src:"res/sound/supermarket.mp3"} );
queue.loadFile( {id: "MarketBackgroundSoundFile", src:"res/items/FrillsBox.png"} );
queue.loadFile( {id: "TurkeySpriteFile", src:"res/TurkeySprite.png"} );
this.screenState = 0;
this.newScreen = "";
@ -21,15 +27,15 @@ function GameState(){ @@ -21,15 +27,15 @@ function GameState(){
// Game State flags
this.turkeyBought = false;
this.marketItems = {
"FrillsBox" : new MarketItem( this, "FrillsBox", 133,92, 100, "res/items/FrillsBox.png", "res/items/FrillsBoxGlow.png" ),
"FrillsBox" : new MarketItem( this, "FrillsBox", 133,92, 2000, "res/items/FrillsBox.png", "res/items/FrillsBoxGlow.png" ),
"TuTempProberkey" : new MarketItem( this, "TuTempProberkey", 200, 57, 100, "res/items/TempProbe.png", "res/items/TempProbeGlow.png" ),
"OvenLightBox" : new MarketItem( this, "OvenLightBox", 131,222, 100, "res/items/OvenLightBox.png", "res/items/OvenLightBoxGlow.png" ),
"OvenLightBox" : new MarketItem( this, "OvenLightBox", 131,222, 300, "res/items/OvenLightBox.png", "res/items/OvenLightBoxGlow.png" ),
"Alarm" : new MarketItem( this, "Alarm", 173,248, 100, "res/items/Alarm.png", "res/items/AlarmGlow.png" ),
"Cookbook" : new MarketItem( this, "Cookbook", 283,203, 100, "res/items/Cookbook1.png", "res/items/Cookbook1Glow.png" ),
"StuffingRepurposed" : new MarketItem( this, "StuffingRepurposed", 510,197, 100, "res/items/StuffingRepurposed.png", "res/items/StuffingRepurposedGlow.png" ),
"StuffingExquisite" : new MarketItem( this, "StuffingExquisite", 458,210, 100, "res/items/StuffingExquisite.png", "res/items/StuffingExquisiteGlow.png" ),
"StuffingSpecial" : new MarketItem( this, "StuffingSpecial", 390,220, 100, "res/items/StuffingSpecial.png", "res/items/StuffingSpecialGlow.png" ),
"Alarm" : new MarketItem( this, "Alarm", 173,248, 500, "res/items/Alarm.png", "res/items/AlarmGlow.png" ),
"Cookbook" : new MarketItem( this, "Cookbook", 283,203, 400, "res/items/Cookbook1.png", "res/items/Cookbook1Glow.png" ),
"StuffingRepurposed" : new MarketItem( this, "StuffingRepurposed", 510,197, 200, "res/items/StuffingRepurposed.png", "res/items/StuffingRepurposedGlow.png" ),
"StuffingExquisite" : new MarketItem( this, "StuffingExquisite", 458,210, 300, "res/items/StuffingExquisite.png", "res/items/StuffingExquisiteGlow.png" ),
"StuffingSpecial" : new MarketItem( this, "StuffingSpecial", 390,220, 500, "res/items/StuffingSpecial.png", "res/items/StuffingSpecialGlow.png" ),
"Turkey1" : new MarketItem( this, "Turkey1", 170,350, 100, "res/items/Turkey5.png", "res/items/Turkey5Glow.png" ),
"Turkey2": new MarketItem( this, "Turkey2", 540,320, 100, "res/items/Turkey4.png", "res/items/Turkey4Glow.png" ),
@ -46,6 +52,23 @@ function GameState(){ @@ -46,6 +52,23 @@ function GameState(){
this.mainUI = new GameUI( "demoCanvas", this );
createjs.Ticker.addEventListener( "tick", gameLoop );
function addHighScore(name, turkeyPoundage, cookTime, score){
var scores = {};
var now = new Date();
if( !localStorage.getItem("highScores") ){
scores = JSON.parse( localStorage.getItem("highScores") );
}
scores[now.getYear()+"/"+now.getMonth()+"/"+now.getDay()] = {
"name" : name,
"weight" : turkeyPoundage,
"cookTime" : cookTime,
"score" : score
};
localStorage.setItem("highScores", JSON.stringfy(scores));
}
function gameLoop(){
that.mainUI.draw();
}
@ -104,7 +127,9 @@ function GameUI( canvasElem, gameState ){ @@ -104,7 +127,9 @@ function GameUI( canvasElem, gameState ){
"CreditsScreen" : CreditsScreen
}
this.activeScreenObj = new MarketScreen( this.stage, gameState );
var soundManager = new SoundManager( gameState );
this.activeScreenObj = new MainScreen( this.stage, gameState );
var textContent = new createjs.Text( "", "20px Arial", "#00000000" );
textContent.x = 750;
textContent.y = 30;
@ -114,12 +139,12 @@ function GameUI( canvasElem, gameState ){ @@ -114,12 +139,12 @@ function GameUI( canvasElem, gameState ){
overlay.alpha = 0;
this.stage.addChild(overlay);
var soundManager = new SoundManager( gameState );
var dialogManager = new DialogUI( this.stage, gameState );
// delay for fade in and fade-out
this.switchScreen = function( screenName ){
gameState.screenState = SCREEN_OUT;
gameState.pubsub.publish( "FadeOut", "" );
dialogManager.minDialog();
console.log("Switch screen called with" + screenName);
gameState.newScreen = screenName;
};
@ -128,6 +153,7 @@ function GameUI( canvasElem, gameState ){ @@ -128,6 +153,7 @@ function GameUI( canvasElem, gameState ){
that.activeScreenObj = new that.screens[ screenName ]( that.stage, gameState );
that.stage.addChild( textContent );
that.stage.addChild( overlay );
dialogManager.render();
};
gameState.pubsub.subscribe( "SwitchScreen", this.switchScreen );
@ -159,114 +185,14 @@ function GameUI( canvasElem, gameState ){ @@ -159,114 +185,14 @@ function GameUI( canvasElem, gameState ){
}
soundManager.tick();
that.activeScreenObj.blit();
dialogManager.tick();
textContent.text = createjs.Ticker.getMeasuredFPS().toFixed(1);
that.stage.update();
}
}
}
function DialogUI( stage ){
var that = this;
// Dialog States
var DIALOG_RECEDING = 0;
var DIALOG_SHOWING = 1;
var DIALOG_PAUSING = 2;
var MILLIS_PER_CHAR = 100;
this.dialogSpeed = 30;
this.dialogState = DIALOG_PAUSING;
this.dialogMotionQueue = [DIALOG_SHOWING];
this.currDialogueSeq = new DialogueSequence();
dialogQueue = [];
this.dialogBox = new createjs.Bitmap("res/DialogueBox.png");
this.dialogBox.x = 10;
this.dialogBox.y = 675;
this.textContent = new createjs.Text( "Hey there kids!", "24px Arial", "#00000000" );
this.textContent.x = 205;
this.textContent.y = 705;
this.textContent.lineWidth = 565;
this.textContent.lineHeight = 30;
this.textContent.textBaseline = "alphabetic";
this.dialogBox.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } );
this.dialogBox.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } );
this.dialogBox.addEventListener( "click", function(){ setTimeout( clickEvent, 100); });
this.textContent.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } );
this.textContent.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } );
this.textContent.addEventListener( "click", function(){ setTimeout( clickEvent, 100); });
// negate double setTimeout if clicked
var oldTime = new Date().getTime();
var delayCounter = 0;
var clickEvent = function( timer ){
// if there is more dialogue text, then keep going, otherwise, recede
if( that.currDialogueSeq.more() ){
setTimeout( function(){ that.dialogMotionQueue.push(DIALOG_SHOWING) }, 1000);
that.textContent.text=that.currDialogueSeq.next();
delayCounter = 0;
oldTime = new Date().getTime()
}else{
// pause and close dialog
setTimeout( function(){that.dialogMotionQueue.push(DIALOG_RECEDING)}, 1000 );
}
}
stage.addChild( this.dialogBox );
stage.addChild( this.textContent );
return {
tick: function(){
delayCounter = new Date().getTime() - oldTime;
if(that.dialogBox.y ==435 && delayCounter > ( that.textContent.text.length * MILLIS_PER_CHAR ) ){
clickEvent();
}
if( that.dialogState == DIALOG_RECEDING ){
that.dialogBox.y+=that.dialogSpeed;
that.textContent.y +=that.dialogSpeed;
console.log( "Receding" + that.dialogBox.y );
}
if( that.dialogState == DIALOG_SHOWING ){
that.dialogBox.y-=that.dialogSpeed;
that.textContent.y -=that.dialogSpeed;
console.log( "Advancing" + that.dialogBox.y );
}
// toggle states
if( that.dialogBox.y > 675 && that.dialogState == DIALOG_RECEDING ){
that.dialogBox.y = 675;
that.textContent.y = 705;
that.dialogState = DIALOG_PAUSING;
console.log( "Pausing on recede" + that.dialogBox.y );
}
if( that.dialogBox.y < 435 && that.dialogState == DIALOG_SHOWING ){
that.dialogBox.y = 435;
that.textContent.y = 480;
that.dialogState = DIALOG_PAUSING;
console.log( "Pausing on showing" + that.dialogBox.y );
}
/* next states if there are any on the queue */
if( that.dialogMotionQueue.length > 0 && that.dialogState == DIALOG_PAUSING ){
that.dialogState = that.dialogMotionQueue.shift();
}
},
minDialog: function(){
that.dialogMotionQueue.push( DIALOG_RECEDING );
},
maxDialog: function(){
that.dialogMotionQueue.push( DIALOG_SHOWING );
},
}
}
function Dialogue( character, text ){
var that = this;

3
js/model.js

@ -218,6 +218,9 @@ UtilityFunctions = { @@ -218,6 +218,9 @@ UtilityFunctions = {
},
lbs2kgs: function(){
return pounds * 0.453592
},
randRange: function(lowVal,highVal) {
return Math.floor(Math.random()*(highVal-lowVal+1))+lowVal;
}
}

89
js/screens.js

@ -4,13 +4,12 @@ function LoadingTitleScreen( stage, gameState ){ @@ -4,13 +4,12 @@ function LoadingTitleScreen( stage, gameState ){
this.picture = new createjs.Bitmap( "res/Loading-Title.png" );
this.ovenLight = new createjs.Shape();
this.ovenLight.graphics.beginFill( "red" ).drawCircle( 396, 318, 5 );
this.ovenLight.addEventListener( "click", function(){alert("hello world")});
stage.addChild( this.picture );
stage.addChild( this.ovenLight );
this.uiElems = [];
this.uiElems.push( new DialogUI( stage ) );
this.uiElems.push( new DialogUI( stage, gameState ) );
return {
blit : function(){
@ -45,19 +44,49 @@ function InfoHelpScreen( stage, gameState ){ @@ -45,19 +44,49 @@ function InfoHelpScreen( stage, gameState ){
function MainScreen( stage, gameState ){
var that = this;
this.background = new createjs.Bitmap( "res/Main.png" );
this.background = new createjs.Bitmap( "res/Main-Screen.png" );
stage.addChild( this.background );
var turkeyAnimations = { peck:[14,24,"peck"], ruffle:[0,13,"ruffle"], stare:[25,35,"stare"] };
var data = {
images: ["res/TurkeySprite.png"],
frames: { width:400, height:350 },
animations: turkeyAnimations
};
var spriteSheet = new createjs.SpriteSheet(data);
var animation = new createjs.Sprite(spriteSheet, "stare");
animation.x = 200;
animation.y = 210;
animation.addEventListener("tick", handleTick);
function handleTick(event) {
if ( turkeyAnimations[event.currentTarget.currentAnimation][1] == event.currentTarget.currentFrame ){
event.currentTarget.paused = true;
}
// Click happened.
}
stage.addChild(animation);
this.grassLayer = new createjs.Bitmap( "res/Grass.png" );
stage.addChild( this.grassLayer );
// buttons info/credits/start
stage.addChild( new Button( stage, gameState, 13, 445, 222, 65, "SwitchScreen", "InfoHelpScreen" ) );
stage.addChild( new Button( stage, gameState, 13, 515, 222, 65, "SwitchScreen", "CreditsScreen" ) );
stage.addChild( new Button( stage, gameState, 564, 520, 222, 65, "SwitchScreen", "DifficultyScreen" ) );
new ImgButton( stage, gameState, 571,527, "res/MainScreen/ButtonStart.png", "res/MainScreen/ButtonStart.png","SwitchScreen", "DifficultyScreen", "Click" );
new ImgButton( stage, gameState, 17,470, "res/MainScreen/ButtonHelp.png", "res/MainScreen/ButtonHelp.png","SwitchScreen", "InfoScreen", "Click" );
new ImgButton( stage, gameState, 17,527, "res/MainScreen/ButtonCredits.png", "res/MainScreen/ButtonCredits.png","SwitchScreen", "CreditsScreen", "Click" );
gameState.pubsub.publish( "BackgroundLoop", {name:"TitleMusic", pos:5650, volume:1} );
this.uiElems = [];
return {
blit : function(){
// Randomly do stuff
if( createjs.Ticker.getTicks() %50 == 0 ){
animation.gotoAndPlay(["peck", "ruffle", "stare"][UtilityFunctions.randRange(0,2)]);
}
// Draw all the uiElements
for( var index in that.uiElems ){
that.uiElems[ index ].tick();
@ -92,22 +121,29 @@ function DifficultyScreen( stage, gameState ){ @@ -92,22 +121,29 @@ function DifficultyScreen( stage, gameState ){
function KitchenScreen( stage, gameState ){
var that = this;
// Fade out any other sounds
gameState.pubsub.publish( "FadeOut", "" );
this.background = new createjs.Bitmap( "res/kitchen.png" );
stage.addChild( this.background );
this.uiElems = [];
for(var i in gameState.purchasedItems ){
console.log(gameState.purchasedItems);
gameState.purchasedItems[i].draw( stage, 403+100*i, 350 );
}
this.uiElems.push( new OvenUI( stage, gameState ) );
this.uiElems.push( gameState.ovenUI ? gameState.ovenUI : ( gameState.ovenUI = new OvenUI( stage, gameState ) ) );
this.uiElems.push( new ClockUI( stage, gameState ) );
this.uiElems.push( new WindowUI( stage, gameState ) )
this.uiElems.push( new DialogUI( stage ) );
stage.addChild( new Button( stage, gameState, 500, 40, 450, 105, "SwitchScreen", "MarketScreen" ) );
// If player did not buy a turkey, tell them
if( !gameState.turkeyBought ){
gameState.pubsub.publish( "ShowDialog", {seq:"KitchenInitial", autoAdvance:false} );
}
return {
blit : function(){
@ -123,17 +159,46 @@ function KitchenScreen( stage, gameState ){ @@ -123,17 +159,46 @@ function KitchenScreen( stage, gameState ){
function MarketScreen( stage, gameState ){
var that = this;
this.background = new createjs.Bitmap( "res/Store-Screen-Clean.png" );
this.background = new createjs.Bitmap( "res/screens/MarketScreen.png" );
var price = new createjs.Text( "100", "24px Arial", "#00000000" );
price.x = 725;
price.y = 500;
var wallet = new createjs.Text( gameState.wallet, "24px Arial", "#00000000" );
wallet.x = 725;
wallet.y = 550;
// Play soundz
gameState.pubsub.publish( "Play", {name:"Entrance", volume:0.3} );
gameState.pubsub.publish( "BackgroundLoop", {name:"MarketMusic", volume:1} );
gameState.pubsub.publish( "BackgroundLoop", {name:"MarketSound", volume:0.4} );
stage.addChild( this.background );
stage.addChild(price);
stage.addChild(wallet);
this.uiElems = [];
this.uiElems.push( new ImgButton( stage, gameState, 690,0, "res/items/ExitSign.png", "res/items/ExitGlow.png","SwitchScreen", "KitchenScreen" ) );
this.uiElems.push( new ImgButton( stage, gameState, 690,0, "res/items/ExitSign.png", "res/items/ExitGlow.png","SwitchScreen", "KitchenScreen", "Click" ) );
var marketItemKeys = Object.keys(gameState.marketItems);
for (var index in marketItemKeys ) {
gameState.marketItems[marketItemKeys[index]].draw( stage );
}
this.topground = new createjs.Bitmap( "res/TopShelf.png" );
this.topground = new createjs.Bitmap( "res/screens/MarketTopShelf.png" );
stage.addChild( this.topground );
this.showPrice = function( cost ){
price.text = cost;
}
gameState.pubsub.subscribe( "ShowPrice", this.showPrice );
this.setWalletAmount = function(newAmount){
wallet.text=gameState.wallet=newAmount;
}
gameState.pubsub.subscribe("WalletAmount", this.setWalletAmount);
return {
blit : function(){

101
js/soundmanager.js

@ -0,0 +1,101 @@ @@ -0,0 +1,101 @@
function SoundInstance( soundObj, loop ){
this.soundObj = soundObj;
}
function SoundManager( gameState ){
var that = this;
var soundCache = [];
var AUDIO_OUT = 1;
var AUDIO_IN = 2;
var AUDIO_STABLE = 0;
this.audioState = AUDIO_STABLE;
// Register all sounds loaded in gameState
createjs.Sound.registerSound("res/sound/turkey_in_the_straw.mp3", "TitleMusic");
createjs.Sound.registerSound("res/sound/supermarket.mp3", "MarketBackgroundSound");
createjs.Sound.registerSound("res/sound/Music/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");
createjs.Sound.registerSound("res/sound/GUI/buzz.mp3", "Error");
createjs.Sound.registerSound("res/sound/Store/buy.mp3", "Buy");
createjs.Sound.registerSound("res/sound/Store/entrance.mp3", "Entrance");
createjs.Sound.registerSound("res/sound/Store/backgroundSound.mp3", "MarketSound");
this.backgroundSounds = [];
this.backgroundSoundsQueue = [];
this.fadeOut = function(){
for ( var i in that.backgroundSounds ){
that.backgroundSounds[i].audioState = AUDIO_OUT;
}
};
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);
}
else{
channel = soundCache[soundName.name] ? soundCache[soundName.name] : soundCache[soundName.name] = createjs.Sound.createInstance(soundName.name);
channel.volume = soundName.volume;
}
channel.play();
};
this.backgroundLoop = function( soundName ){
var newBackgroundSound;
if( typeof soundName != "object" ){
newBackgroundSound = soundCache[soundName] ? soundCache[soundName] : soundCache[soundName] = createjs.Sound.createInstance(soundName);
}
else{
newBackgroundSound = soundCache[soundName.name] ? soundCache[soundName.name] : soundCache[soundName.name] = createjs.Sound.createInstance( soundName.name );
newBackgroundSound.setPosition(soundName.pos || 0);
newBackgroundSound.volume = soundName.volume || 1;
newBackgroundSound.play();
// loop-de-loop
newBackgroundSound.addEventListener("complete", function(){
if( newBackgroundSound.volume == 0 ){ newBackgroundSound.stop(); return; }
newBackgroundSound.setPosition(soundName.pos || 0);
newBackgroundSound.volume = soundName.volume || 1;
newBackgroundSound.play();
});
}
that.backgroundSoundsQueue.push(newBackgroundSound);
};
gameState.pubsub.subscribe( "Play", this.play );
gameState.pubsub.subscribe( "BackgroundLoop", this.backgroundLoop );
gameState.pubsub.subscribe( "FadeOut", this.fadeOut );
return {
tick: function(){
for ( var i in that.backgroundSounds ){
if( that.backgroundSounds[i].audioState == AUDIO_OUT ){
that.backgroundSounds[i].volume -=0.03;
}
if( that.backgroundSounds[i].audioState == AUDIO_IN ){
that.backgroundSounds[i].volume +=0.03;
}
if( that.backgroundSounds[i].volume >= 1.0 ){
that.backgroundSounds[i].volume = 1;
}
if( that.backgroundSounds[i].volume <= 0.0 ){
that.backgroundSounds[i].volume = 0;
that.backgroundSounds[i].stop();
that.backgroundSounds.splice( i, 1 );
}
}
if( that.backgroundSounds.length == 0 ){
for ( var i in that.backgroundSoundsQueue ){
var newSound = that.backgroundSoundsQueue[i];
newSound.audioState = AUDIO_IN;
that.backgroundSounds.push( newSound );
}
that.backgroundSoundsQueue = [];
}
}
}
}

11
js/stories.js

@ -1,4 +1,10 @@ @@ -1,4 +1,10 @@
var story = ["Brother: Hey Grandpa, I've got a funny story about that primer you gave me",
var story = {
"Null":["Me: "],
"KitchenInitial" : ["Me: I need to buy a turkey..."],
"CannotBuyTurkey" : ["Me: I've barely have time for ONE turkey, let alone TWO!"],
"NoMoney" : ["Me: I can't afford this!"],
"BuyTurkeyFirst" : ["Me: You should buy a turkey first!"],
"PaintStory" : ["Brother: Hey Grandpa, I've got a funny story about that primer you gave me",
"Grandpa: You'll have to remind me, again, my memory isn't too good in my old age",
"Brother: Well, you gave me some primer to redo my room.",
"Mom: How is that going? Last I heard you had the priming done",
@ -9,4 +15,5 @@ var story = ["Brother: Hey Grandpa, I've got a funny story about that primer you @@ -9,4 +15,5 @@ var story = ["Brother: Hey Grandpa, I've got a funny story about that primer you
"Brother: Well yes, but I was also cutting the edges, like you taught me. And that was easier with the paint bucket in my hand. Or so I thought...",
"Brother: Right. Well, umm so I quickly put the paint can down in the roller pan, seee, that I had nearby, and as I turned around to go clean myself off with some paper towels, I noticed a drip line all the way from the garage.",
"Brother: That's not good. So I dashed for the towels, and tried to soak up as much as possible. And well.. yeah So, in the future, I probably won't go for your primer Grandpa.",
"Grandpa: ..."];
"Grandpa: ..."]
};

42
js/ui.js

@ -143,23 +143,40 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg ){ @@ -143,23 +143,40 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg ){
var mouseOut = new createjs.Bitmap( mouseOutImg );
mouseOver.x = mouseOut.x = x;
mouseOver.y = mouseOut.y = y;
mouseOut.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; mouseOver.visible = true; mouseOut.visible = false; } );
mouseOut.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; mouseOver.visible = false; mouseOut.visible = true; } );
mouseOver.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; mouseOver.visible = true; mouseOut.visible = false; } );
mouseOver.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; mouseOver.visible = false; mouseOut.visible = true; } );
mouseOut.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; mouseOver.visible = true; mouseOut.visible = false; gameState.pubsub.publish("ShowPrice", cost ); } );
mouseOut.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; mouseOver.visible = false; mouseOut.visible = true; gameState.pubsub.publish("ShowPrice", "" ); } );
mouseOver.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; mouseOver.visible = true; mouseOut.visible = false; gameState.pubsub.publish("ShowPrice", cost ); } );
mouseOver.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; mouseOver.visible = false; mouseOut.visible = true; gameState.pubsub.publish("ShowPrice", "" );} );
mouseOver.addEventListener( "click", function(){
if(!that.bought){
if(!that.bought && cost <= gameState.wallet ){
if( that.name.indexOf("Turkey") == 0 && gameState.turkeyBought != true){
gameState.turkeyBought = true;
gameState.marketItems[ that.name ].delete();
gameState.pubsub.publish("Play", {name:"Buy", volume:0.7} );
gameState.pubsub.publish("WalletAmount", gameState.wallet - Math.abs(cost))
}
// can we buy this? Only possible if you already bought a turkey
if( !that.name.indexOf("Turkey") == 0 && gameState.turkeyBought == true ){
else if( !that.name.indexOf("Turkey") == 0 && gameState.turkeyBought == true ){
gameState.purchasedItems.push( objReturn );
gameState.marketItems[ that.name ].delete();
that.bought = true;
gameState.pubsub.publish("Play", {name:"Buy", volume:0.7});
gameState.pubsub.publish("WalletAmount", gameState.wallet - Math.abs(cost));
}
// One turkey only
else if( that.name.indexOf("Turkey") == 0 && gameState.turkeyBought == true ){
gameState.pubsub.publish( "ShowDialog", {seq:"CannotBuyTurkey", autoAdvance:false} );
gameState.pubsub.publish( "Play", "Error" );
}
// Buy turkey first
else{
gameState.pubsub.publish( "ShowDialog", {seq:"BuyTurkeyFirst", autoAdvance:false} );
gameState.pubsub.publish( "Play", "Error" );
}
}
else{
gameState.pubsub.publish( "ShowDialog", {seq:"NoMoney", autoAdvance:false} );
gameState.pubsub.publish( "Play", "Error" );
}
});
@ -184,7 +201,7 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg ){ @@ -184,7 +201,7 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg ){
function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd, arg ){
function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd, arg, sound ){
var mouseOver = new createjs.Bitmap( mouseOverImg );
var mouseOut = new createjs.Bitmap( mouseOutImg );
mouseOver.x = mouseOut.x = x;
@ -193,7 +210,12 @@ function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd, @@ -193,7 +210,12 @@ function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd,
mouseOut.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; mouseOver.visible = false; mouseOut.visible = true; } );
mouseOver.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; mouseOver.visible = true; mouseOut.visible = false; } );
mouseOver.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; mouseOver.visible = false; mouseOut.visible = true; } );
mouseOver.addEventListener( "click", function(){ gameState.pubsub.publish( eventCmd, arg ) } );
mouseOver.addEventListener( "click", function(){
if( sound ){
gameState.pubsub.publish("Play", sound );
}
gameState.pubsub.publish( eventCmd, arg )
} );
mouseOver.visible = false;
stage.addChild( mouseOut );
stage.addChild( mouseOver );
@ -212,7 +234,7 @@ function Button( stage, gameState, x_orig, y_orig, x_dest, y_dest, eventCmd, arg @@ -212,7 +234,7 @@ 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;
}

BIN
res/Grass.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

BIN
res/Loading/.DS_Store vendored

Binary file not shown.

BIN
res/Loading/Loading-Title-Mockup.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 324 KiB

BIN
res/Loading/Loading-Title.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 KiB

BIN
res/Loading/PanFront.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
res/Loading/TextCooking.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

BIN
res/Loading/TextDone.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
res/Loading/Turkey0.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 96 KiB

BIN
res/Loading/Turkey25.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 103 KiB

BIN
res/Loading/Turkey50.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

BIN
res/Loading/Turkey75.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

BIN
res/Loading/TurkeyDone.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

BIN
res/Main-Screen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 593 KiB

BIN
res/Main.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 92 KiB

BIN
res/MainScreen/.DS_Store vendored

Binary file not shown.

BIN
res/MainScreen/ButtonCredits.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
res/MainScreen/ButtonHelp.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
res/MainScreen/ButtonStart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
res/TurkeySprite.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 MiB

BIN
res/items/.DS_Store vendored

Binary file not shown.

BIN
res/people/.DS_Store vendored

Binary file not shown.

BIN
res/people/Brother.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

BIN
res/screens/.DS_Store vendored

Binary file not shown.

BIN
res/screens/MarketScreen.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 518 KiB

BIN
res/screens/MarketTopShelf.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

BIN
res/sound/.DS_Store vendored

Binary file not shown.

35
res/sound/Audio Sources.txt

@ -0,0 +1,35 @@ @@ -0,0 +1,35 @@
Unless Otherwise noted, all sounds and music are in the public Domain.
---------------------------
<Turkey in the Straw>
turkey_in_the_straw
Composition Licence: Traditional, arr. first published between 1829 and 1834. This MP3 (or other media file) is in the public domain because its copyright has expired. This applies to the United States, where Works published prior to 1978 were copyright protected for a maximum of 75 years. See Circular 1 "COPYRIGHT BASICS" from the U.S. Copyright Office. Works published before 1924 are now in the public domain.
This file is also in the public domain in countries that figure copyright from the date of death of the artist (post mortem auctoris in this case George Washington Dixon 1801? âMarch 2, 1861), and that most commonly runs for a period of 50 to 70 years from December 31 of that year.
Performance Licence: The United States Air Force Band Web site is provided as a public service by the United States Air Force Band and Department of the Air Force.
Information presented on the United States Air Force Band site is considered public information and may be distributed or copied. Use of appropriate byline/photo/image credits is requested.
UPLOADED by Sookietex
---------------------------
<Clicks>
Freesound.org
file name references the author name and file number.
---------------------------
Title: Improved Ice Cream Truck
Artist: Kevin MacLeod
Genre: Folk
Length: 0:51
Bitrate: 320 kbps
Size: 1.93MB
An improved version of a traditional Ice Cream Truck melody… whose actual title I forget.

BIN
res/sound/Events/.DS_Store vendored

Binary file not shown.

BIN
res/sound/Events/Fire/.DS_Store vendored

Binary file not shown.

BIN
res/sound/Events/Fire/87564__sgak__fire Fire Start Louder.mp3

Binary file not shown.

BIN
res/sound/Events/Fire/87564__sgak__fire Loop.mp3

Binary file not shown.

BIN
res/sound/GUI/.DS_Store vendored

Binary file not shown.

BIN
res/sound/GUI/buzz.mp3

Binary file not shown.

BIN
res/sound/GUI/click.mp3

Binary file not shown.

BIN
res/sound/GUI/lowclick.mp3

Binary file not shown.

BIN
res/sound/GUI/pop.mp3

Binary file not shown.

BIN
res/sound/Music/.DS_Store vendored

Binary file not shown.

BIN
res/sound/Music/Waterford.mp3

Binary file not shown.

BIN
res/sound/Store/.DS_Store vendored

Binary file not shown.

BIN
res/sound/Store/Background Sounds/.DS_Store vendored

Binary file not shown.

BIN
res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 2.ogg

Binary file not shown.

BIN
res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 3.mp3

Binary file not shown.

BIN
res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 3.ogg

Binary file not shown.

BIN
res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 4.ogg

Binary file not shown.

BIN
res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 5.ogg

Binary file not shown.

BIN
res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop 6.ogg

Binary file not shown.

BIN
res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop1.mp3

Binary file not shown.

BIN
res/sound/Store/Background Sounds/72565__wrinex__supermarkt-ms Loop1.ogg

Binary file not shown.

BIN
res/sound/Store/backgroundSound.mp3

Binary file not shown.

BIN
res/sound/Store/buy.mp3

Binary file not shown.

BIN
res/sound/Store/entrance.mp3

Binary file not shown.

BIN
res/sound/Waterford.mp3

Binary file not shown.

BIN
res/sound/supermarket.mp3

Binary file not shown.

BIN
res/sound/turkey_in_the_straw.ogg

Binary file not shown.
Loading…
Cancel
Save