1 package se
.umu
.cs
.dit06ajnajs
;
7 private int squareSize
;
10 private MapSquare
[][] squareMatrix
;
12 public Map(int squareSize
, MapSquare
[][] squareMatrix
) {
13 this.squareSize
= squareSize
;
17 numCol
= squareMatrix
.length
;
18 numRow
= squareMatrix
[0].length
;
20 catch(NullPointerException e
) {
26 // Set width and height for map
27 this.width
= squareSize
* numCol
;
28 this.height
= squareSize
* numRow
;
29 // Create squareMatrix with right dimension
30 squareMatrix
= new MapSquare
[numCol
][numRow
];
33 // TODO Gör metod för att få ut bakgrundsbild. I denna klass eller någon annanstns
35 public MapSquare
getMapSquareAtPos(Point point
) {
36 //TODO testa algoritmen
40 if (x
> width
|| y
> height
) {
41 throw new IllegalArgumentException("Position is " +
42 "outside of map bounds.");
45 int col
= x
/squareSize
;
46 int row
= y
/squareSize
;
48 return squareMatrix
[col
][row
];