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

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

Added a basic draw function to Unit and made some other minor code changes.

  • Property mode set to 100644
File size: 942 bytes
Line 
1package com.medievaltech.game;
2
3import android.graphics.Canvas;
4import android.graphics.Point;
5
6public 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);
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.