Basic score count working
update takes movement into account
This commit is contained in:
@ -1,9 +1,9 @@
|
||||
package se.urmo.game.state;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import se.urmo.game.collision.CollisionChecker;
|
||||
import se.urmo.game.collision.GhostCollisionChecker;
|
||||
import se.urmo.game.entities.BlinkyStrategy;
|
||||
import se.urmo.game.entities.Ghost;
|
||||
import se.urmo.game.entities.PacMan;
|
||||
import se.urmo.game.main.Game;
|
||||
@ -14,6 +14,7 @@ import java.awt.*;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.InputStream;
|
||||
|
||||
@Slf4j
|
||||
public class PlayingState implements GameState {
|
||||
private final Game game;
|
||||
private final GameStateManager gameStateManager;
|
||||
@ -39,6 +40,16 @@ public class PlayingState implements GameState {
|
||||
pacman.update();
|
||||
ghostManager.update(pacman, map);
|
||||
checkCollisions();
|
||||
handleDots();
|
||||
}
|
||||
|
||||
private void handleDots() {
|
||||
Point pacmanScreenPos = pacman.getPosition();
|
||||
boolean wasRemoved = map.removeTileImage(pacmanScreenPos);
|
||||
|
||||
if(wasRemoved){
|
||||
score+=10;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -84,7 +95,6 @@ public class PlayingState implements GameState {
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
pacman.setMoving(false);
|
||||
pacman.setDirection(Direction.NONE);
|
||||
}
|
||||
|
||||
private void checkCollisions() {
|
||||
|
||||
Reference in New Issue
Block a user