Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added randomized spin on dropped brick. Removed debugging decoration …

…from protagonist.
  • Loading branch information...
commit d08bf60f7de9a5e6b48823a115d8054f2a871819 1 parent 7f77310
Wayne Beaton authored January 11, 2011
BIN  bin/KittyMunch3Android.apk
Binary file not shown
BIN  bin/classes.dex
Binary file not shown
22  src/ca/rokc/kittymunch/game/Brick.java
@@ -10,12 +10,17 @@
10 10
  *******************************************************************************/
11 11
 package ca.rokc.kittymunch.game;
12 12
 
  13
+import java.util.Random;
  14
+
13 15
 import android.graphics.Canvas;
14 16
 import android.graphics.Color;
15 17
 import android.graphics.Paint;
16 18
 import ca.rokc.kittymunch.geometry.Point;
17 19
 
18 20
 public class Brick extends Projectile {
  21
+	float rotation = 0;
  22
+	float spin = (float) (new Random().nextFloat() - 0.5);
  23
+	
19 24
 	public Brick(Point location, Point velocity, int height) {
20 25
 		super(location, velocity, height);
21 26
 	}
@@ -23,8 +28,19 @@ public Brick(Point location, Point velocity, int height) {
23 28
 	@Override
24 29
 	public void drawOn(Canvas canvas) {
25 30
 		Paint paint = new Paint();
26  
-		paint.setStyle(Paint.Style.STROKE);
27  
-		paint.setColor(Color.RED);
28  
-		canvas.drawCircle((int)location.x, (int)location.y, height, paint);
  31
+		paint.setStyle(Paint.Style.FILL);
  32
+		paint.setColor(Color.DKGRAY);
  33
+		int left = (int)location.x - height;
  34
+		int right = (int)location.x + height;
  35
+		int top = (int)location.y - (height / 2);
  36
+		int bottom = (int)location.y + (height / 2);
  37
+		
  38
+		
  39
+		canvas.save();
  40
+		canvas.rotate(rotation, (float)location.x, (float)location.y);
  41
+		canvas.drawRect(left, top, right, bottom, paint);
  42
+		canvas.restore();
  43
+		
  44
+		rotation += spin;
29 45
 	}
30 46
 }
18  src/ca/rokc/kittymunch/game/Protagonist.java
@@ -14,7 +14,6 @@
14 14
 import android.graphics.Bitmap;
15 15
 import android.graphics.BitmapFactory;
16 16
 import android.graphics.Canvas;
17  
-import android.graphics.Color;
18 17
 import android.graphics.Paint;
19 18
 import ca.rokc.kittymunch.R;
20 19
 import ca.rokc.kittymunch.geometry.Point;
@@ -119,20 +118,7 @@ public void drawOn(Canvas canvas) {
119 118
 		
120 119
 		canvas.drawBitmap(bitmap, (int)location.x - 35, (int)location.y - 45, new Paint());
121 120
 
122  
-		drawRectangle(canvas, movementBounds, Color.GREEN);
123  
-		drawRectangle(canvas, dropBounds, Color.RED);
124  
-	}
125  
-
126  
-	private void drawRectangle(Canvas canvas, Rectangle rectangle, int color) {
127  
-		Paint paint;
128  
-		paint = new Paint();
129  
-		paint.setStyle(Paint.Style.STROKE);
130  
-		paint.setColor(color);
131  
-		
132  
-		canvas.drawRect(
133  
-				rectangle.left, 
134  
-				rectangle.top, 
135  
-				rectangle.right, 
136  
-				rectangle.bottom, paint);
  121
+//		drawRectangle(canvas, movementBounds, Color.GREEN);
  122
+//		drawRectangle(canvas, dropBounds, Color.RED);
137 123
 	}
138 124
 }

0 notes on commit d08bf60

Please sign in to comment.
Something went wrong with that request. Please try again.