Changeset 1a91f0d in galcon-client


Ignore:
Timestamp:
May 28, 2010, 12:34:15 AM (14 years ago)
Author:
Zero Cool <devnull@…>
Branches:
master
Children:
3e9f39e
Parents:
96857ee
Message:

Fleet Class pdate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/com/example/helloandroid/Fleet.java

    r96857ee r1a91f0d  
    1515        public Fleet(Planet source, Planet destination, int numShips, int faction) {
    1616                //Calculate initial coordinates and direction
    17                
     17                if(destination.x - source.x != 0){
    1818                //line formula
    1919                slope = ((source.y - destination.y)/(source.x - destination.x));
     
    2424               
    2525                //coordinates for all 4 coordinates
    26                 if ((direction >= 0) && (direction < Math.PI/2)){
    27                         x = (int)(Math.cos(direction)*(source.radius + 10) + source.x );
    28                         y = (int)(Math.sin(direction)*(source.radius + 10) + source.y );
    29                 } else if((direction >= Math.PI/2) && (direction < Math.PI)){
    30                        
    31                 } else if((direction >= Math.PI) && (direction < 3*Math.PI/2)){
     26                if(destination.x - source.x < 0 )
     27                        direction += Math.PI;
    3228               
     29                x = (int)((Math.cos(direction)*(source.radius + 10) + source.x));
     30                y = (int)((Math.sin(direction)*(source.radius + 10) + source.y));
    3331                } else {
     32                        if((destination.y - source.y) > 0 ){
     33                                direction = Math.PI/2;
     34                                x = destination.x;
     35                                y = source.y + source.radius + 10;
     36                        } else {
     37                                direction = 3*Math.PI/2;
     38                                x = destination.x;
     39                                y = source.y - source.radius - 10;
     40                        }
     41                }
    3442               
    35                 }
    3643                this.numShips = numShips;
    3744                this.faction = faction;
     
    113120
    114121        public void update() {
    115                 //update coordinates
    116        
     122               
    117123        }
    118124       
    119125        // attack the destination planet
    120126        public void attack() {
    121                 //planet attack
     127                if(numShips <= destination.numShips ){
     128               
     129                }
    122130        }
    123131}
Note: See TracChangeset for help on using the changeset viewer.