Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:versionName="3.0.2" >

<uses-sdk
android:minSdkVersion="8"
android:minSdkVersion="11"
android:targetSdkVersion="21" />

<uses-permission android:name="android.permission.INTERNET" />
Expand Down
30 changes: 22 additions & 8 deletions src/com/wurbo/ghostcatcher/GameSurfaceView.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
import android.content.Context;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Typeface;
import android.graphics.drawable.PictureDrawable;
Expand All @@ -33,8 +36,8 @@ public class GameSurfaceView extends SurfaceView implements
private MainThread mThread;
private long height, width;
public static final String TAG = GameSurfaceView.class.getSimpleName();
PictureDrawable ghostBase;
PictureDrawable playerBase;
Bitmap ghostBase;
Bitmap playerBase;
PictureDrawable background;
private float cursorX = 0;
private float cursorY = 0;
Expand Down Expand Up @@ -88,9 +91,20 @@ public GameSurfaceView(Context context, String username) {

// Load SVGS
SVG svg = SVGParser.getSVGFromResource(getResources(), R.raw.ghostbasic);
ghostBase = svg.createPictureDrawable();
svg = SVGParser.getSVGFromResource(getResources(), R.raw.ghostbasic);
playerBase = svg.createPictureDrawable();
PictureDrawable pd = svg.createPictureDrawable();
Bitmap bitmap = Bitmap.createBitmap(pd.getIntrinsicWidth(), pd.getIntrinsicHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
canvas.drawPicture(pd.getPicture());


Bitmap bitmap2 = Bitmap.createBitmap(pd.getIntrinsicWidth(), pd.getIntrinsicHeight(), Config.ARGB_8888);
Canvas canvas2 = new Canvas(bitmap2);
canvas2.scale(1, -1);
canvas2.translate(0, -pd.getIntrinsicWidth());
canvas2.drawPicture(pd.getPicture());

ghostBase = bitmap2;
playerBase = bitmap;

// Get window height/width
DisplayMetrics displaymetrics = new DisplayMetrics();
Expand Down Expand Up @@ -132,7 +146,7 @@ public GameSurfaceView(Context context, String username) {
for (int i = 0; i < numGhosts; i++) {
Ghost ghost = new Ghost(50, (int) width, (int) height, ghostBase);
ghost.random((int) width, (int) height);
ghost.setFlipped(true);
//ghost.setFlipped(true);
ghosts.add(ghost);
}

Expand Down Expand Up @@ -333,8 +347,8 @@ private void changeSize(String string) {
}

private void drawEntity(Canvas canvas, Entity entity) {
canvas.drawPicture(entity.basePicture(), entity);
canvas.drawCircle(entity.getX(), entity.getY() + entity.getOffset(), entity.getOffset(), entity.getPaint());
canvas.drawBitmap(entity.basePicture(), null, entity, entity.getPaint());
//canvas.drawCircle(entity.getX(), entity.getY() + entity.getOffset(), entity.getOffset(), entity.getPaint());
}

@Override
Expand Down
15 changes: 9 additions & 6 deletions src/com/wurbo/ghostcatcher/entities/Entity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

import java.util.Random;

import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.ColorFilter;
import android.graphics.LightingColorFilter;
import android.graphics.Paint;
import android.graphics.Picture;
import android.graphics.RectF;
import android.graphics.drawable.PictureDrawable;

public class Entity extends RectF {

Expand All @@ -19,16 +21,17 @@ public class Entity extends RectF {
private boolean flipped = false;
protected Random rand;
protected Paint paint;
private Picture basePicture;
private Bitmap basePicture;

public Entity(float size, int screenWidth, int screenHeight, PictureDrawable baseImage) {
public Entity(float size, int screenWidth, int screenHeight, Bitmap playerBase) {
rand = new Random();
paint = new Paint();
//Create ratio for width for target width of 720px
this.widthRatio = (float) (screenWidth / 720.0);
this.heightRatio = (float) (screenHeight / 1080.0);
this.size = size;
this.basePicture = baseImage.getPicture();
//playerBase.setColorFilter(cf);
this.basePicture = playerBase;
}

public float getSize() {
Expand Down Expand Up @@ -112,7 +115,7 @@ public Paint getPaint() {
return paint;
}

public Picture basePicture() {
public Bitmap basePicture() {
return basePicture;
}
}
13 changes: 10 additions & 3 deletions src/com/wurbo/ghostcatcher/entities/Ghost.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.wurbo.ghostcatcher.entities;

import android.graphics.drawable.PictureDrawable;
import android.graphics.Bitmap;
import android.graphics.PorterDuff;
import android.graphics.PorterDuffColorFilter;


public class Ghost extends Entity {
Expand All @@ -10,7 +12,7 @@ public enum GhostType {

private GhostType type;

public Ghost(float size, int screenWidth, int screenHeight, PictureDrawable ghostBase) {
public Ghost(float size, int screenWidth, int screenHeight, Bitmap ghostBase) {
super(size, screenWidth, screenHeight, ghostBase);
paint.setARGB(0, 0, 0, 0);
setType(GhostType.WHITE);
Expand All @@ -20,7 +22,7 @@ public void setType(GhostType type) {
this.type = type;
switch (type) {
case WHITE:
paint.setARGB(0, 0, 0, 0);
paint.setARGB(200, 255, 255, 255);
setSize(50);
break;
case RED:
Expand All @@ -46,6 +48,11 @@ public void setType(GhostType type) {
default:
break;
}

//ColorFilter cf = new LightingColorFilter(paint.getColor(), 1);
if (type != GhostType.WHITE) {
paint.setColorFilter(new PorterDuffColorFilter(paint.getColor(), PorterDuff.Mode.ADD));
}
}

public void random(int width, int height) {
Expand Down
4 changes: 2 additions & 2 deletions src/com/wurbo/ghostcatcher/entities/Player.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.wurbo.ghostcatcher.entities;

import android.graphics.drawable.PictureDrawable;
import android.graphics.Bitmap;


public class Player extends Entity {
Expand All @@ -9,7 +9,7 @@ public class Player extends Entity {
private long shieldTime = 10000;
private int score = 0;

public Player(float size, int screenWidth, int screenHeight, PictureDrawable playerBase) {
public Player(float size, int screenWidth, int screenHeight, Bitmap playerBase) {
super(size, screenWidth, screenHeight, playerBase);
paint.setARGB(0, 0, 0, 0);
}
Expand Down