Skip to content

Commit

Permalink
Animated HippogriffCar in proper position
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcdonnell2 committed Apr 22, 2018
1 parent 24e2234 commit ca127f3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 16 deletions.
2 changes: 1 addition & 1 deletion js/Main/Car.js
Expand Up @@ -82,7 +82,7 @@ function carClass() {
}

this.draw = function() {
drawBitmapCenteredWithRotation(this.myCarPic, this.x,this.y, this.ang);
//drawBitmapCenteredWithRotation(this.myCarPic, this.x,this.y, this.ang);
hippoCarPicTailwagSprite.render(this.x,this.y,this.ang);
hippoCarPicTailwagSprite.update();
}
Expand Down
33 changes: 18 additions & 15 deletions js/Main/Sprite.js
Expand Up @@ -29,20 +29,23 @@ function sprite(options) {
frameIndex = 0;
}

that.render = function(x, y, withAng) {
canvasContext.save();
canvasContext.translate(x /*+ that.width / 4*/, y /*+ that.height / 4*/);
canvasContext.rotate(withAng);
that.context.drawImage(that.image,
frameIndex * that.width / numberOfFrames,
0,
that.width / numberOfFrames,
that.height,
-that.width/4,
-that.height/4,
that.width / numberOfFrames,
that.height);
canvasContext.restore();
}
-that.width
-that.height

that.render = function(x, y, withAng) {
canvasContext.save();
canvasContext.translate(x, y);
canvasContext.rotate(withAng);
that.context.drawImage(that.image,
frameIndex * that.width / numberOfFrames,
0,
that.width / numberOfFrames,
that.height,
-(that.width / numberOfFrames)/1.79,
-that.height/1.79,
(that.width / numberOfFrames),
that.height);
canvasContext.restore();
}
return that;
}

0 comments on commit ca127f3

Please sign in to comment.