source: galcon-client/src/com/example/helloandroid/Fleet.java@ 96857ee

Last change on this file since 96857ee was 96857ee, checked in by Zero Cool <devnull@…>, 14 years ago

Fleet.java

  • Property mode set to 100644
File size: 2.0 KB
Line 
1package com.example.helloandroid;
2
3import java.math.*;
4
5public class Fleet {
6 private int x;
7 private int y;
8 private double slope, xIntercept;
9 private double direction;
10 private Planet destination;
11 private int numShips;
12 private int faction;
13
14 /* Optimising: pre-calculate paths */
15 public Fleet(Planet source, Planet destination, int numShips, int faction) {
16 //Calculate initial coordinates and direction
17
18 //line formula
19 slope = ((source.y - destination.y)/(source.x - destination.x));
20 xIntercept = destination.y - (slope*destination.x);
21
22 //direction
23 direction = 1/Math.tan(slope);
24
25 //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)){
32
33 } else {
34
35 }
36 this.numShips = numShips;
37 this.faction = faction;
38 this.destination = destination;
39 }
40
41
42 public int getX() {
43 return x;
44 }
45
46
47
48 public void setX(int x) {
49 this.x = x;
50 }
51
52
53
54 public int getY() {
55 return y;
56 }
57
58
59
60 public void setY(int y) {
61 this.y = y;
62 }
63
64
65
66 public double getDirection() {
67 return direction;
68 }
69
70
71
72 public void setDirection(double direction) {
73 this.direction = direction;
74 }
75
76
77
78 public Planet getDestination() {
79 return destination;
80 }
81
82
83
84 public void setDestination(Planet destination) {
85 this.destination = destination;
86 }
87
88
89
90 public int getNumShips() {
91 return numShips;
92 }
93
94
95
96 public void setNumShips(int numShips) {
97 this.numShips = numShips;
98 }
99
100
101
102 public int getFaction() {
103 return faction;
104 }
105
106
107
108 public void setFaction(int faction) {
109 this.faction = faction;
110 }
111
112
113
114 public void update() {
115 //update coordinates
116
117 }
118
119 // attack the destination planet
120 public void attack() {
121 //planet attack
122 }
123}
Note: See TracBrowser for help on using the repository browser.