source: advance-wars/src/com/medievaltech/game/Map.java@ b97a618

Last change on this file since b97a618 was b97a618, checked in by dportnoy <devnull@…>, 14 years ago

Touching a unit now displays its movement area. Touching a square without a unit will stop displaying any previously displayed movement area. THe movement area is now drawn under the unit itself.

  • Property mode set to 100644
File size: 1.2 KB
Line 
1package com.medievaltech.game;
2
3import android.graphics.Canvas;
4import android.graphics.Point;
5
6public class Map {
7 private Tile[][] grid;
8 public Point offset;
9
10 public Map(int width, int height, Point offset) {
11 grid = new Tile[width][height];
12 this.offset = offset;
13 }
14
15 public Map(Tile t, int width, int height, Point offset) {
16 grid = new Tile[width][height];
17 this.offset = offset;
18
19 for(int x=0; x<getWidth(); x++)
20 for(int y=0; y<getHeight(); y++)
21 grid[x][y] = new Tile(t, new Point(x, y));
22 }
23
24 public int getWidth() {
25 return grid.length;
26 }
27
28 public int getHeight() {
29 return grid[0].length;
30 }
31
32 public Tile getTile(int x, int y) {
33 return grid[x][y];
34 }
35
36 public Tile getTile(Point point) {
37 return grid[point.x][point.y];
38 }
39
40 public void setTile(int x, int y, Tile t) {
41 grid[x][y] = t;
42 }
43
44 public void draw(Canvas c) {
45 for(int x=0; x<getWidth(); x++)
46 for(int y=0; y<getHeight(); y++)
47 grid[x][y].draw(c, offset.x+50*x, offset.y+50*y);
48 }
49
50 public void drawUnits(Canvas c) {
51 for(int x=0; x<getWidth(); x++)
52 for(int y=0; y<getHeight(); y++)
53 grid[x][y].drawUnit(c, offset.x+50*x, offset.y+50*y);
54 }
55}
Note: See TracBrowser for help on using the repository browser.