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

Last change on this file since b23048f 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
RevLine 
[1a1e8c7]1package com.medievaltech.game;
[2e798d9]2
3import android.graphics.Canvas;
[15ddb57]4import android.graphics.Point;
[2e798d9]5
6public class Map {
7 private Tile[][] grid;
[b97a618]8 public Point offset;
[2e798d9]9
[b97a618]10 public Map(int width, int height, Point offset) {
[2e798d9]11 grid = new Tile[width][height];
[b97a618]12 this.offset = offset;
[2e798d9]13 }
14
[b97a618]15 public Map(Tile t, int width, int height, Point offset) {
[2e798d9]16 grid = new Tile[width][height];
[b97a618]17 this.offset = offset;
[2e798d9]18
19 for(int x=0; x<getWidth(); x++)
20 for(int y=0; y<getHeight(); y++)
[ebaddd9]21 grid[x][y] = new Tile(t, new Point(x, y));
[2e798d9]22 }
23
24 public int getWidth() {
25 return grid.length;
26 }
27
28 public int getHeight() {
29 return grid[0].length;
30 }
31
[1a1e8c7]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
[2e798d9]40 public void setTile(int x, int y, Tile t) {
41 grid[x][y] = t;
42 }
43
[b97a618]44 public void draw(Canvas c) {
[2e798d9]45 for(int x=0; x<getWidth(); x++)
46 for(int y=0; y<getHeight(); y++)
[b97a618]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);
[2e798d9]54 }
55}
Note: See TracBrowser for help on using the repository browser.