Changeset 113d7cf in advance-wars for src/com/medievaltech/advancewars/Map.java


Ignore:
Timestamp:
May 9, 2011, 6:23:05 PM (14 years ago)
Author:
dportnoy <devnull@…>
Branches:
master
Children:
bdd63ba
Parents:
ae564dc
Message:

Implemented saving/loading of the map and the units on it. Also did some package refactoring (renamed com.medievaltech.game to com.medievaltech.unit and moved some classes into com.medievaltech.advancewars)

File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/com/medievaltech/advancewars/Map.java

    rae564dc r113d7cf  
    1 package com.medievaltech.game;
     1package com.medievaltech.advancewars;
    22
    3 import android.graphics.Canvas;
    4 import android.graphics.Point;
     3import java.io.*;
     4
     5import com.medievaltech.unit.Unit;
     6
     7
     8import android.graphics.*;
    59
    610public class Map {
     
    4246        }
    4347       
     48        public void save(PrintWriter p) {
     49                p.println(getWidth());
     50                p.println(getHeight());
     51                p.println(offset.x+"x"+offset.y);
     52               
     53                for(int x=0; x<getWidth(); x++) {
     54                        p.print(grid[x][0].type.ordinal());
     55                        for(int y=1; y<getHeight(); y++)
     56                                p.print(","+grid[x][y].type.ordinal());
     57                        p.println();
     58                }
     59               
     60                for(int x=0; x<getWidth(); x++) {
     61                        for(int y=1; y<getHeight(); y++) {
     62                                if(grid[x][y].currentUnit != null) {
     63                                        Unit u = grid[x][y].currentUnit;
     64                                        //p.println(u.type);
     65                                        p.println(u.location.x+","+u.location.y);
     66                                }
     67                        }
     68                }
     69        }
     70       
    4471        public void draw(Canvas c) {
    4572                for(int x=0; x<getWidth(); x++)
Note: See TracChangeset for help on using the changeset viewer.