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 G = 500;
|
||||||
|
|
||||||
const MAX_FRAME = 9;
|
const MAX_FRAME = 9;
|
||||||
let img = new Image();
|
|
||||||
img.src = "img/griezmann.png"
|
|
||||||
|
|
||||||
class Box {
|
class Box {
|
||||||
constructor() {
|
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) {
|
drawObject(object) {
|
||||||
let size = object.size * this.width();
|
let size = object.size * this.width();
|
||||||
|
|
||||||
this.context.fillStyle = 'rgb(0, 0, 0)';
|
|
||||||
this.context.drawImage(
|
this.context.drawImage(
|
||||||
Box.texture,
|
Box.texture,
|
||||||
0, 64 * this.player.frameNumber, 64, 64,
|
0, 64 * this.player.frameNumber, 64, 64,
|
||||||
|
@ -144,16 +143,13 @@ class Scene extends Screen {
|
||||||
let width = object.width * this.width();
|
let width = object.width * this.width();
|
||||||
let height = object.height * this.height();
|
let height = object.height * this.height();
|
||||||
|
|
||||||
this.context.fillStyle = object.color || 'rgb(0, 0, 0)';
|
this.context.drawImage(
|
||||||
this.context.beginPath();
|
Platform.texture,
|
||||||
|
0, 0, 64, 64,
|
||||||
this.context.rect(
|
|
||||||
(object.x - object.width / 2) * this.width(),
|
(object.x - object.width / 2) * this.width(),
|
||||||
(1 - object.y - object.height / 2 + this.cameraHeight) * this.height(),
|
(1 - object.y - object.height / 2 + this.cameraHeight) * this.height(),
|
||||||
width,
|
width, width,
|
||||||
height,
|
|
||||||
);
|
);
|
||||||
this.context.fill();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
drawHud() {
|
drawHud() {
|
||||||
|
|
Loading…
Reference in New Issue