Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 22 additions & 22 deletions dist/skifree.js

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions js/lib/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ class Game {
}

reset() {
paused = false;
staticObjects = new SpriteArray();
movingObjects = new SpriteArray();
mouseX = dContext.getCentreOfViewport();
mouseY = 0;
player.reset();
player.setMapPosition(0, 0, 0);
this.paused = false;
this.staticObjects = new SpriteArray();
this.movingObjects = new SpriteArray();
this.mouseX = this.dContext.getCentreOfViewport();
this.mouseY = 0;
this.player.reset();
this.player.setMapPosition(0, 0, 0);
this.start();
}
}
Expand Down
17 changes: 9 additions & 8 deletions js/lib/monster.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ class Monster extends Sprite {
}

draw(dContext) {
var spritePartToUse = function () {
const spritePartToUse = () => {
var xDiff = this.movingToward[0] - this.canvasX;

if (this.isEating) {
return 'eating' + eatingStage;
console.log('eating' + this.eatingStage);
return 'eating' + this.eatingStage;
}

if (this.spriteVersion + 0.1 > 2) {
Expand All @@ -35,16 +36,16 @@ class Monster extends Sprite {
return super.draw(dContext, spritePartToUse());
};

startEating (whenDone) {
startEating(whenDone) {
this.eatingStage += 1;
this.isEating = true;
this.isMoving = false;
if (eatingStage < 6) {
setTimeout(function () {
startEating(whenDone);
}, 300);
if (this.eatingStage < 6) {
setTimeout( () => {
this.startEating(whenDone);
}, 300);
} else {
eatingStage = 0;
this.eatingStage = 0;
this.isEating = false;
this.isMoving = true;
whenDone();
Expand Down
15 changes: 6 additions & 9 deletions js/lib/skier.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (typeof navigator !== 'undefined') {

class Skier extends Sprite {
constructor(data) {
super(data)
super(data);
this.discreteDirections = {
'west': 270,
'wsWest': 240,
Expand Down Expand Up @@ -77,7 +77,7 @@ class Skier extends Sprite {
this.isJumping = false;
this.isPerformingTrick = false;
if (this.cancelableStateInterval) {
this.clearInterval(this.cancelableStateInterval);
clearInterval(this.cancelableStateInterval);
}
this.setMapPosition(undefined, undefined, 0);
}
Expand Down Expand Up @@ -167,7 +167,6 @@ class Skier extends Sprite {
}

getTrickSprite() {
console.log('Trick step is', this.trickStep);
if (this.trickStep === 0) {
return 'jumping';
} else if (this.trickStep === 1) {
Expand Down Expand Up @@ -292,21 +291,19 @@ class Skier extends Sprite {
}

super.cycle();

this.checkHittableObjects();
}

draw(dContext) {
const spritePartToUse = () => {
if (this.isBeingEaten) {
return getBeingEatenSprite();
return this.getBeingEatenSprite();
}

if (this.isJumping) {
if (this.isPerformingTrick) {
return getTrickSprite();
return this.getTrickSprite();
}
return getJumpingSprite();
return this.getJumpingSprite();
}

if (this.hasBeenHit) {
Expand Down Expand Up @@ -336,8 +333,8 @@ class Skier extends Sprite {
}

speedBoost() {
var originalSpeed = this.speed;
if (this.canSpeedBoost) {
var originalSpeed = this.getSpeed();
this.canSpeedBoost = false;
this.setSpeed(this.speed * this.boostMultiplier);
setTimeout(() => {
Expand Down
2 changes: 1 addition & 1 deletion js/lib/sprite.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class Sprite {
delete this.hittableObjects[k];
} else {
if (objectData.object.hits(this)) {
objectData.callbacks.each(function (callback) {
objectData.callbacks.each( (callback) => {
callback(this, objectData.object);
});
}
Expand Down
9 changes: 4 additions & 5 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,8 @@ function startNeverEndingGame (images) {
distanceTravelledInMetres = 0;
livesLeft = 5;
highScore = localStorage.getItem('highScore');
game.reset();
game.addStaticObject(startSign);
game.reset();
}

function detectEnd () {
Expand All @@ -105,7 +105,6 @@ function startNeverEndingGame (images) {
var randomPosition = dContext.getRandomMapPositionAboveViewport();
newMonster.setMapPosition(randomPosition[0], randomPosition[1]);
newMonster.follow(player);
newMonster.setSpeed(player.getStandardSpeed());
newMonster.onHitting(player, monsterHitsSkierBehaviour);

game.addMovingObject(newMonster, 'monster');
Expand Down Expand Up @@ -217,8 +216,8 @@ function startNeverEndingGame (images) {
})
.focus(); // So we can listen to events immediately

Mousetrap.bind('f', player.speedBoost);
Mousetrap.bind('t', player.attemptTrick);
Mousetrap.bind('f', function () { player.speedBoost() });
Mousetrap.bind('t', function () { player.attemptTrick() });
Mousetrap.bind(['w', 'up'], function () {
player.stop();
});
Expand All @@ -242,7 +241,7 @@ function startNeverEndingGame (images) {
});
Mousetrap.bind('m', spawnMonster);
Mousetrap.bind('b', spawnBoarder);
Mousetrap.bind('space', resetGame);
Mousetrap.bind('space', function () { resetGame() });

var hammertime = new Hammer(mainCanvas)

Expand Down
Loading