Skip to content

Commit 15548dc

Browse files
committed
Coisas que faltaram, desculpa pelo commit preguiçoso
1 parent 50e892d commit 15548dc

File tree

7 files changed

+25
-27
lines changed

7 files changed

+25
-27
lines changed

control/GameScreen.js

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ class GameScreen {
44
this.ctx = this.canvas.getContext("2d");
55
this.width = this.canvas.width;
66
this.height = this.canvas.height;
7+
this.background = new Image(Consts.CELL_SIZE, Consts.CELL_SIZE);
8+
this.background.src = `${Consts.IMG_PATH}/bricks.png`;
79

810
this.gameController = new GameController();
911
this.elements = [];
@@ -34,20 +36,29 @@ class GameScreen {
3436
return this.canvas.getContext("2d");
3537
}
3638

37-
draw() {
39+
paint() {
3840
Drawing.clear();
41+
for (let x = 0; x < Consts.NUM_CELLS; x++) {
42+
for (let y = 0; y < Consts.NUM_CELLS; y++) {
43+
Drawing.draw(
44+
x * Consts.CELL_SIZE,
45+
y * Consts.CELL_SIZE,
46+
this.background
47+
);
48+
}
49+
}
3950
this.gameController.processAllElements(this.elements);
4051
this.gameController.drawAllElement(this.elements);
4152
}
4253

4354
loop = () => {
44-
this.draw();
55+
this.paint();
4556
document.title = this.lolo.getStringPosition();
4657
};
4758

4859
go() {
4960
this.keyPressed();
50-
61+
5162
this.addElement(this.lolo);
5263
this.addElement(new Skull(0, 250));
5364

control/Main.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
class Main {
2-
3-
static main(){
4-
new GameScreen({ canvasId: "canvas" });
5-
}
6-
}
2+
static main() {
3+
new GameScreen({ canvasId: "canvas" });
4+
}
5+
}

elements/Fire.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Fire extends Element {
66
}
77

88
autoDraw() {
9-
Drawing.drawImg(this.pos.getX(), this.pos.getY(), this.imageIcon);
9+
Drawing.draw(this.pos.getX(), this.pos.getY(), this.imageIcon);
1010

1111
this.countDelay++;
1212
if (this.countDelay === this.DELAY_MOVIMENT) {

elements/Lolo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Lolo extends Element {
55
}
66

77
autoDraw() {
8-
Drawing.drawImg(this.pos.getX(), this.pos.getY(), this.imageIcon);
8+
Drawing.draw(this.pos.getX(), this.pos.getY(), this.imageIcon);
99
}
1010

1111
backToLastPosition() {

elements/Skull.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ class Skull extends Element {
88
imageIcon: "skull.png"
99
});
1010
this.countIntervals = 0;
11-
this.TIME_FIRE = 300;
11+
this.TIME_FIRE = 150;
1212
}
1313

1414
autoDraw() {
15-
Drawing.drawImg(this.pos.getX(), this.pos.getY(), this.imageIcon);
15+
Drawing.draw(this.pos.getX(), this.pos.getY(), this.imageIcon);
1616

1717
this.countIntervals++;
1818

@@ -21,6 +21,7 @@ class Skull extends Element {
2121
this.pos.getX() + Consts.CELL_SIZE,
2222
this.pos.getY()
2323
);
24+
2425
Drawing.getGameScreen().addElement(fire);
2526
this.countIntervals = 0;
2627
}

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
color: white;
2121
}
2222
canvas {
23-
background-image: url("assets/unesp.jpg");
23+
/* background-image: url("assets/unesp.jpg"); */
2424
background-size: cover;
2525
border: 1px solid black;
2626
}

utils/Drawing.js

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,7 @@ class Drawing {
1111
this.gameScreen = gameScreen;
1212
}
1313

14-
static drawRect(x, y, color) {
15-
const { ctx } = this.gameScreen;
16-
ctx.beginPath();
17-
ctx.rect(x, y, Consts.CELL_SIZE, Consts.CELL_SIZE);
18-
ctx.fillStyle = color;
19-
ctx.shadowColor = "black";
20-
ctx.shadowBlur = 4;
21-
ctx.shadowOffsetX = 2;
22-
ctx.shadowOffsetY = 2;
23-
ctx.fill();
24-
ctx.closePath();
25-
}
26-
27-
static drawImg(x, y, img) {
14+
static draw(x, y, img) {
2815
const { ctx } = this.gameScreen;
2916
ctx.drawImage(img, x, y, img.width, img.height);
3017
}

0 commit comments

Comments
 (0)