From 8fb64e8969f093c896ad9b5e327738e82941d30c Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Thu, 12 May 2016 15:04:55 +0200 Subject: Properly handle invulnerability state image --- src/ch/epfl/xblast/server/painter/PlayerPainter.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/ch/epfl/xblast/server/painter/PlayerPainter.java b/src/ch/epfl/xblast/server/painter/PlayerPainter.java index a366918..79b954c 100644 --- a/src/ch/epfl/xblast/server/painter/PlayerPainter.java +++ b/src/ch/epfl/xblast/server/painter/PlayerPainter.java @@ -16,6 +16,8 @@ public final class PlayerPainter { private static final byte DYING_IMAGE_ID = 12; private static final byte LAST_DYING_IMAGE_ID = 13; + private static final int BLANK_PLAYER_GROUP = 4; + private static final int PLAYER_MULTIPLIER = 20; private static final int DIRECTION_MULTIPLIER = 3; @@ -52,6 +54,15 @@ public final class PlayerPainter { return (byte) (pid.ordinal() * PLAYER_MULTIPLIER); } + /** + * Returns the player image byte for the blank player. + * + * @return the image byte for the player + */ + private static byte byteForPlayerID() { + return (byte) (BLANK_PLAYER_GROUP * PLAYER_MULTIPLIER); + } + /** * Returns the image ID for the dying state according to the number of remaining lives. * @@ -78,6 +89,12 @@ public final class PlayerPainter { return (byte) (byteForPlayerID(player.id()) + byteForDyingState(player.lives())); + case INVULNERABLE: + if (tick % 2 == 1) + return (byte) (byteForPlayerID() + + byteForDirection(player.direction()) + + byteForFrame(tick)); + default: return (byte) (byteForPlayerID(player.id()) + byteForDirection(player.direction()) -- cgit v1.2.3