update
This commit is contained in:
1 parent
04c9b367ae
commit
406af7315b
7 files changed
+29
-113
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,85 +1,5 @@
|
||||
/* AUTO-GENERATED FILE. DO NOT MODIFY.
|
||||
*
|
||||
* This class was automatically generated by the
|
||||
* aapt tool from the resource data it found. It
|
||||
* should not be modified by hand.
|
||||
*/
|
||||
|
||||
package com.adroid.game.pacman;
|
||||
|
||||
/* This stub is for using by IDE only. It is NOT the R class actually packed into APK */
|
||||
public final class R {
|
||||
public static final class attr {
|
||||
}
|
||||
public static final class drawable {
|
||||
public static final int blue_gradien=0x7f020000;
|
||||
public static final int corner=0x7f020001;
|
||||
public static final int food=0x7f020002;
|
||||
public static final int foodup=0x7f020003;
|
||||
public static final int ghost=0x7f020004;
|
||||
public static final int ghost_eat=0x7f020005;
|
||||
public static final int ghost_eat2=0x7f020006;
|
||||
public static final int ghost_eye=0x7f020007;
|
||||
public static final int ic_launcher=0x7f020008;
|
||||
public static final int inky=0x7f020009;
|
||||
public static final int level1=0x7f02000a;
|
||||
public static final int pacman=0x7f02000b;
|
||||
public static final int pacman_final1=0x7f02000c;
|
||||
public static final int pacmanta=0x7f02000d;
|
||||
public static final int pacmantaa=0x7f02000e;
|
||||
public static final int sfood=0x7f02000f;
|
||||
public static final int streight=0x7f020010;
|
||||
}
|
||||
public static final class id {
|
||||
public static final int menu_settings=0x7f080000;
|
||||
}
|
||||
public static final class layout {
|
||||
public static final int activity_main=0x7f030000;
|
||||
}
|
||||
public static final class menu {
|
||||
public static final int activity_main=0x7f070000;
|
||||
}
|
||||
public static final class raw {
|
||||
public static final int lvl=0x7f040000;
|
||||
public static final int lvl0=0x7f040001;
|
||||
public static final int pacman_cherry=0x7f040002;
|
||||
public static final int pacman_die=0x7f040003;
|
||||
public static final int pacman_ghost_eating=0x7f040004;
|
||||
public static final int pacman_siren=0x7f040005;
|
||||
public static final int pacman_start=0x7f040006;
|
||||
public static final int pacman_walk=0x7f040007;
|
||||
public static final int pacmandie=0x7f040008;
|
||||
}
|
||||
public static final class string {
|
||||
public static final int app_name=0x7f050000;
|
||||
public static final int hello_world=0x7f050001;
|
||||
public static final int menu_settings=0x7f050002;
|
||||
}
|
||||
public static final class style {
|
||||
/**
|
||||
Base application theme, dependent on API level. This theme is replaced
|
||||
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
|
||||
|
||||
|
||||
Theme customizations available in newer API levels can go in
|
||||
res/values-vXX/styles.xml, while customizations related to
|
||||
backward-compatibility can go here.
|
||||
|
||||
|
||||
Base application theme for API 11+. This theme completely replaces
|
||||
AppBaseTheme from res/values/styles.xml on API 11+ devices.
|
||||
|
||||
API 11 theme customizations can go here.
|
||||
|
||||
Base application theme for API 14+. This theme completely replaces
|
||||
AppBaseTheme from BOTH res/values/styles.xml and
|
||||
res/values-v11/styles.xml on API 14+ devices.
|
||||
|
||||
API 14 theme customizations can go here.
|
||||
*/
|
||||
public static final int AppBaseTheme=0x7f060000;
|
||||
/** Application theme.
|
||||
All customizations that are NOT specific to a particular API-level can go here.
|
||||
*/
|
||||
public static final int AppTheme=0x7f060001;
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -19,13 +19,13 @@ x.xx..0000000000000000.....x
|
||||
x.xxxxxxx0xxxxxxxxx0xxxxxx.x
|
||||
x.xxxxxxx.xxxxxxxxx.xxxxxx.x
|
||||
x.xxx...............xx.....x
|
||||
x.xxx.xxxxxxxx.xxxx.xx.xxxxx
|
||||
x.xxx.xxxxxxxx.xxxx.xx.xxxxx
|
||||
x.xxx.xxxxxxx.xxxxx.xx.xxxxx
|
||||
x.xxx.xxxxxxx.xxxxx.xx.xxxxx
|
||||
xo........................ox
|
||||
x.xxxxxxxxxxxx.xxxx.xxxxxx.x
|
||||
x.xxxxxxxxxxxx.xxxx.xxxxxx.x
|
||||
x.xxxxxxxxxxxx.xxxx.xxxxxx.x
|
||||
x.xxxxxxxxxxxx.xxxx.xxxxxx.x
|
||||
x.xxxxxxxxxxx.xxxxx.xxxxxx.x
|
||||
x.xxxxxxxxxxx.xxxxx.xxxxxx.x
|
||||
x.xxxxxxxxxxx.xxxxx.xxxxxx.x
|
||||
x.xxxxxxxxxxx.xxxxx.xxxxxx.x
|
||||
x....xx.o..................x
|
||||
x.xx.xx.xxxxxxxxxx.xxxxxxx.x
|
||||
x.xx....xxxxxxxxxx.xxxxxxx.x
|
||||
|
||||
@@ -1,14 +1,8 @@
|
||||
package com.android.game.pacman.game;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Timer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Matrix;
|
||||
import android.graphics.Paint;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
@@ -16,22 +10,14 @@ import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.CountDownTimer;
|
||||
import android.os.Vibrator;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.Log;
|
||||
import android.view.SurfaceHolder;
|
||||
import android.view.SurfaceView;
|
||||
|
||||
import com.adroid.game.pacman.R;
|
||||
import com.android.game.pacman.model.Block;
|
||||
import com.android.game.pacman.model.Board;
|
||||
import com.android.game.pacman.model.Collision;
|
||||
import com.android.game.pacman.model.Ghost;
|
||||
import com.android.game.pacman.model.PacMan;
|
||||
import com.android.game.pacman.model.SolidObject;
|
||||
import com.android.game.pacman.model.SoundStuff;
|
||||
import com.android.game.pacman.model.Vect;
|
||||
import com.android.game.pacman.model.*;
|
||||
import com.android.game.pacman.utils.GameEnum;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class GameLogic extends SurfaceView implements SurfaceHolder.Callback,
|
||||
SensorEventListener {
|
||||
|
||||
@@ -207,15 +193,17 @@ public class GameLogic extends SurfaceView implements SurfaceHolder.Callback,
|
||||
for (Ghost ghost : ghosts) {
|
||||
if (Collision.detectNormalCollision(pacman.boundingRect,
|
||||
ghost.boundingRect)) {
|
||||
if (ghost.isEatable()) {
|
||||
if (ghost.isEatable() && !ghost.isOnlyEyes()) {
|
||||
ghost.setIsTouched(true);
|
||||
ghost.reset();
|
||||
ghost.setEyes(true);
|
||||
eatInRow++;
|
||||
points += GHOST_EAT_POINT * eatInRow;
|
||||
SoundStuff.sp.play(SoundStuff.pacmanEatGhost, 1, 1, 1, 0,
|
||||
1f);
|
||||
v.vibrate(100);
|
||||
|
||||
} else
|
||||
} else if (!ghost.isOnlyEyes())
|
||||
pacman.die();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package com.android.game.pacman.model;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Rect;
|
||||
|
||||
import com.adroid.game.pacman.R;
|
||||
import com.android.game.pacman.game.GameLogic;
|
||||
import com.android.game.pacman.utils.GameEnum;
|
||||
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class Ghost extends GameObject {
|
||||
private LinkedList<GameEnum> movement;
|
||||
private Rect sourceRect;
|
||||
@@ -72,7 +71,7 @@ public class Ghost extends GameObject {
|
||||
canChangeDir();
|
||||
if (eatable) {
|
||||
if (isTouched) {
|
||||
eatable = false;
|
||||
eatable = true;
|
||||
onlyEyes = true;
|
||||
}
|
||||
|
||||
@@ -109,20 +108,25 @@ public class Ghost extends GameObject {
|
||||
|
||||
|
||||
}
|
||||
public void reset(){
|
||||
|
||||
public void reset() {
|
||||
time = 0;
|
||||
currentFrame = 0;
|
||||
framePeriod = 0.5f;
|
||||
blinking = false;
|
||||
eatable = false;
|
||||
frameTicker = 0;
|
||||
swap=false;
|
||||
swap = false;
|
||||
}
|
||||
|
||||
public boolean isEatable() {
|
||||
return eatable;
|
||||
}
|
||||
|
||||
public boolean isOnlyEyes() {
|
||||
return onlyEyes;
|
||||
}
|
||||
|
||||
private void calculateSourceRect(double gameTime) {
|
||||
|
||||
if (!eatable) {
|
||||
@@ -146,7 +150,7 @@ public class Ghost extends GameObject {
|
||||
sourceRect.right = sourceRect.left + spriteWidth;
|
||||
|
||||
}
|
||||
} else if (eatable && blinking) {
|
||||
} else if (eatable && blinking && !onlyEyes) {
|
||||
frameTicker += gameTime;
|
||||
time += gameTime;
|
||||
if (frameTicker > framePeriod) {
|
||||
@@ -172,6 +176,10 @@ public class Ghost extends GameObject {
|
||||
sourceEatRect.right = sourceEatRect.left + spriteEatWidth;
|
||||
}
|
||||
|
||||
public void setEyes(boolean set) {
|
||||
onlyEyes = set;
|
||||
}
|
||||
|
||||
public void setBlinking(boolean blinking) {
|
||||
this.blinking = blinking;
|
||||
|
||||
|
||||
Reference in new issue
Block a user