Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Adhesion/ld24
Browse files Browse the repository at this point in the history
  • Loading branch information
spacemars committed Aug 26, 2012
2 parents 9a3921a + a6889f7 commit 7276ec9
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
1 change: 1 addition & 0 deletions gameResources.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ var gameResources =

{ name: "player", type: "image", src: "data/player.png" },

{ name: "shield", type: "image", src: "data/shield.png" },
{ name: "buttstompimpact", type: "image", src: "data/buttstompimpact.png" },
{ name: "doublejump", type: "image", src: "data/doublejump.png" },
{ name: "explode", type: "image", src: "data/explode.png" },
Expand Down
72 changes: 72 additions & 0 deletions player.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,20 @@ var Player = me.ObjectEntity.extend(
this.haveWallStick = true;
this.spikeHat = true;

//var shieldsettings = new Object();
//shieldsettings.image = "shield";
//shieldsettings.spritewidth = 144;

//this.shield = new me.ObjectEntity( this.pos.x, this.pos.y,
// shieldsettings );
//this.shield.animationspeed = 3;
//var frames = [ 0, 1, 2, 3, 4, 5 ];
//this.shield.addAnimation( "play", frames );
//this.shield.setCurrentAnimation( "play" );

this.addShield( this.pos.x, this.pos.y, "shield", 144,
[ 0, 1, 2, 3, 4, 5 ], 5, 5 );

// mobility stuff
this.doubleJumped = false;
this.rocketJumped = false;
Expand All @@ -54,6 +68,10 @@ var Player = me.ObjectEntity.extend(
this.impactCounter = 0;

this.hp = 1;
if ( this.shield )
{
this.hp++;
}

this.centerOffsetX = 72;
this.centerOffsetY = 72;
Expand Down Expand Up @@ -88,6 +106,17 @@ var Player = me.ObjectEntity.extend(
{
this.flicker( 90, this.die( type ) );
}
else
{
this.shield.flicker( 90,
function()
{
//me.game.player.shield.die();
me.game.remove( this.shield );
me.game.player.shield = null;
me.game.sort();
} );
}
},

die: function( type )
Expand Down Expand Up @@ -230,6 +259,13 @@ var Player = me.ObjectEntity.extend(
this.followPos.x = this.pos.x + this.centerOffsetX;
this.followPos.y = this.pos.y + this.centerOffsetY;

// update shield
if ( this.shield )
{
this.shield.pos.x = this.pos.x;
this.shield.pos.y = this.pos.y;
}

this.parent( this );
return true;
},
Expand Down Expand Up @@ -325,5 +361,41 @@ var Player = me.ObjectEntity.extend(
function() { me.game.remove( particle ) } );
me.game.add( particle, z );
me.game.sort();
console.log( particle.pos.x );
console.log( particle.pos.y );
},

// TODO this code is redundant and terrible. why does the commented one not
// work :(

addShield: function( x, y, sprite, spritewidth, frames, speed, z )
{
var settings = new Object();
settings.image = sprite;
settings.spritewidth = spritewidth;

this.shield = new me.ObjectEntity( x, y, settings );
this.shield.animationspeed = speed;
this.shield.addAnimation( "play", frames );
this.shield.setCurrentAnimation( "play" );
me.game.add( this.shield, z );
me.game.sort();
}

/*addShieldBad: function()
{
console.log( "addshield" );
var settings = new Object();
settings.image = "shield";
settings.spritewidth = 144;
var shield = new me.ObjectEntity( this.pos.x, this.pos.y, settings );
shield.animationspeed = 3;
shield.addAnimation( "play", [ 0, 1, 2, 3, 4, 5 ] );
shield.setCurrentAnimation( "play" );
me.game.add( shield, this.z );
me.game.sort();
console.log( shield.pos.x );
console.log( shield.pos.y );
}*/
});

0 comments on commit 7276ec9

Please sign in to comment.