Changeset 95509e1 in galcon-client for src/com/example/helloandroid/Fleet.java
- Timestamp:
- Jun 5, 2010, 7:01:47 PM (14 years ago)
- Branches:
- master
- Children:
- c65ef39
- Parents:
- 61c4fbc
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/com/example/helloandroid/Fleet.java
r61c4fbc r95509e1 4 4 5 5 import android.graphics.Canvas; 6 import android.graphics.Color; 6 7 import android.graphics.Paint; 7 8 import android.graphics.Path; … … 23 24 /* Optimising: pre-calculate paths */ 24 25 public Fleet(Planet source, Planet destination, int numShips, int faction) { 26 source.setNumShips(source.getNumShips()-numShips); 27 25 28 //Calculate initial coordinates and direction 26 29 if((destination.getX() - source.getX()) != 0){ … … 133 136 } 134 137 135 public void draw(Canvas canvas, Paint linePaint) { 136 //Log.i("Gencon", "direction: "+direction); 137 canvas.drawLine((float)x, (float)y, (float)(x+10*Math.cos(direction)), (float)(y+10*Math.sin(direction)), linePaint); 138 138 public void draw(Canvas canvas, Paint linePaint) { 139 139 Path p = new Path(); 140 140 … … 144 144 p.lineTo((float)(x+5*Math.cos(direction+Math.PI/2)), (float)(y+5*Math.sin(direction+Math.PI/2))); 145 145 146 int c, prevC = linePaint.getColor(); 147 148 switch(faction) { 149 case 0: 150 c = Color.argb(255, 100, 100, 100); 151 break; 152 case 1: 153 c = Color.argb(255, 255, 0, 0); 154 break; 155 case 2: 156 c = Color.argb(255, 0, 180, 0); 157 break; 158 case 3: 159 c = Color.argb(255, 0, 0, 255); 160 break; 161 case 4: 162 c = Color.argb(255, 150, 150, 0); 163 break; 164 default: 165 c = prevC; 166 } 167 168 linePaint.setColor(c); 169 146 170 canvas.drawPath(p, linePaint); 171 172 linePaint.setColor(prevC); 147 173 } 148 174
Note:
See TracChangeset
for help on using the changeset viewer.