6#ifndef BOMBERMAN_SCENES_MULTIPLAYERLEVELSCENEINTERNAL_H
7#define BOMBERMAN_SCENES_MULTIPLAYERLEVELSCENEINTERNAL_H
15#include "Core/Animation.h"
16#include "Entities/Sprite.h"
21#include "Util/PlayerColors.h"
23namespace bomberman::multiplayer_level_scene_internal
27 "Player color table must cover all supported multiplayer player ids");
31 inline constexpr int kMovementDeltaThresholdQ = 2;
32 inline constexpr int kNameTagOffsetPx = 6;
33 inline constexpr int kNameTagMinPointSize = 12;
34 inline constexpr int kNameTagMaxPointSize = 20;
36 inline constexpr int kGameplayStatusOffsetY = 12;
37 inline constexpr int kDebugHudOffsetX = 12;
38 inline constexpr int kDebugHudOffsetY = 12;
39 inline constexpr int kDebugHudPointSize = 12;
40 inline constexpr int kDebugHudLineGapPx = 4;
41 inline constexpr uint32_t kDebugHudRefreshIntervalMs = 250;
42 inline constexpr int kCenterBannerPointSize = 56;
43 inline constexpr int kCenterBannerDetailPointSize = 40;
44 inline constexpr int kCenterBannerLineGapPx = 10;
45 inline constexpr uint32_t kCenterBannerDurationTicks =
static_cast<uint32_t
>(
sim::kTickRate);
46 inline constexpr uint32_t kLivePredictionLogIntervalMs = 1000;
47 inline constexpr uint32_t kSimulationTickMs = 1000u /
static_cast<uint32_t
>(
sim::kTickRate);
48 inline constexpr uint32_t kPreStartReturnTimeoutMs = 7000;
49 inline constexpr uint32_t kPowerupBlinkIntervalMs = 140;
50 inline constexpr int kBombAnimationFrameCount = 4;
51 inline constexpr int kBombSparkAnimationFrameCount = 5;
52 inline constexpr int kBombSparkFrameSizePx = 32;
53 inline constexpr uint32_t kBombSparkAnimationIntervalMs = 50;
54 inline constexpr uint32_t kBombSparkLifetimeMs = 250;
57 inline constexpr int kBoostedBombExtraPx = 4;
58 inline constexpr int kExplosionAnimationStartFrame = 1;
59 inline constexpr int kExplosionAnimationFrameCount = 11;
60 inline constexpr uint32_t kExplosionLifetimeMs = 800;
66 constexpr uint16_t
packCellKey(
const uint8_t col,
const uint8_t row)
68 return static_cast<uint16_t
>((
static_cast<uint16_t
>(row) << 8u) |
static_cast<uint16_t
>(col));
79 auto animation = std::make_shared<Animation>();
80 for (
int frame = 0; frame < kBombAnimationFrameCount; ++frame)
85 animation->setSprite(bombSprite.get());
86 bombSprite->addAnimation(animation);
98 auto animation = std::make_shared<Animation>();
99 for (
int frame = 0; frame < kExplosionAnimationFrameCount; ++frame)
101 animation->addAnimationEntity(
105 animation->setSprite(explosionSprite.get());
106 explosionSprite->addAnimation(animation);
115 if (!bombSparkSprite)
118 auto animation = std::make_shared<Animation>();
119 animation->setAnimationInterval(kBombSparkAnimationIntervalMs);
120 for (
int frame = 0; frame < kBombSparkAnimationFrameCount; ++frame)
122 animation->addAnimationEntity(
AnimationEntity(kBombSparkFrameSizePx * frame,
124 kBombSparkFrameSizePx,
125 kBombSparkFrameSizePx));
128 animation->setSprite(bombSparkSprite.get());
129 bombSparkSprite->addAnimation(animation);
136 const auto flags =
static_cast<uint8_t
>(entry.
flags);
141 inline bool snapshotEntryInputLocked(
const net::MsgSnapshot::PlayerEntry& entry)
143 const auto flags =
static_cast<uint8_t
>(entry.flags);
148 inline bool snapshotEntryInvulnerable(
const net::MsgSnapshot::PlayerEntry& entry)
150 const auto flags =
static_cast<uint8_t
>(entry.flags);
155 inline bool snapshotEntryBombRangeBoost(
const net::MsgSnapshot::PlayerEntry& entry)
157 const auto flags =
static_cast<uint8_t
>(entry.flags);
162 inline bool snapshotEntryMaxBombsBoost(
const net::MsgSnapshot::PlayerEntry& entry)
164 const auto flags =
static_cast<uint8_t
>(entry.flags);
169 inline bool snapshotEntrySpeedBoost(
const net::MsgSnapshot::PlayerEntry& entry)
171 const auto flags =
static_cast<uint8_t
>(entry.flags);
181 const MovementDirection fallback)
183 const int absDx = std::abs(dxQ);
184 const int absDy = std::abs(dyQ);
186 if (absDx < kMovementDeltaThresholdQ && absDy < kMovementDeltaThresholdQ)
190 return dxQ >= 0 ? MovementDirection::Right : MovementDirection::Left;
192 return dyQ >= 0 ? MovementDirection::Down : MovementDirection::Up;
201 return std::clamp(scaledTileSize / 3, kNameTagMinPointSize, kNameTagMaxPointSize);
213 if (moveX == 0 && moveY == 0)
214 return MovementDirection::None;
217 return moveX > 0 ? MovementDirection::Right : MovementDirection::Left;
219 return moveY > 0 ? MovementDirection::Down : MovementDirection::Up;
Game-world configuration constants.
constexpr unsigned int tileSize
Source sprite size in pixels (not scaled render size).
Definition Const.h:45
void attachBombAnimation(const std::shared_ptr< Sprite > &bombSprite)
Attach the looping bomb animation.
Definition MultiplayerLevelSceneInternal.h:74
void attachExplosionAnimation(const std::shared_ptr< Sprite > &explosionSprite)
Attach the explosion animation.
Definition MultiplayerLevelSceneInternal.h:93
constexpr uint32_t kGameplayDegradedThresholdMs
Silence window before gameplay is marked degraded.
Definition MultiplayerLevelSceneInternal.h:35
constexpr uint32_t kPendingLocalBombPlacementLifetimeMs
Lifetime of a pending local bomb reservation.
Definition MultiplayerLevelSceneInternal.h:55
MovementDirection inferDirectionFromDelta(const int dxQ, const int dyQ, const MovementDirection fallback)
Infer visible facing from position delta.
Definition MultiplayerLevelSceneInternal.h:179
int computeTagPointSize(const int scaledTileSize)
Derive a readable player-tag size from the current tile size.
Definition MultiplayerLevelSceneInternal.h:199
void attachBombSparkAnimation(const std::shared_ptr< Sprite > &bombSparkSprite)
Attach the short local bomb spark animation.
Definition MultiplayerLevelSceneInternal.h:113
MovementDirection inferDirectionFromButtons(const uint8_t buttons)
Infer facing directly from queued input buttons.
Definition MultiplayerLevelSceneInternal.h:208
constexpr uint16_t packCellKey(const uint8_t col, const uint8_t row)
Pack a tile coordinate into one map key.
Definition MultiplayerLevelSceneInternal.h:66
Multiplayer gameplay scene interface.
Shared client/server wire contract for the multiplayer protocol.
Shared simulation tuning constants used by client and server gameplay code.
Shared default multiplayer spawn slots.
constexpr int8_t buttonsToMoveY(uint8_t buttons)
Derives vertical movement {-1, 0, 1} from a button bitmask.
Definition NetCommon.h:90
constexpr int8_t buttonsToMoveX(uint8_t buttons)
Derives horizontal movement {-1, 0, 1} from a button bitmask.
Definition NetCommon.h:81
constexpr uint8_t kMaxPlayers
Maximum supported player count in a game instance.
Definition NetCommon.h:54
constexpr uint32_t kDefaultBombFuseTicks
Default authoritative bomb fuse in simulation ticks.
Definition SimConfig.h:23
constexpr std::array< SpawnSlotCell, 4 > kDefaultSpawnSlots
Default player-id keyed spawn slots for the current arena layout.
Definition SpawnSlots.h:36
constexpr int16_t kTickRate
Simulation tick rate in Hz.
Definition SimConfig.h:14
Animation part for clipping.
Definition Animation.h:14
Definition NetCommon.h:681
EPlayerFlags flags
Player alive status and other state flags.
Definition NetCommon.h:705
@ Invulnerable
Player is invulnerable if set.
@ Alive
Player is alive if set, dead if unset.
@ MaxBombsBoost
Player currently has the max-bombs boost active.
@ BombRangeBoost
Player currently has the bomb-range boost active.
@ SpeedBoost
Player currently has the speed boost active.
@ InputLocked
Player input/movement is server-locked if set.