Permalink
Browse files

Added randomized spin on dropped brick. Removed debugging decoration …

…from protagonist.
  • Loading branch information...
waynebeaton committed Jan 11, 2011
1 parent 7f77310 commit d08bf60f7de9a5e6b48823a115d8054f2a871819
View
Binary file not shown.
View
Binary file not shown.
@@ -10,21 +10,37 @@
*******************************************************************************/
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);
}
@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;
}
}
@@ -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);
}
}

0 comments on commit d08bf60

Please sign in to comment.