-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameObject.java
More file actions
32 lines (27 loc) · 782 Bytes
/
GameObject.java
File metadata and controls
32 lines (27 loc) · 782 Bytes
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
28
29
30
31
32
package com.javarush.games.moonlander;
import com.javarush.engine.cell.*;
public class GameObject {
public double x;
public double y;
public int[][] matrix;
public int width;
public int height;
public GameObject(double x, double y, int[][] matrix) {
this.x = x;
this.y = y;
this.matrix = matrix;
this.width = matrix[0].length;
this.height = matrix.length;
}
public void draw(Game game) {
if (matrix == null) {
return;
}
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
int colorIndex = matrix[j][i];
game.setCellColor((int) x + i, (int) y + j, Color.values()[colorIndex]);
}
}
}
}