Skip to content

Commit

Permalink
Added rocks and removed thick snow behaviour
Browse files Browse the repository at this point in the history
  • Loading branch information
basicallydan committed Feb 18, 2013
1 parent 7c6283b commit 9a88faf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
5 changes: 3 additions & 2 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,11 @@ function startGame (images) {
snowboarder.draw(dContext);
});

randomlyGenerateObject(sprites.smallTree, 3);
randomlyGenerateObject(sprites.tallTree, 1);
randomlyGenerateObject(sprites.smallTree, 4);
randomlyGenerateObject(sprites.tallTree, 2);
randomlyGenerateObject(sprites.jump, 1);
randomlyGenerateObject(sprites.thickSnow, 1);
randomlyGenerateObject(sprites.rock, 1);

distanceTravelledInMetres = parseFloat(skier.getPixelsTravelledDownMountain() / pixelsPerMetre).toFixed(1);

Expand Down
20 changes: 17 additions & 3 deletions js/spriteInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@
},
hitBehaviour: {}
},
'rock' : {
$imageFile : 'skifree-objects.png',
parts : {
main : [ 30, 52, 23, 11 ]
},
hitBehaviour: {}
},
'monster' : {
$imageFile : 'sprite-characters.png',
parts : {
Expand Down Expand Up @@ -109,6 +116,12 @@
sprites.smallTree.hitBehaviour.skier = treeHitsSkierBehaviour;
sprites.tallTree.hitBehaviour.skier = treeHitsSkierBehaviour;

function rockHitsSkierBehaviour(rock, skier) {
skier.hasHitObstacle(rock);
}

sprites.rock.hitBehaviour.skier = rockHitsSkierBehaviour;

function skierHitsJumpBehaviour(skier, jump) {
skier.hasHitJump(jump);
}
Expand All @@ -119,7 +132,8 @@

sprites.jump.hitBehaviour.skier = jumpHitsSkierBehaviour;

function skierHitsThickSnowBehaviour(skier, thickSnow) {
// Really not a fan of this behaviour.
/* function skierHitsThickSnowBehaviour(skier, thickSnow) {
// Need to implement this properly
skier.setSpeed(2);
setTimeout(function() {
Expand All @@ -133,9 +147,9 @@
setTimeout(function() {
skier.resetSpeed();
}, 300);
}
}*/

sprites.thickSnow.hitBehaviour.skier = thickSnowHitsSkierBehaviour;
// sprites.thickSnow.hitBehaviour.skier = thickSnowHitsSkierBehaviour;

function snowboarderHitsSkierBehaviour(snowboarder, skier) {
skier.hasHitObstacle(snowboarder);
Expand Down

0 comments on commit 9a88faf

Please sign in to comment.