Eat power pellets.

This commit is contained in:
Matt Low 2019-12-25 01:33:27 +04:00
parent e038db9500
commit fd30774746
2 changed files with 15 additions and 2 deletions

View File

@ -1,7 +1,6 @@
package com.me.pacman.entity; package com.me.pacman.entity;
import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.me.pacman.level.LevelTile;
import com.me.pacman.state.PlayState; import com.me.pacman.state.PlayState;
public class Pacman extends MovableEntity { public class Pacman extends MovableEntity {
@ -61,6 +60,10 @@ public class Pacman extends MovableEntity {
state.eatPellet(x, y); state.eatPellet(x, y);
freezeFrames = 1; freezeFrames = 1;
break; break;
case POWER_PELLET:
state.eatPowerPellet(x, y);
freezeFrames = 3;
break;
} }
} }

View File

@ -90,7 +90,7 @@ public class PlayState extends LevelState {
lives--; lives--;
} }
public void eatPellet(float x, float y) { private void pelletEaten(float x, float y) {
level.setTile(x, y, LevelTile.EMPTY); level.setTile(x, y, LevelTile.EMPTY);
if (pelletEatenCount % 2 == 0) { if (pelletEatenCount % 2 == 0) {
game.assets.chomp_1.play(1.0f); game.assets.chomp_1.play(1.0f);
@ -99,9 +99,19 @@ public class PlayState extends LevelState {
} }
pelletEatenCount++; pelletEatenCount++;
pelletCount--; pelletCount--;
}
public void eatPellet(float x, float y) {
pelletEaten(x, y);
score += 10; score += 10;
} }
public void eatPowerPellet(float x, float y) {
pelletEaten(x, y);
// TODO: Enable ghost chase mode
score += 50;
}
@Override @Override
public void dispose() { public void dispose() {
Gdx.input.setInputProcessor(null); Gdx.input.setInputProcessor(null);