Changeset 5a03a06 in galcon-client for src/com/example/helloandroid/Fleet.java
- Timestamp:
- May 28, 2010, 3:32:34 AM (14 years ago)
- Branches:
- master
- Children:
- b6a9b5f
- Parents:
- 1291908
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/example/helloandroid/Fleet.java
r1291908 r5a03a06 1 1 package com.example.helloandroid; 2 3 import java.math.*;4 2 5 3 public class Fleet { 6 4 private int x; 7 5 private int y; 6 private double dblX; 7 private double dblY; 8 8 private double slope, xIntercept; 9 9 private double direction; … … 15 15 public Fleet(Planet source, Planet destination, int numShips, int faction) { 16 16 //Calculate initial coordinates and direction 17 if( destination.getX() - source.getX() != 0){17 if((destination.getX() - source.getX()) != 0){ 18 18 //line formula 19 19 slope = ((source.getY() - destination.getY())/(source.getX() - destination.getX())); … … 24 24 25 25 //coordinates for all 4 coordinates 26 if( destination.getX() - source.getX() < 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.getX())); 30 y = (int)((Math.sin(direction)*(source.radius + 10) + source.getY())); 29 dblX = ((Math.cos(direction)*(source.radius + 10) + source.getX())); 30 dblY = ((Math.sin(direction)*(source.radius + 10) + source.getY())); 31 31 32 } else { 32 33 if((destination.getY() - source.getY()) > 0 ){ 33 34 direction = Math.PI/2; 34 x= destination.getX();35 y= source.getY() + source.radius + 10;35 dblX = destination.getX(); 36 dblY = source.getY() + source.radius + 10; 36 37 } else { 37 38 direction = 3*Math.PI/2; 38 x= destination.getX();39 y= source.getY() - source.radius - 10;39 dblX = destination.getX(); 40 dblY = source.getY() - source.radius - 10; 40 41 } 41 42 } 43 44 x = (int)dblX; 45 y = (int)dblY; 42 46 43 47 this.numShips = numShips; … … 120 124 121 125 public void update() { 122 126 int speed = 1; //pixels per move 123 127 } 124 128 125 129 // attack the destination planet 130 //after the method is called the fleet needs to removed 126 131 public void attack() { 127 132 if(numShips <= destination.getNumShips()){
Note:
See TracChangeset
for help on using the changeset viewer.