diff options
author | Pacien TRAN-GIRARD | 2016-05-12 15:04:55 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2016-05-12 15:05:33 +0200 |
commit | 8fb64e8969f093c896ad9b5e327738e82941d30c (patch) | |
tree | 39288f1f0df05d3d200735e5f833ac96411912c0 /src/ch | |
parent | c095405dd09105be86a25987e3607be10fb12647 (diff) | |
download | xblast-8fb64e8969f093c896ad9b5e327738e82941d30c.tar.gz |
Properly handle invulnerability state image
Diffstat (limited to 'src/ch')
-rw-r--r-- | src/ch/epfl/xblast/server/painter/PlayerPainter.java | 17 |
1 files changed, 17 insertions, 0 deletions
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 { | |||
16 | private static final byte DYING_IMAGE_ID = 12; | 16 | private static final byte DYING_IMAGE_ID = 12; |
17 | private static final byte LAST_DYING_IMAGE_ID = 13; | 17 | private static final byte LAST_DYING_IMAGE_ID = 13; |
18 | 18 | ||
19 | private static final int BLANK_PLAYER_GROUP = 4; | ||
20 | |||
19 | private static final int PLAYER_MULTIPLIER = 20; | 21 | private static final int PLAYER_MULTIPLIER = 20; |
20 | private static final int DIRECTION_MULTIPLIER = 3; | 22 | private static final int DIRECTION_MULTIPLIER = 3; |
21 | 23 | ||
@@ -53,6 +55,15 @@ public final class PlayerPainter { | |||
53 | } | 55 | } |
54 | 56 | ||
55 | /** | 57 | /** |
58 | * Returns the player image byte for the blank player. | ||
59 | * | ||
60 | * @return the image byte for the player | ||
61 | */ | ||
62 | private static byte byteForPlayerID() { | ||
63 | return (byte) (BLANK_PLAYER_GROUP * PLAYER_MULTIPLIER); | ||
64 | } | ||
65 | |||
66 | /** | ||
56 | * Returns the image ID for the dying state according to the number of remaining lives. | 67 | * Returns the image ID for the dying state according to the number of remaining lives. |
57 | * | 68 | * |
58 | * @param lives the number of remaining lives | 69 | * @param lives the number of remaining lives |
@@ -78,6 +89,12 @@ public final class PlayerPainter { | |||
78 | return (byte) (byteForPlayerID(player.id()) | 89 | return (byte) (byteForPlayerID(player.id()) |
79 | + byteForDyingState(player.lives())); | 90 | + byteForDyingState(player.lives())); |
80 | 91 | ||
92 | case INVULNERABLE: | ||
93 | if (tick % 2 == 1) | ||
94 | return (byte) (byteForPlayerID() | ||
95 | + byteForDirection(player.direction()) | ||
96 | + byteForFrame(tick)); | ||
97 | |||
81 | default: | 98 | default: |
82 | return (byte) (byteForPlayerID(player.id()) | 99 | return (byte) (byteForPlayerID(player.id()) |
83 | + byteForDirection(player.direction()) | 100 | + byteForDirection(player.direction()) |