Skip to content

Commit

Permalink
Add a ghost with an helmet and 5hp.
Browse files Browse the repository at this point in the history
This kind of ghost has 5 hp, that means that you have to shoot it 5
times before it dies.
  • Loading branch information
vbarthel-fr committed Aug 15, 2013
1 parent 6770c76 commit 857ae21
Show file tree
Hide file tree
Showing 43 changed files with 46 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,26 @@ public void spawn() {
if (mGameInformation.getCurrentTargetsNumber() < mGameInformation.getMaxTargetOnTheField()) {
final int randomDraw = MathUtils.randomize(0,100);
final float[] pos = mGameInformation.getCurrentPosition();
if(randomDraw < 80) {
if(randomDraw < 60) {
mGameInformation.addTargetableItem(DisplayableItemFactory.createEasyGhost(
(int) pos[0] - mXRange,
(int) pos[0] + mXRange,
(int) pos[1] - mYRange,
(int) pos[1] + mYRange));
}else {
}else if (randomDraw < 85){
mGameInformation.addTargetableItem(DisplayableItemFactory.createBabyGhost(
(int) pos[0] - mXRange,
(int) pos[0] + mXRange,
(int) pos[1] - mYRange,
(int) pos[1] + mYRange));
} else {
mGameInformation.addTargetableItem(DisplayableItemFactory.createGhostWithHelmet(
(int) pos[0] - mXRange,
(int) pos[0] + mXRange,
(int) pos[1] - mYRange,
(int) pos[1] + mYRange));
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ public class DisplayableItemFactory {
public final static int TYPE_EASY_GHOST = 0x00000001;
public final static int TYPE_BULLET_HOLE = 0x00000002;
public final static int TYPE_BABY_GHOST = 0x00000003;
public final static int TYPE_GHOST_WITH_HELMET = 0x00000004;

private static final int DEFAULT_X_MIN_IN_DEGREE = -170;
private static final int DEFAULT_X_MAX_IN_DEGREE = 170;
Expand All @@ -14,10 +15,12 @@ public class DisplayableItemFactory {
//Health
public final static int HEALTH_EASY_GHOST = 1;
public final static int HEALTH_BABY_GHOST = 1;
public final static int HEALTH_GHOST_WITH_HELMET = 5;

//Base Point
public final static int BASE_POINT_EAST_GHOST = 1;
public final static int BASE_POINT_BABY_GHOST = 2;
public final static int BASE_POINT_GHOST_WITH_HELMET = 10;

public static TargetableItem createEasyGhost() {
TargetableItem easyGhost = new TargetableItem();
Expand All @@ -30,12 +33,19 @@ public static TargetableItem createEasyGhost() {
return easyGhost;
}

public static TargetableItem createGhostWithHelmet(int xmin, int xmax, int ymin, int ymax) {
return createTargetableItem(TYPE_GHOST_WITH_HELMET, HEALTH_GHOST_WITH_HELMET, BASE_POINT_GHOST_WITH_HELMET
, xmin, xmax, ymin, ymax);
}

public static TargetableItem createEasyGhost(int xmin, int xmax, int ymin, int ymax) {
return createTargetableItem(TYPE_EASY_GHOST, HEALTH_EASY_GHOST, BASE_POINT_EAST_GHOST, xmin, xmax, ymin, ymax);
return createTargetableItem(TYPE_EASY_GHOST, HEALTH_EASY_GHOST, BASE_POINT_EAST_GHOST,
xmin, xmax, ymin, ymax);
}

public static TargetableItem createBabyGhost(int xmin, int xmax, int ymin, int ymax) {
return createTargetableItem(TYPE_BABY_GHOST, HEALTH_BABY_GHOST, BASE_POINT_BABY_GHOST, xmin, xmax, ymin, ymax);
return createTargetableItem(TYPE_BABY_GHOST, HEALTH_BABY_GHOST, BASE_POINT_BABY_GHOST,
xmin, xmax, ymin, ymax);
}

private static TargetableItem createTargetableItem(int type, int health, int basePoint, int xmin, int xmax, int ymin, int ymax) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public class GameView extends View {
private final Bitmap mBulletHoleBitmap;
private final Bitmap mBabyGhostBitmap;
private final Bitmap mTargetedBabyGhostBitmap;
private final Bitmap[] mGhostWithHelmetBitmaps;
private final Bitmap[] mGhostWithHelmetTargetedBitmaps;
private final String mComboString;
private final String mScoreString;
private final String mTimeString;
Expand Down Expand Up @@ -54,6 +56,21 @@ public GameView(Context context, GameInformation model) {
mBulletHoleBitmap = BitmapFactory.decodeResource(res, R.drawable.bullethole);
mBabyGhostBitmap = BitmapFactory.decodeResource(res, R.drawable.baby_ghost);
mTargetedBabyGhostBitmap = BitmapFactory.decodeResource(res, R.drawable.baby_ghost_targeted);
mGhostWithHelmetBitmaps = new Bitmap[]{
BitmapFactory.decodeResource(res, R.drawable.ghost_with_helmet_5),
BitmapFactory.decodeResource(res, R.drawable.ghost_with_helmet_4),
BitmapFactory.decodeResource(res, R.drawable.ghost_with_helmet_3),
BitmapFactory.decodeResource(res, R.drawable.ghost_with_helmet_2),
BitmapFactory.decodeResource(res, R.drawable.ghost_with_helmet),
};

mGhostWithHelmetTargetedBitmaps = new Bitmap[]{
BitmapFactory.decodeResource(res, R.drawable.ghost_with_helmet_5_targeted),
BitmapFactory.decodeResource(res, R.drawable.ghost_with_helmet_4_targeted),
BitmapFactory.decodeResource(res, R.drawable.ghost_with_helmet_3_targeted),
BitmapFactory.decodeResource(res, R.drawable.ghost_with_helmet_2_targeted),
BitmapFactory.decodeResource(res, R.drawable.ghost_with_helmet_targeted),
};

mComboString = res.getString(R.string.in_game_combo_counter);
mScoreString = res.getString(R.string.in_game_score);
Expand Down Expand Up @@ -206,6 +223,9 @@ private void drawDisplayableItems(Canvas canvas) {
case DisplayableItemFactory.TYPE_BABY_GHOST:
renderBabyGhost(canvas, (TargetableItem)i, currentPos);
break;
case DisplayableItemFactory.TYPE_GHOST_WITH_HELMET:
renderGhostWithHelmet(canvas, (TargetableItem)i, currentPos);
break;
case DisplayableItemFactory.TYPE_BULLET_HOLE:
renderBulletHole(canvas, i);
break;
Expand All @@ -232,6 +252,11 @@ private boolean isTargeted(float[] crosshairPosition, DisplayableItem t, Bitmap
}
}

private void renderGhostWithHelmet(Canvas canvas, TargetableItem ghostWithHelmet, float[] currentPos) {
int bitmapIndex = ghostWithHelmet.getHealth() - 1;
renderGhost(canvas, ghostWithHelmet, currentPos, mGhostWithHelmetBitmaps[bitmapIndex], mGhostWithHelmetTargetedBitmaps[bitmapIndex]);
}

private void renderEasyGhost(Canvas canvas, TargetableItem easyGhost, float[] currentPos) {
renderGhost(canvas, easyGhost, currentPos, mGhostBitmap, mGhostTargetedBitmap);
}
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 857ae21

Please sign in to comment.