1#ifndef BOMBERMAN_SIM_MOVEMENT_H
2#define BOMBERMAN_SIM_MOVEMENT_H
48 if (col < 0 || row < 0 ||
55 const Tile t = map[row][col];
56 return t != Tile::Stone && t != Tile::Brick;
87 pos.xQ += moveX * speedQ;
88 pos.yQ += moveY * speedQ;
114 const int32_t newXQ = pos.xQ + moveX * speedQ;
122 const int32_t newYQ = pos.yQ + moveY * speedQ;
142 inline int tileQToScreen(int32_t tileQ,
int fieldPx,
int scaledTile,
int cameraPx)
144 return fieldPx + (tileQ * scaledTile / 256) - cameraPx;
162 return fieldPx + ((tileQ - 128) * scaledTile / 256) - cameraPx;
Game-world configuration constants.
constexpr unsigned int tileArrayWidth
Tile map width in tiles.
Definition Const.h:43
constexpr unsigned int tileArrayHeight
Tile map height in tiles.
Definition Const.h:44
Tile
Tile type identifiers used in the tile map.
Definition Const.h:13
Shared simulation tuning constants used by client and server gameplay code.
Shared simulation primitives and constants used by both the client and the authoritative server.
Definition Movement.h:21
constexpr double kPlayerSpeedTilesPerSecond
Player movement speed in tiles per second.
Definition SimConfig.h:26
TilePos stepMovementWithCollision(TilePos pos, int8_t moveX, int8_t moveY, const TileMap &map, int32_t speedQ=kPlayerSpeedQ)
Advances a position by one tick with tile-map collision.
Definition Movement.h:105
bool overlapsWall(const TileMap &map, int32_t xQ, int32_t yQ)
Returns true if the AABB centered at (xQ, yQ) with half-extent kHitboxHalfQ overlaps any solid tile.
Definition Movement.h:63
bool isWalkable(const TileMap &map, int col, int row)
Returns true if the given tile coordinate is passable.
Definition Movement.h:45
constexpr int32_t kHitboxHalfQ
Player hitbox half-extent in tile-Q8 units.
Definition Movement.h:26
int tileQToScreenTopLeft(int32_t tileQ, int fieldPx, int scaledTile, int cameraPx)
Converts a center tile-Q8 coordinate to the screen top-left pixel for sprite rendering.
Definition Movement.h:160
constexpr float kPlayerHitboxScale
Player hitbox size as a fraction of the tile size.
Definition SimConfig.h:33
constexpr int32_t kPlayerSpeedQ
Player movement speed in tile-Q8 units per simulation tick.
Definition Movement.h:23
Tile[tileArrayHeight][tileArrayWidth] TileMap
Read-only view of a runtime tile map (same layout as LevelScene::tiles).
Definition Movement.h:36
int tileQToScreen(int32_t tileQ, int fieldPx, int scaledTile, int cameraPx)
Converts a center tile-Q8 coordinate to the screen pixel at that center.
Definition Movement.h:142
constexpr int16_t kTickRate
Simulation tick rate in Hz.
Definition SimConfig.h:14
TilePos stepMovement(TilePos pos, int8_t moveX, int8_t moveY, int32_t speedQ=kPlayerSpeedQ)
Advances a position by one simulation tick given a directional input.
Definition Movement.h:85
Tile-space Q8 position representing the CENTER of the entity.
Definition Movement.h:30