-
Notifications
You must be signed in to change notification settings - Fork 0
/
RoadMarking.java
34 lines (27 loc) · 923 Bytes
/
RoadMarking.java
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
33
34
package com.codegym.games.racer;
import com.codegym.engine.cell.Game;
import java.util.ArrayList;
import java.util.List;
public class RoadMarking {
private List<GameObject> roadMarking = new ArrayList<>();
public RoadMarking() {
for (int i = -4; i <= RacerGame.HEIGHT + 4; i += 8) {
roadMarking.add(new GameObject(RacerGame.CENTER_X - 9, i, ShapeMatrix.ROAD_MARKING));
roadMarking.add(new GameObject(RacerGame.CENTER_X + 9, i, ShapeMatrix.ROAD_MARKING));
}
}
public void move(int boost) {
for (GameObject item : roadMarking) {
if (item.y >= RacerGame.HEIGHT - 1) {
item.y = item.y - RacerGame.HEIGHT - 8 + boost;
} else {
item.y += boost;
}
}
}
public void draw(Game game) {
for (GameObject item : roadMarking) {
item.draw(game);
}
}
}