Added texture for platforms
This commit is contained in:
parent
3466fc57ec
commit
735c1f75cb
|
@ -3,8 +3,6 @@ const MAX_JUMP = 2;
|
|||
const G = 500;
|
||||
|
||||
const MAX_FRAME = 9;
|
||||
let img = new Image();
|
||||
img.src = "img/griezmann.png"
|
||||
|
||||
class Box {
|
||||
constructor() {
|
||||
|
@ -74,4 +72,6 @@ class Box {
|
|||
}
|
||||
}
|
||||
|
||||
Box.texture = img;
|
||||
Box.texture = new Image();
|
||||
Box.texture.src = "img/griezmann.png"
|
||||
|
||||
|
|
|
@ -11,3 +11,6 @@ class Platform {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
Platform.texture = new Image();
|
||||
Platform.texture.src = "img/grass.png";
|
||||
|
|
12
src/scene.js
12
src/scene.js
|
@ -130,7 +130,6 @@ class Scene extends Screen {
|
|||
drawObject(object) {
|
||||
let size = object.size * this.width();
|
||||
|
||||
this.context.fillStyle = 'rgb(0, 0, 0)';
|
||||
this.context.drawImage(
|
||||
Box.texture,
|
||||
0, 64 * this.player.frameNumber, 64, 64,
|
||||
|
@ -144,16 +143,13 @@ class Scene extends Screen {
|
|||
let width = object.width * this.width();
|
||||
let height = object.height * this.height();
|
||||
|
||||
this.context.fillStyle = object.color || 'rgb(0, 0, 0)';
|
||||
this.context.beginPath();
|
||||
|
||||
this.context.rect(
|
||||
this.context.drawImage(
|
||||
Platform.texture,
|
||||
0, 0, 64, 64,
|
||||
(object.x - object.width / 2) * this.width(),
|
||||
(1 - object.y - object.height / 2 + this.cameraHeight) * this.height(),
|
||||
width,
|
||||
height,
|
||||
width, width,
|
||||
);
|
||||
this.context.fill();
|
||||
}
|
||||
|
||||
drawHud() {
|
||||
|
|
Loading…
Reference in New Issue