-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangularMap.java
More file actions
30 lines (27 loc) · 959 Bytes
/
RectangularMap.java
File metadata and controls
30 lines (27 loc) · 959 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
package agh.ics.oop.model;
import agh.ics.oop.model.util.MapVisualizer;
import java.util.HashMap;
import java.util.Map;
public class RectangularMap extends AbstractWorldMap {
private final int width;
private final int height;
private final Vector2d MAP_RIGHT_TOP;
private final Vector2d MAP_LEFT_BOTTOM;
private final MapVisualizer mapVisualizer = new MapVisualizer(this);
public RectangularMap(int width, int height) {
this.width = width;
this.height = height;
MAP_RIGHT_TOP = new Vector2d(width - 1, height - 1);
MAP_LEFT_BOTTOM = new Vector2d(0,0);
}
@Override
public boolean canMoveTo(Vector2d position) {
return (!isOccupied(position) && position.precedes(MAP_RIGHT_TOP) && position.follows(MAP_LEFT_BOTTOM));
}
public Vector2d getMAP_RIGHT_TOP() {
return MAP_RIGHT_TOP;
}
public Vector2d getMAP_LEFT_BOTTOM() {
return MAP_LEFT_BOTTOM;
}
}