Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added randomized spin on dropped brick. Removed debugging decoration …

…from protagonist.
  • Loading branch information...
commit d08bf60f7de9a5e6b48823a115d8054f2a871819 1 parent 7f77310
Wayne Beaton authored
BIN  bin/KittyMunch3Android.apk
View
Binary file not shown
BIN  bin/classes.dex
View
Binary file not shown
22 src/ca/rokc/kittymunch/game/Brick.java
View
@@ -10,12 +10,17 @@
*******************************************************************************/
package ca.rokc.kittymunch.game;
+import java.util.Random;
+
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import ca.rokc.kittymunch.geometry.Point;
public class Brick extends Projectile {
+ float rotation = 0;
+ float spin = (float) (new Random().nextFloat() - 0.5);
+
public Brick(Point location, Point velocity, int height) {
super(location, velocity, height);
}
@@ -23,8 +28,19 @@ public Brick(Point location, Point velocity, int height) {
@Override
public void drawOn(Canvas canvas) {
Paint paint = new Paint();
- paint.setStyle(Paint.Style.STROKE);
- paint.setColor(Color.RED);
- canvas.drawCircle((int)location.x, (int)location.y, height, paint);
+ paint.setStyle(Paint.Style.FILL);
+ paint.setColor(Color.DKGRAY);
+ int left = (int)location.x - height;
+ int right = (int)location.x + height;
+ int top = (int)location.y - (height / 2);
+ int bottom = (int)location.y + (height / 2);
+
+
+ canvas.save();
+ canvas.rotate(rotation, (float)location.x, (float)location.y);
+ canvas.drawRect(left, top, right, bottom, paint);
+ canvas.restore();
+
+ rotation += spin;
}
}
18 src/ca/rokc/kittymunch/game/Protagonist.java
View
@@ -14,7 +14,6 @@
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
-import android.graphics.Color;
import android.graphics.Paint;
import ca.rokc.kittymunch.R;
import ca.rokc.kittymunch.geometry.Point;
@@ -119,20 +118,7 @@ public void drawOn(Canvas canvas) {
canvas.drawBitmap(bitmap, (int)location.x - 35, (int)location.y - 45, new Paint());
- drawRectangle(canvas, movementBounds, Color.GREEN);
- drawRectangle(canvas, dropBounds, Color.RED);
- }
-
- private void drawRectangle(Canvas canvas, Rectangle rectangle, int color) {
- Paint paint;
- paint = new Paint();
- paint.setStyle(Paint.Style.STROKE);
- paint.setColor(color);
-
- canvas.drawRect(
- rectangle.left,
- rectangle.top,
- rectangle.right,
- rectangle.bottom, paint);
+// drawRectangle(canvas, movementBounds, Color.GREEN);
+// drawRectangle(canvas, dropBounds, Color.RED);
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.