mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2024-06-16 17:48:29 +02:00
There's really no need to put the y-multiplication in a lookup table. The compiler will optimize the multiplication better than putting it in a lookup table will. To improve readability and to hardcode things less, the new SCREEN_WIDTH_TILES and SCREEN_HEIGHT_TILES constant names are used, as well as adding a new TILE_IDX macro to calculate the index of a tile in a concatenated-rows (row-major in formal parlance) array. Also, tile numbers are stored in a temporary variable to improve readability as well (no more copy-pasting `contents[i + vmult[j]]` over and over again).
21 lines
485 B
C
21 lines
485 B
C
#ifndef CONSTANTS_H
|
|
#define CONSTANTS_H
|
|
|
|
/*
|
|
* FIXME: These should be used everywhere...
|
|
* FIXME: This should include more constants!
|
|
*/
|
|
|
|
#define SCREEN_WIDTH_TILES 40
|
|
#define SCREEN_HEIGHT_TILES 30
|
|
|
|
#define SCREEN_WIDTH_PIXELS (SCREEN_WIDTH_TILES * 8)
|
|
#define SCREEN_HEIGHT_PIXELS (SCREEN_WIDTH_TILES * 8)
|
|
|
|
#define TILE_IDX(x, y) (x + y * SCREEN_WIDTH_TILES)
|
|
|
|
/* 4 bytes per char, for UTF-8 encoding. */
|
|
#define SCREEN_WIDTH_CHARS (SCREEN_WIDTH_TILES * 4)
|
|
|
|
#endif /* CONSTANTS_H */
|