Pacman null check since he might arrive at a null tile

This commit is contained in:
Matt Low 2019-12-25 19:12:26 +04:00
parent 347f8f5dba
commit f5ba40255a

View File

@ -1,6 +1,7 @@
package com.me.pacman.entity;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.me.pacman.level.LevelTile;
import com.me.pacman.state.PlayState;
public class Pacman extends MovableEntity {
@ -21,7 +22,7 @@ public class Pacman extends MovableEntity {
@Override
public TextureRegion getSprite() {
if (!moving) {
return sprite[0][0];
return sprite[2][0];
}
int spriteDir;
@ -55,7 +56,12 @@ public class Pacman extends MovableEntity {
counter += 1;
}
switch (state.level.getTile(x, y)) {
LevelTile tile = state.level.getTile(x, y);
if (tile == null) {
return;
}
switch (tile) {
case PELLET:
state.eatPellet(x, y);
freezeFrames = 1;