source: advance-wars/src/com/medievaltech/advancewars/Map.java@ abe7b3d

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

Changed the package names from com.example.* to com.medievaltech.*

  • Property mode set to 100644
File size: 874 bytes
RevLine 
[abe7b3d]1package com.medievaltech.advancewars;
[2e798d9]2
3import android.graphics.Canvas;
[15ddb57]4import android.graphics.Point;
[2e798d9]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] = 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 void setTile(int x, int y, Tile t) {
30 grid[x][y] = t;
31 }
32
33 public void draw(Canvas c, int xStart, int yStart) {
34 for(int x=0; x<getWidth(); x++)
35 for(int y=0; y<getHeight(); y++)
36 grid[x][y].draw(c, xStart+50*x, yStart+50*y);
37 }
[15ddb57]38
39 public Tile getTile(Point point)
40 {
41 return grid[point.x][point.y];
42 }
[2e798d9]43}
Note: See TracBrowser for help on using the repository browser.