|
|
|
@@ -4,8 +4,6 @@ var GameState = function(game) {
|
|
|
|
GameState.prototype.updateClock = function()
|
|
|
|
GameState.prototype.updateClock = function()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.clock.setSeconds(this.clock.getSeconds() + 1);
|
|
|
|
this.clock.setSeconds(this.clock.getSeconds() + 1);
|
|
|
|
if ( this.clock.getSeconds() == 59)
|
|
|
|
|
|
|
|
player.score += SCORE_PERSECOND;
|
|
|
|
|
|
|
|
this.clock.setMilliseconds(0);
|
|
|
|
this.clock.setMilliseconds(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -31,7 +29,10 @@ GameState.prototype.create = function()
|
|
|
|
);
|
|
|
|
);
|
|
|
|
if ( lp['inject_sprites'] == true ) {
|
|
|
|
if ( lp['inject_sprites'] == true ) {
|
|
|
|
this.aiSprites = game.add.group();
|
|
|
|
this.aiSprites = game.add.group();
|
|
|
|
this.aiSprites.debug = true;
|
|
|
|
this.aiSprites.debug = false;
|
|
|
|
|
|
|
|
this.aiSpriteEffects = game.add.group();
|
|
|
|
|
|
|
|
this.staticSounds = game.add.group();
|
|
|
|
|
|
|
|
this.bubble_group = game.add.group();
|
|
|
|
this.map.createFromObjects('AI', 3544, 'player', 0, true, false, this.aiSprites, AISprite);
|
|
|
|
this.map.createFromObjects('AI', 3544, 'player', 0, true, false, this.aiSprites, AISprite);
|
|
|
|
this.aiSprites.forEach(function(spr) {
|
|
|
|
this.aiSprites.forEach(function(spr) {
|
|
|
|
spr.update_new_values();
|
|
|
|
spr.update_new_values();
|
|
|
|
@@ -91,6 +92,7 @@ GameState.prototype.create = function()
|
|
|
|
|
|
|
|
|
|
|
|
this.camera.follow(player, Phaser.Camera.FOLLOW_TOPDOWN);
|
|
|
|
this.camera.follow(player, Phaser.Camera.FOLLOW_TOPDOWN);
|
|
|
|
controls = game.input.keyboard.createCursorKeys();
|
|
|
|
controls = game.input.keyboard.createCursorKeys();
|
|
|
|
|
|
|
|
controls.run = game.input.keyboard.addKey(Phaser.Keyboard.SHIFT);
|
|
|
|
controls.steal = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
|
|
|
|
controls.steal = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);
|
|
|
|
|
|
|
|
|
|
|
|
this.effectSprites = game.add.group();
|
|
|
|
this.effectSprites = game.add.group();
|
|
|
|
@@ -112,16 +114,12 @@ GameState.prototype.create = function()
|
|
|
|
light.update_new_values();
|
|
|
|
light.update_new_values();
|
|
|
|
}, this)
|
|
|
|
}, this)
|
|
|
|
|
|
|
|
|
|
|
|
this.aiSpriteEffects = game.add.group();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.staticSounds = game.add.group();
|
|
|
|
|
|
|
|
this.map.createFromObjects('Sounds', 11, 'player', 0, true, false, this.staticSounds, SoundSprite);
|
|
|
|
this.map.createFromObjects('Sounds', 11, 'player', 0, true, false, this.staticSounds, SoundSprite);
|
|
|
|
this.staticSounds.forEach(function(snd) {
|
|
|
|
this.staticSounds.forEach(function(snd) {
|
|
|
|
snd.update_new_values();
|
|
|
|
snd.update_new_values();
|
|
|
|
}, this)
|
|
|
|
}, this)
|
|
|
|
|
|
|
|
|
|
|
|
this.bubble_group = game.add.group();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.uigroup = game.add.group();
|
|
|
|
this.uigroup = game.add.group();
|
|
|
|
this.recentlyStolenGroup = game.add.group();
|
|
|
|
this.recentlyStolenGroup = game.add.group();
|
|
|
|
this.game.time.advancedTiming = true;
|
|
|
|
this.game.time.advancedTiming = true;
|
|
|
|
@@ -162,10 +160,12 @@ GameState.prototype.create = function()
|
|
|
|
// 20, SCREEN_HEIGHT - 40, '', { font : '16px Arial', fill: '#ffffff' }, this.uigroup
|
|
|
|
// 20, SCREEN_HEIGHT - 40, '', { font : '16px Arial', fill: '#ffffff' }, this.uigroup
|
|
|
|
// );
|
|
|
|
// );
|
|
|
|
|
|
|
|
|
|
|
|
this.scoreText = this.game.add.text(
|
|
|
|
this.scoreTextBitmap = bitmapText('', FONTSIZE_MEDIUM);
|
|
|
|
SCREEN_WIDTH - 80, SCREEN_HEIGHT - 30, '',
|
|
|
|
this.scoreText = this.game.add.image(484,
|
|
|
|
{ font: '16px Arial', fill: '#ffffff' }, this.uigroup
|
|
|
|
480 - 68 + 31,
|
|
|
|
);
|
|
|
|
this.scoreTextBitmap,
|
|
|
|
|
|
|
|
0,
|
|
|
|
|
|
|
|
this.uigroup);
|
|
|
|
|
|
|
|
|
|
|
|
this.lightbar = this.game.add.sprite(256,
|
|
|
|
this.lightbar = this.game.add.sprite(256,
|
|
|
|
hudoffset + 7 + 6,
|
|
|
|
hudoffset + 7 + 6,
|
|
|
|
@@ -245,25 +245,25 @@ GameState.prototype.check_input = function()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( controls.up.isDown) {
|
|
|
|
if ( controls.up.isDown) {
|
|
|
|
if ( controls.up.shiftKey ) {
|
|
|
|
if ( controls.run.isDown ) {
|
|
|
|
newstate = (STATE_FACE_UP | STATE_MOVING | STATE_RUNNING);
|
|
|
|
newstate = (STATE_FACE_UP | STATE_MOVING | STATE_RUNNING);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
newstate = (STATE_FACE_UP | STATE_MOVING );
|
|
|
|
newstate = (STATE_FACE_UP | STATE_MOVING );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ( controls.down.isDown ) {
|
|
|
|
} else if ( controls.down.isDown ) {
|
|
|
|
if ( controls.down.shiftKey ) {
|
|
|
|
if ( controls.run.isDown ) {
|
|
|
|
newstate = (STATE_FACE_DOWN | STATE_MOVING | STATE_RUNNING);
|
|
|
|
newstate = (STATE_FACE_DOWN | STATE_MOVING | STATE_RUNNING);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
newstate = (STATE_FACE_DOWN | STATE_MOVING );
|
|
|
|
newstate = (STATE_FACE_DOWN | STATE_MOVING );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ( controls.left.isDown ) {
|
|
|
|
} else if ( controls.left.isDown ) {
|
|
|
|
if ( controls.left.shiftKey ) {
|
|
|
|
if ( controls.run.isDown ) {
|
|
|
|
newstate = (STATE_FACE_LEFT | STATE_MOVING | STATE_RUNNING);
|
|
|
|
newstate = (STATE_FACE_LEFT | STATE_MOVING | STATE_RUNNING);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
newstate = (STATE_FACE_LEFT | STATE_MOVING );
|
|
|
|
newstate = (STATE_FACE_LEFT | STATE_MOVING );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if ( controls.right.isDown ) {
|
|
|
|
} else if ( controls.right.isDown ) {
|
|
|
|
if ( controls.right.shiftKey ) {
|
|
|
|
if ( controls.run.isDown ) {
|
|
|
|
newstate = (STATE_FACE_RIGHT | STATE_MOVING | STATE_RUNNING);
|
|
|
|
newstate = (STATE_FACE_RIGHT | STATE_MOVING | STATE_RUNNING);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
newstate = (STATE_FACE_RIGHT | STATE_MOVING );
|
|
|
|
newstate = (STATE_FACE_RIGHT | STATE_MOVING );
|
|
|
|
@@ -300,7 +300,7 @@ GameState.prototype.update_player_lightmeter = function() {
|
|
|
|
}, this)
|
|
|
|
}, this)
|
|
|
|
player.lightmeter += lightValue;
|
|
|
|
player.lightmeter += lightValue;
|
|
|
|
player.lightmeter = Math.min(player.lightmeter, 1.0);
|
|
|
|
player.lightmeter = Math.min(player.lightmeter, 1.0);
|
|
|
|
this.lightbar.scale.y = player.lightmeter;
|
|
|
|
this.lightbar.scale.x = player.lightmeter;
|
|
|
|
this.lightbar.alpha = 0.5 + (player.lightmeter / 2);
|
|
|
|
this.lightbar.alpha = 0.5 + (player.lightmeter / 2);
|
|
|
|
//this.lightbar_crop.width = ((this.lightbar_image.width) * player.lightmeter);
|
|
|
|
//this.lightbar_crop.width = ((this.lightbar_image.width) * player.lightmeter);
|
|
|
|
//this.lightbar.crop(this.lightbar_crop);
|
|
|
|
//this.lightbar.crop(this.lightbar_crop);
|
|
|
|
@@ -431,7 +431,7 @@ GameState.prototype.update = function()
|
|
|
|
_AI_collide);
|
|
|
|
_AI_collide);
|
|
|
|
this.updateShadowTexture();
|
|
|
|
this.updateShadowTexture();
|
|
|
|
|
|
|
|
|
|
|
|
if ( this.aiSprites.debug == false ) {
|
|
|
|
if ( this.aiSprites.debug == true ) {
|
|
|
|
function _draw_viewrect(x) {
|
|
|
|
function _draw_viewrect(x) {
|
|
|
|
var r = x.viewRectangle();
|
|
|
|
var r = x.viewRectangle();
|
|
|
|
if ( isSet(r) == false )
|
|
|
|
if ( isSet(r) == false )
|
|
|
|
@@ -462,8 +462,7 @@ GameState.prototype.update = function()
|
|
|
|
clockhour -= 12;
|
|
|
|
clockhour -= 12;
|
|
|
|
this.hud_hourhand.frame = parseInt((5 * clockhour) + (0.083 * this.clock.getMinutes()));
|
|
|
|
this.hud_hourhand.frame = parseInt((5 * clockhour) + (0.083 * this.clock.getMinutes()));
|
|
|
|
this.hud_minutehand.frame = this.clock.getMinutes();
|
|
|
|
this.hud_minutehand.frame = this.clock.getMinutes();
|
|
|
|
// this.clockText.setText("" + this.clock.getHours() + ":" + this.clock.getMinutes() + ":" + this.clock.getSeconds());
|
|
|
|
this.scoreTextBitmap.setText("$ " + player.score);
|
|
|
|
this.scoreText.setText("" + player.score);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
GameState.prototype.shutdown = function()
|
|
|
|
GameState.prototype.shutdown = function()
|
|
|
|
@@ -483,6 +482,8 @@ GameState.prototype.shutdown = function()
|
|
|
|
}, this);
|
|
|
|
}, this);
|
|
|
|
this.aiSprites.destroy();
|
|
|
|
this.aiSprites.destroy();
|
|
|
|
this.aiSprites = null;
|
|
|
|
this.aiSprites = null;
|
|
|
|
|
|
|
|
this.aiSpriteEffects.destroy();
|
|
|
|
|
|
|
|
this.aiSpriteEffects = null;
|
|
|
|
this.uigroup.destroy();
|
|
|
|
this.uigroup.destroy();
|
|
|
|
this.uigroup = null;
|
|
|
|
this.uigroup = null;
|
|
|
|
this.recentlyStolenGroup.destroy();
|
|
|
|
this.recentlyStolenGroup.destroy();
|
|
|
|
@@ -540,7 +541,7 @@ Preloader.prototype.preload = function()
|
|
|
|
this.loadingText.anchor.setTo(0.5, 0.5);
|
|
|
|
this.loadingText.anchor.setTo(0.5, 0.5);
|
|
|
|
this.creditText = textImage(game.world.centerX,
|
|
|
|
this.creditText = textImage(game.world.centerX,
|
|
|
|
480 - 16,
|
|
|
|
480 - 16,
|
|
|
|
"Featuring Art by Peter Hann (www.peter-hann.com)",
|
|
|
|
"Featuring Art by Peter Hann (www.phann.de)",
|
|
|
|
FONTSIZE_SMALL);
|
|
|
|
FONTSIZE_SMALL);
|
|
|
|
this.creditText.anchor.setTo(0.5, 0.5);
|
|
|
|
this.creditText.anchor.setTo(0.5, 0.5);
|
|
|
|
this.preloadTube = game.add.image(game.world.centerX, 280, 'loadingtube');
|
|
|
|
this.preloadTube = game.add.image(game.world.centerX, 280, 'loadingtube');
|
|
|
|
|