Last change
on this file since 5d77d43 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
|
Rev | Line | |
---|
[1a1e8c7] | 1 | package com.medievaltech.game;
|
---|
[2e798d9] | 2 |
|
---|
| 3 | import android.graphics.Canvas;
|
---|
[15ddb57] | 4 | import android.graphics.Point;
|
---|
[2e798d9] | 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++)
|
---|
[1a1e8c7] | 18 | grid[x][y] = new Tile(t);
|
---|
[2e798d9] | 19 | }
|
---|
| 20 |
|
---|
| 21 | public int getWidth() {
|
---|
| 22 | return grid.length;
|
---|
| 23 | }
|
---|
| 24 |
|
---|
| 25 | public int getHeight() {
|
---|
| 26 | return grid[0].length;
|
---|
| 27 | }
|
---|
| 28 |
|
---|
[1a1e8c7] | 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 |
|
---|
[2e798d9] | 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.