Last change
on this file since ebaddd9 was ebaddd9, checked in by dportnoy <devnull@…>, 14 years ago |
Added code to draw a unit's possible movement options on the map.
|
-
Property mode
set to
100644
|
File size:
959 bytes
|
Line | |
---|
1 | package com.medievaltech.game;
|
---|
2 |
|
---|
3 | import android.graphics.Canvas;
|
---|
4 | import android.graphics.Point;
|
---|
5 |
|
---|
6 | public class Map {
|
---|
7 | private Tile[][] grid;
|
---|
8 |
|
---|
9 | public Map(int width, int height) {
|
---|
10 | grid = new Tile[width][height];
|
---|
11 | }
|
---|
12 |
|
---|
13 | public Map(Tile t, int width, int height) {
|
---|
14 | grid = new Tile[width][height];
|
---|
15 |
|
---|
16 | for(int x=0; x<getWidth(); x++)
|
---|
17 | for(int y=0; y<getHeight(); y++)
|
---|
18 | grid[x][y] = new Tile(t, new Point(x, y));
|
---|
19 | }
|
---|
20 |
|
---|
21 | public int getWidth() {
|
---|
22 | return grid.length;
|
---|
23 | }
|
---|
24 |
|
---|
25 | public int getHeight() {
|
---|
26 | return grid[0].length;
|
---|
27 | }
|
---|
28 |
|
---|
29 | public Tile getTile(int x, int y) {
|
---|
30 | return grid[x][y];
|
---|
31 | }
|
---|
32 |
|
---|
33 | public Tile getTile(Point point) {
|
---|
34 | return grid[point.x][point.y];
|
---|
35 | }
|
---|
36 |
|
---|
37 | public void setTile(int x, int y, Tile t) {
|
---|
38 | grid[x][y] = t;
|
---|
39 | }
|
---|
40 |
|
---|
41 | public void draw(Canvas c, int xStart, int yStart) {
|
---|
42 | for(int x=0; x<getWidth(); x++)
|
---|
43 | for(int y=0; y<getHeight(); y++)
|
---|
44 | grid[x][y].draw(c, xStart+50*x, yStart+50*y);
|
---|
45 | }
|
---|
46 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.