Browse Source

More fixes

Load_Fix
Robert Chen 11 years ago
parent
commit
28116d8e52
  1. 11
      js/main.js
  2. 11
      js/model.js
  3. 13
      js/screens.js
  4. 52
      js/ui.js
  5. BIN
      res/screens/.DS_Store
  6. BIN
      res/screens/KitchenScreen/.DS_Store
  7. BIN
      res/sound/.DS_Store

11
js/main.js

@ -9,6 +9,7 @@ function GameState(){ @@ -9,6 +9,7 @@ function GameState(){
this.name = "";
this.gender = "Male";
this.wallet = 40.00;
this.hard = false;
// Load all our resources:
var queue = new createjs.LoadQueue(true);
@ -65,6 +66,12 @@ function GameState(){ @@ -65,6 +66,12 @@ function GameState(){
queue.loadFile( {id: "res/screens/KitchenScreen/TurkeyState4.svg", src:"res/screens/KitchenScreen/TurkeyState4.svg"});
queue.loadFile( {id: "res/screens/KitchenScreen/TurkeyState5.svg", src:"res/screens/KitchenScreen/TurkeyState5.svg"});
queue.loadFile( {id: "res/screens/KitchenScreen/CookbookKitchenGlow.png", src:"res/screens/KitchenScreen/CookbookKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/CookbookKitchen.png", src:"res/screens/KitchenScreen/CookbookKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/AlarmKitchenGlow.png", src:"res/screens/KitchenScreen/AlarmKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/AlarmKitchen.png", src:"res/screens/KitchenScreen/AlarmKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/TempProbeKitchenGlow.png", src:"res/screens/KitchenScreen/TempProbeKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/TempProbeKitchen.png", src:"res/screens/KitchenScreen/TempProbeKitchen.png"});
@ -89,10 +96,6 @@ function GameState(){ @@ -89,10 +96,6 @@ function GameState(){
queue.loadFile( {id: "res/screens/KitchenScreen/DoorOpen.png", src:"res/screens/KitchenScreen/DoorOpen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/DoorClosedLightOn.png", src:"res/screens/KitchenScreen/DoorClosedLightOn.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/DoorClosedLightOff.png", src:"res/screens/KitchenScreen/DoorClosedLightOff.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/CookbookKitchenGlow.png", src:"res/screens/KitchenScreen/CookbookKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/CookbookKitchen.png", src:"res/screens/KitchenScreen/CookbookKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/AlarmKitchenGlow.png", src:"res/screens/KitchenScreen/AlarmKitchenGlow.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/AlarmKitchen.png", src:"res/screens/KitchenScreen/AlarmKitchen.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/PanFront.png", src:"res/screens/KitchenScreen/PanFront.png"});
queue.loadFile( {id: "res/screens/KitchenScreen/OvenTurnRedState.png", src:"res/screens/KitchenScreen/OvenTurnRedState.png"});

11
js/model.js

@ -76,7 +76,7 @@ function OvenModel( turkeyWeight, gameState ) { @@ -76,7 +76,7 @@ function OvenModel( turkeyWeight, gameState ) {
if ( that.equalizeTemp() ) {
// Turn on oven light
gameState.pubsub.publish( "OvenLight", "On" );
//gameState.pubsub.publish( "OvenLight", "On" );
//Reset the model's time calculation if there are major changes in the tolerance of the temperature
that.globalTime = 0;
@ -84,12 +84,15 @@ function OvenModel( turkeyWeight, gameState ) { @@ -84,12 +84,15 @@ function OvenModel( turkeyWeight, gameState ) {
else {
// Turn off oven light
gameState.pubsub.publish( "OvenLight", "Off" );
//gameState.pubsub.publish( "OvenLight", "Off" );
that.globalTime = that.globalTime + 60;
}
console.log( that.tempInfini )
turkey.updateLayerTemps();
},
getTurkeyState: function(){
}
}
}
@ -230,8 +233,8 @@ var ovenObject = new OvenModel(); @@ -230,8 +233,8 @@ var ovenObject = new OvenModel();
var turkey = new TurkeyModel( 8, ovenObject );
globalTime=0;
setInterval(function(){time()},100);
setInterval(function(){ovenObject.secondTick()},100);
ovenObject.changeTemp(100)
function time() {
console.clear()
if (ovenObject.equalizeTemp() ) {

13
js/screens.js

@ -189,7 +189,7 @@ function DifficultyScreen( stage, gameState ){ @@ -189,7 +189,7 @@ function DifficultyScreen( stage, gameState ){
// handle keyboard typing
document.onkeyup = function(event){
// keycode
var keynum = 0;
var keynum = 48;
if(window.event){ // IE
keynum = event.keyCode;
}
@ -199,7 +199,7 @@ function DifficultyScreen( stage, gameState ){ @@ -199,7 +199,7 @@ function DifficultyScreen( stage, gameState ){
}
}
if( keynum != 8 && nameInput.text.length < 22 )
if( keynum != 8 && keynum < 91 && keynum > 47 && nameInput.text.length < 22 )
nameInput.text += String.fromCharCode(keynum);
};
@ -220,16 +220,18 @@ function DifficultyScreen( stage, gameState ){ @@ -220,16 +220,18 @@ function DifficultyScreen( stage, gameState ){
nameInput.text = nameInput.text.substr(0, nameInput.text.length-1);
}
gameState.name = nameInput.text;
// 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" ) );
stage.addChild( new Button( stage, gameState, 503, 370, 200, 55, "SwitchScreen", "KitchenScreen" ) );
stage.addChild( new Button( stage, gameState, 500, 495, 205, 55, "SwitchScreen", "KitchenScreen" ) );
stage.addChild( new Button( stage, gameState, 503, 370, 200, 55, null, null, function(){ gameState.hard = false; gameState.pubsub.publish("SwitchScreen", "KitchenScreen"); } ) );
stage.addChild( new Button( stage, gameState, 500, 495, 205, 55, null, null, function(){ gameState.hard = true; gameState.pubsub.publish("SwitchScreen", "KitchenScreen"); } ) );
stage.addChild( new Button( stage, gameState, 35, 495, 85, 55, "SwitchScreen", "MainScreen" ) );
gameState.pubsub.subscribe("ChangeGender", function(gender){
gameState.pubsub.subscribe( "ChangeGender", function(gender){
gameState.gender=gender;
if( gender == "Male" ){
that.maleSelection.alpha = 1;
@ -274,6 +276,7 @@ function KitchenScreen( stage, gameState ){ @@ -274,6 +276,7 @@ function KitchenScreen( stage, gameState ){
this.uiElems.push( new WindowUI( stage, gameState ) )
stage.addChild( new Button( stage, gameState, 500, 40, 450, 105, "SwitchScreen", "MarketScreen" ) );
stage.addChild( new Button( stage, gameState, 14, 17, 73, 45, "SwitchScreen", "HelpScreen" ) );
new ImgButton( stage, gameState, 571,527, "res/screens/KitchenScreen/StoreBrochure.png", "res/screens/KitchenScreen/StoreBrochureGlow.png", "SwitchScreen", "MarketScreen", "Click" );
// If player did not buy a turkey, tell them
if( !gameState.turkeyBought ){

52
js/ui.js

@ -67,7 +67,17 @@ function OvenUI( stage, gameState ){ @@ -67,7 +67,17 @@ function OvenUI( stage, gameState ){
}
}
gameState.pubsub.subscribe( "OvenLight", this.changeOvenLight );
var turkeyStates = [
new createjs.Bitmap( "res/screens/KitchenScreen/TurkeyState1.svg" ),
new createjs.Bitmap( "res/screens/KitchenScreen/TurkeyState2.svg" ),
new createjs.Bitmap( "res/screens/KitchenScreen/TurkeyState3.svg" ),
new createjs.Bitmap( "res/screens/KitchenScreen/TurkeyState4.svg" ),
new createjs.Bitmap( "res/screens/KitchenScreen/TurkeyState5.svg" )
];
for (i in turkeyStates){
turkeyStates[i].alpha = 0;
}
var temperatureText = new createjs.Text( "OFF", "40px Arial", "#ff7700" );
temperatureText.x = 50;
@ -92,6 +102,11 @@ function OvenUI( stage, gameState ){ @@ -92,6 +102,11 @@ function OvenUI( stage, gameState ){
var doorOpen = new createjs.Bitmap( "res/screens/KitchenScreen/DoorOpen.png" );
doorOpen.alpha = 0;
var redState = new createjs.Bitmap( "res/screens/KitchenScreen/OvenTurnRedState.png" );
redState.alpha = 0;
var panFront = new createjs.Bitmap( "res/screens/KitchenScreen/PanFront.png" );
this.changeTemperature = function( direction ){
if( temperatureText.text == "OFF" && direction == "Up" ) temperatureText.text = "125";
@ -182,6 +197,8 @@ function OvenUI( stage, gameState ){ @@ -182,6 +197,8 @@ function OvenUI( stage, gameState ){
// change temperature, this one's for the UI
gameState.pubsub.subscribe( "ChangeTemperature", this.changeTemperature );
gameState.pubsub.subscribe( "OvenLightToggle", this.ovenLightToggle );
gameState.pubsub.subscribe( "OvenLight", this.changeOvenLight );
this.secondTick = function(){
ovenModel.secondTick();
@ -201,7 +218,12 @@ function OvenUI( stage, gameState ){ @@ -201,7 +218,12 @@ function OvenUI( stage, gameState ){
stage.addChild( this.text );
stage.addChild( lightPressedImg);
// Turkey goes here
// did the player actually buy a turkey? if so, determine its cooked state
if( gameState.turkeyBought ){
turkeyStates[0].alpha = 1;
}
// Pan front goes here
stage.addChild( panFront );
stage.addChild( doorPeekLightOn);
stage.addChild( doorPeekLightOff);
@ -226,7 +248,6 @@ return { @@ -226,7 +248,6 @@ return {
function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, funnyDescription, weight ){
var that = this;
console.log("Loading market item" + name);
this.name = name;
this.bought = false;
var mouseOver = new createjs.Bitmap( mouseOverImg );
@ -314,7 +335,7 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, fun @@ -314,7 +335,7 @@ function MarketItem( gameState, name, x, y, cost, mouseOutImg, mouseOverImg, fun
function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd, arg, sound ){
function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd, arg, sound, altfunc ){
var mouseOver = new createjs.Bitmap( mouseOverImg );
var mouseOut = new createjs.Bitmap( mouseOutImg );
mouseOver.x = mouseOut.x = x;
@ -327,7 +348,11 @@ function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd, @@ -327,7 +348,11 @@ function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd,
if( sound ){
gameState.pubsub.publish("Play", sound );
}
gameState.pubsub.publish( eventCmd, arg )
if( !altfunc){
gameState.pubsub.publish( eventCmd, arg );
return;
}
altfunc();
} );
mouseOver.visible = false;
stage.addChild( mouseOut );
@ -338,18 +363,23 @@ function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd, @@ -338,18 +363,23 @@ function ImgButton( stage, gameState, x, y, mouseOutImg, mouseOverImg, eventCmd,
}
}
function Button( stage, gameState, x_orig, y_orig, x_dest, y_dest, eventCmd, arg ){
function Button( stage, gameState, x_orig, y_orig, x_dest, y_dest, eventCmd, arg, altfunc ){
var that = this;
var button = new createjs.Shape();
button.graphics.beginFill("#ffffff").drawRect(x_orig, y_orig, x_dest, y_dest);
button.alpha = 0.5;
button.addEventListener( "click", function(){ gameState.pubsub.publish( eventCmd, arg ) } );
button.addEventListener( "click", function(){
gameState.pubsub.publish( "Play", "Click" );
if( !altfunc ){
gameState.pubsub.publish( eventCmd, arg );
return;
}
console.log(altfunc);
altfunc();
gameState.pubsub.publish( eventCmd, arg );
} );
button.addEventListener( "mouseover", function(){ document.body.style.cursor='pointer'; } );
button.addEventListener( "mouseout", function(){ document.body.style.cursor='default'; } );
button.addEventListener( "click", function(){
gameState.pubsub.publish( "Play", "Click" );
});
return button;
}

BIN
res/screens/.DS_Store vendored

Binary file not shown.

BIN
res/screens/KitchenScreen/.DS_Store vendored

Binary file not shown.

BIN
res/sound/.DS_Store vendored

Binary file not shown.
Loading…
Cancel
Save