Pacman null check since he might arrive at a null tile
This commit is contained in:
parent
347f8f5dba
commit
f5ba40255a
@ -1,6 +1,7 @@
|
|||||||
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 {
|
||||||
@ -21,7 +22,7 @@ public class Pacman extends MovableEntity {
|
|||||||
@Override
|
@Override
|
||||||
public TextureRegion getSprite() {
|
public TextureRegion getSprite() {
|
||||||
if (!moving) {
|
if (!moving) {
|
||||||
return sprite[0][0];
|
return sprite[2][0];
|
||||||
}
|
}
|
||||||
|
|
||||||
int spriteDir;
|
int spriteDir;
|
||||||
@ -55,7 +56,12 @@ public class Pacman extends MovableEntity {
|
|||||||
counter += 1;
|
counter += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (state.level.getTile(x, y)) {
|
LevelTile tile = state.level.getTile(x, y);
|
||||||
|
if (tile == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (tile) {
|
||||||
case PELLET:
|
case PELLET:
|
||||||
state.eatPellet(x, y);
|
state.eatPellet(x, y);
|
||||||
freezeFrames = 1;
|
freezeFrames = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user