Changeset 1a1e8c7 in advance-wars for src/com/medievaltech/game/Tile.java


Ignore:
Timestamp:
Jan 31, 2011, 11:44:53 PM (14 years ago)
Author:
dportnoy <devnull@…>
Branches:
master
Children:
00c432c
Parents:
abe7b3d
Message:

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

File:
1 moved

Legend:

Unmodified
Added
Removed
  • src/com/medievaltech/game/Tile.java

    rabe7b3d r1a1e8c7  
    1 package com.medievaltech.advancewars;
    2 
    3 import com.medievaltech.game.Unit;
     1package com.medievaltech.game;
    42
    53import android.graphics.Canvas;
     
    1715        public Unit currentUnit;
    1816        public Point point;
     17        private Paint p;
    1918       
    20         public void addUnit(Unit unit)
    21         {
     19        public Tile(Paint p) {
     20                this.p = p;
     21                this.currentUnit = null;
     22        }
     23       
     24        public Tile(Tile t) {
     25                this.type = t.type;
     26                this.moveCoefficent = t.moveCoefficent;
     27                this.p = t.p;
     28        }
     29       
     30        public void addUnit(Unit unit) {
    2231                currentUnit = unit;     
    2332        }
    2433       
    25         public void removeUnit(Unit unit)
    26         {
    27                 if(currentUnit != null)
    28                 {
     34        public void removeUnit(Unit unit) {
     35                if(currentUnit != null) {
    2936                        currentUnit = null;
    3037                }
    3138       
    3239        }
    33         private Paint p;
    34        
    35         public Tile(Paint p) {
    36                 this.p = p;
    37         }
    3840       
    3941        public void draw(Canvas c, int x, int y) {
    4042                c.drawRect(x, y, x+50, y+50, p);
     43               
     44                if(currentUnit != null)
     45                        currentUnit.draw(c, x+25, y+25);
    4146        }
    4247}
Note: See TracChangeset for help on using the changeset viewer.