Skip to content

Commit

Permalink
life powerup
Browse files Browse the repository at this point in the history
  • Loading branch information
yonbergman committed Apr 4, 2012
1 parent 10039e9 commit 7115062
Show file tree
Hide file tree
Showing 11 changed files with 33 additions and 6 deletions.
Binary file modified hobo.psd
Binary file not shown.
18 changes: 13 additions & 5 deletions public/javascripts/structure/cell.js
Expand Up @@ -5,8 +5,15 @@ function Cell(isWall) {
if (roll <= Cell.BONUS_CHANCE) {
this.content = new Content(Content.COIN, Content.COINS.BONUS);
}
else if (roll <= Cell.LIFE_CHANCE) {
this.content = new Content(Content.LIVE, Content.LIVES.LIFE);
}
else if (roll <= Cell.POWERUP_CHANCE) {
this.content = new Content(Content.POWERUP, Math.roll(0.5) ? Content.POWERUPS.GODMODE: Content.POWERUPS.SPEED);
if (Math.roll(0.5)) {
this.content = new Content(Content.POWERUP, Content.POWERUPS.SPEED);
} else {
this.content = new Content(Content.POWERUP, Content.POWERUPS.GODMODE);
}
}
else if (roll <= Cell.TOP_COIN_CHANCE) {
this.content = new Content(Content.COIN, Content.COINS.TOP);
Expand All @@ -26,10 +33,11 @@ function Cell(isWall) {
}
};

Cell.LOW_COIN_CHANCE = 0.6;
Cell.MID_COIN_CHANCE = 0.3;
Cell.TOP_COIN_CHANCE = 0.1;
Cell.POWERUP_CHANCE = 0.01;
Cell.LOW_COIN_CHANCE = 0.6000;
Cell.MID_COIN_CHANCE = 0.3000;
Cell.TOP_COIN_CHANCE = 0.1000;
Cell.POWERUP_CHANCE = 0.0100;
Cell.LIFE_CHANCE = 0.0030;
Cell.BONUS_CHANCE = 0.0025;

Cell.prototype.setAsPath = function() {
Expand Down
14 changes: 13 additions & 1 deletion public/javascripts/structure/content.js
Expand Up @@ -14,11 +14,18 @@ Content.COINS = {
Content.POWERUPS = {
SPEED: 0,
GODMODE: 1
}
};

Content.LIVES = {
LIFE: 0
};



// types.
Content.COIN = "coin";
Content.POWERUP = "powerup";
Content.LIVE = "life";

Content.prototype.getValue = function() {
switch (this.value) {
Expand All @@ -28,6 +35,7 @@ Content.prototype.getValue = function() {
case Content.COINS.LOW: return 1;
case Content.POWERUPS.GODMODE: return 5;
case Content.POWERUPS.SPEED: return 5;
case Content.LIVES.LIFE: return 20;
}
return 0;
};
Expand All @@ -42,4 +50,8 @@ Content.prototype.isBonus = function() {

Content.prototype.isPowerup = function() {
return this.type == Content.POWERUP;
};

Content.prototype.isLife = function() {
return this.type == Content.LIVE;
};
7 changes: 7 additions & 0 deletions public/javascripts/tile_renderer.js
Expand Up @@ -68,6 +68,8 @@ TileRenderer.prototype.render = function(render_row, render_col){
}
else if (cell.content.isPowerup()) {
this.renderPowerup(cell.content.value)
} else if (cell.content.isLife()){
this.renderLife(cell.content.value)
}
}
};
Expand All @@ -84,6 +86,11 @@ TileRenderer.prototype.renderPowerup = function(content_type) {
var animation = (tmp % 2) ? 0 : Math.floor(tmp/2)+1;
this.blit(this.renderer.coins, 16 * animation, 16 * content_type + 64)
}
TileRenderer.prototype.renderLife = function(content_type) {
var tmp = Math.floor((this.renderer.accumulator*5) % 4);
var animation = [0,1,2,1][tmp];
this.blit(this.renderer.coins, 16 * animation, 16 * content_type + 96)
};

TileRenderer.prototype.renderWall = function(){
var idx = 0;
Expand Down
Binary file modified public/resources/images/coins.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/resources/images/dog.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/resources/images/hobo.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/resources/images/road-side.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/resources/images/roads.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/resources/images/roof.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/resources/images/wall.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7115062

Please sign in to comment.