Changeset 1291908 in galcon-client
- Timestamp:
- May 28, 2010, 12:55:50 AM (14 years ago)
- Branches:
- master
- Children:
- 5a03a06
- Parents:
- 3e9f39e
- Location:
- src/com/example/helloandroid
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/example/helloandroid/Fleet.java
r3e9f39e r1291908 15 15 public Fleet(Planet source, Planet destination, int numShips, int faction) { 16 16 //Calculate initial coordinates and direction 17 if(destination. x - source.x!= 0){17 if(destination.getX() - source.getX() != 0){ 18 18 //line formula 19 slope = ((source. y - destination.y)/(source.x - destination.x));20 xIntercept = destination. y - (slope*destination.x);19 slope = ((source.getY() - destination.getY())/(source.getX() - destination.getX())); 20 xIntercept = destination.getY() - (slope*destination.getX()); 21 21 22 22 //direction … … 24 24 25 25 //coordinates for all 4 coordinates 26 if(destination. x - source.x< 0 )26 if(destination.getX() - source.getX() < 0 ) 27 27 direction += Math.PI; 28 28 29 x = (int)((Math.cos(direction)*(source.radius + 10) + source. x));30 y = (int)((Math.sin(direction)*(source.radius + 10) + source. y));29 x = (int)((Math.cos(direction)*(source.radius + 10) + source.getX())); 30 y = (int)((Math.sin(direction)*(source.radius + 10) + source.getY())); 31 31 } else { 32 if((destination. y - source.y) > 0 ){32 if((destination.getY() - source.getY()) > 0 ){ 33 33 direction = Math.PI/2; 34 x = destination. x;35 y = source. y+ source.radius + 10;34 x = destination.getX(); 35 y = source.getY() + source.radius + 10; 36 36 } else { 37 37 direction = 3*Math.PI/2; 38 x = destination. x;39 y = source. y- source.radius - 10;38 x = destination.getX(); 39 y = source.getY() - source.radius - 10; 40 40 } 41 41 } … … 125 125 // attack the destination planet 126 126 public void attack() { 127 if(numShips <= destination.numShips ){ 128 127 if(numShips <= destination.getNumShips()){ 128 destination.setNumShips(destination.getNumShips() - numShips); 129 } else { 130 destination.setNumShips(numShips - destination.getNumShips()); 131 destination.setFaction(this.faction); 129 132 } 130 133 } -
src/com/example/helloandroid/Planet.java
r3e9f39e r1291908 41 41 } 42 42 43 public void setFaction(int faction) { 44 this.faction = faction; 45 } 46 43 47 public void update() { 44 48 //regen ships if not owned by faction 0
Note:
See TracChangeset
for help on using the changeset viewer.