-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsprite.js
27 lines (27 loc) · 831 Bytes
/
sprite.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var sprite = function(options, boolean) {
this.image = new Image();
this.image.src = options.src;
this.raw = 0;
this.width = options.width;
this.height = options.height;
this.frameIndex = 0;
this.tickCount = 0;
this.ticksPerFrame = options.ticksPerFrame || 0;
this.numberOfFrames = options.numberOfFrames || 1;
this.render = function() {
if (this.raw > 354) {
this.raw = 0;
}
this.raw += 118;
}
canvas.getContext("2d").drawImage(
this.image,
this.frameIndex * this.width / this.numberOfFrames,
this.raw, //a changer en fonction de la direction du player
this.width / this.numberOfFrames,
this.height,
this.pos.x,
this.pos.y,
this.width / this.numberOfFrames,
this.height);
}