From f5ba40255aa76a1c8340450e0f5e2c90cb047806 Mon Sep 17 00:00:00 2001 From: Matt Low Date: Wed, 25 Dec 2019 19:12:26 +0400 Subject: [PATCH] Pacman null check since he might arrive at a null tile --- core/src/com/me/pacman/entity/Pacman.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/src/com/me/pacman/entity/Pacman.java b/core/src/com/me/pacman/entity/Pacman.java index a073885..bd50d15 100644 --- a/core/src/com/me/pacman/entity/Pacman.java +++ b/core/src/com/me/pacman/entity/Pacman.java @@ -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;