Skip to content

Commit

Permalink
Player body adjusts to skate
Browse files Browse the repository at this point in the history
  • Loading branch information
acemir committed Apr 18, 2016
1 parent 29ff692 commit bd522ee
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
3 changes: 3 additions & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@ Skate with a skull while mastering stunts.
Game built in 64x64 resolution to participate in the LowrezJam 2016.
Have fun.

## Release v0.2 - April 18, 2016
* Spikes to jump over

## Release v0.1 - April 18, 2016
* Game Intro
29 changes: 26 additions & 3 deletions states/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Sk8Skull.Game.prototype = {
this.game.physics.arcade.enable(this.player);
this.player.body.gravity.y = 300;
this.player.body.collideWorldBounds = true;
this.player.body.width = 17;
this.player.body.height = 6;
this.player.body.offset.x = 4;
this.player.body.offset.y = 19;

this.animRUN = this.player.animations.add('run', [0, 1, 2, 3], 10, true);
this.animOLLIE = this.player.animations.add('ollie', [4, 5, 6], 10, false);
Expand All @@ -60,15 +64,25 @@ Sk8Skull.Game.prototype = {
},this);

this.animOLLIE.onComplete.add(function(){
this.player.frame = 0;
this.player.jumping = false;
if (this.player.body.velocity.x) this.player.animations.play('run');
else this.player.frame = 0;
},this);

//Apply controls
var key_UP = this.game.input.keyboard.addKey(Phaser.Keyboard.UP).onDown.add(this.kickflip, this);
var key_W = this.game.input.keyboard.addKey(Phaser.Keyboard.W).onDown.add(this.kickflip, this);
var key_SPACE = this.game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR).onDown.add(this.kickflip, this);
document.body.addEventListener('touchstart', function(e){player.animations.play('kickflip')});
document.body.addEventListener('mousedown', function(e){player.animations.play('kickflip')});
document.body.addEventListener('touchstart', function(e){
player.jumping = true;
player.body.velocity.x = 60;
player.animations.play('kickflip')
});
document.body.addEventListener('mousedown', function(e){
player.jumping = true;
player.body.velocity.x = 60;
player.animations.play('kickflip')
});

this.kickflip(false);

Expand All @@ -82,6 +96,7 @@ Sk8Skull.Game.prototype = {
},

render: function() {
// this.game.debug.body(this.player);
Sk8Skull.scaleDraw.call(this);
},

Expand All @@ -91,6 +106,13 @@ Sk8Skull.Game.prototype = {
else this.player.body.velocity.x = 0;
this.player.animations.play('kickflip');
},

ollie: function(isUser) {
this.player.jumping = true;
if (isUser) this.player.body.velocity.x = 60;
else this.player.body.velocity.x = 0;
this.player.animations.play('ollie');
},

generateMounds: function() {
this.mounds = this.game.add.group();
Expand All @@ -117,6 +139,7 @@ Sk8Skull.Game.prototype = {
player.body.velocity.x = 60
} else {
player.body.velocity.x = 0
player.frame = 0
}
}
}

0 comments on commit bd522ee

Please sign in to comment.