22 #define FISH_TILE(fish) ((fish) > 0 ? (fish) : 0)
23 #define PENGUIN_TILE(player_id) ((player_id) > 0 ? -(player_id) : 0)
24 #define is_water_tile(tile) ((tile) == 0)
25 #define is_fish_tile(tile) ((tile) > 0)
26 #define is_penguin_tile(tile) ((tile) < 0)
27 #define get_tile_fish(tile) ((tile) > 0 ? (tile) : 0)
28 #define get_tile_player_id(tile) ((tile) < 0 ? -(tile) : 0)
71 int x = coords.
x, y = coords.
y;
void generate_board_random(Game *game, Rng *rng)
Generates the board by setting every tile purely randomly. The resulting board will look sort of like...
void generate_board_island(Game *game, Rng *rng)
Generates the board which looks sort of like a big icy island.
TileAttribute
The list of attributes built into the common library.
@ TILE_DIRTY
Set when a tile is changed with set_tile, can be unset by the UI. All tiles initially have this attri...
The core of the unified game logic library, contains the Game struct.
A pair of 2D coordinates, used for addressing the Game::board_grid.
The central struct of the application, holds the game data and settings.
ALWAYS_INLINE void set_all_tiles_attr(Game *game, short attr, bool value)
Sets the attribute attr on all tiles.
ALWAYS_INLINE bool is_tile_in_bounds(const Game *game, Coords coords)
Checks if the given coords are within the bounds of the board.
ALWAYS_INLINE void set_tile(Game *game, Coords coords, short value)
Sets the value of the tile at coords (and also sets the attribute TILE_DIRTY). Fails if coords are ou...
ALWAYS_INLINE short get_tile(const Game *game, Coords coords)
Returns the value of the tile at coords. Fails if coords are outside the bounds.
int board_width
Use setup_board for setting this.
void setup_board(Game *game, int width, int height)
Sets Game::board_width and Game::board_height and allocates Game::board_grid and Game::tile_attribute...
short * tile_attributes
Stores auxilary data of grid tiles for use in the UIs. Use setup_board for initializing,...
short * board_grid
A 2D grid represented as a 1D array which stores the tiles of the board. Use setup_board for initiali...
ALWAYS_INLINE bool get_tile_attr(const Game *game, Coords coords, short attr)
Checks whether the attribute attr of the tile at coords is set.
int board_height
Use setup_board for setting this.
ALWAYS_INLINE void set_tile_attr(Game *game, Coords coords, short attr, bool value)
Sets (or resets) the attribute attr of the tile at coords.
A wrapper around random number generators.
#define change_bit(num, bit, val)
#define ALWAYS_INLINE
Strongly suggests to the compiler that a function should be inlined.
#define test_bit(num, bit)