Last change
on this file since 90838a1 was 2e798d9, checked in by sdanshinwrt <devnull@…>, 14 years ago |
-A simple 6x8 map now gets drawn to the screen, with green and blue tiles
-Added the bin folder to .hgignore
|
-
Property mode
set to
100644
|
File size:
757 bytes
|
Rev | Line | |
---|
[2e798d9] | 1 | package com.example.advancewars;
|
---|
| 2 |
|
---|
| 3 | import android.graphics.Canvas;
|
---|
| 4 |
|
---|
| 5 | public class Map {
|
---|
| 6 | private Tile[][] grid;
|
---|
| 7 |
|
---|
| 8 | public Map(int width, int height) {
|
---|
| 9 | grid = new Tile[width][height];
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | public Map(Tile t, int width, int height) {
|
---|
| 13 | grid = new Tile[width][height];
|
---|
| 14 |
|
---|
| 15 | for(int x=0; x<getWidth(); x++)
|
---|
| 16 | for(int y=0; y<getHeight(); y++)
|
---|
| 17 | grid[x][y] = t;
|
---|
| 18 | }
|
---|
| 19 |
|
---|
| 20 | public int getWidth() {
|
---|
| 21 | return grid.length;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | public int getHeight() {
|
---|
| 25 | return grid[0].length;
|
---|
| 26 | }
|
---|
| 27 |
|
---|
| 28 | public void setTile(int x, int y, Tile t) {
|
---|
| 29 | grid[x][y] = t;
|
---|
| 30 | }
|
---|
| 31 |
|
---|
| 32 | public void draw(Canvas c, int xStart, int yStart) {
|
---|
| 33 | for(int x=0; x<getWidth(); x++)
|
---|
| 34 | for(int y=0; y<getHeight(); y++)
|
---|
| 35 | grid[x][y].draw(c, xStart+50*x, yStart+50*y);
|
---|
| 36 | }
|
---|
| 37 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.