diff options
Diffstat (limited to 'src/include')
-rw-r--r-- | src/include/data_ini.h | 9 | ||||
-rw-r--r-- | src/include/data_ress.h | 30 | ||||
-rw-r--r-- | src/include/loader.h | 10 | ||||
-rw-r--r-- | src/include/utils.h | 9 |
4 files changed, 54 insertions, 4 deletions
diff --git a/src/include/data_ini.h b/src/include/data_ini.h index 9b14899..06b1c47 100644 --- a/src/include/data_ini.h +++ b/src/include/data_ini.h @@ -3,9 +3,8 @@ #include <SDL_stdinc.h> -// Original game level size is fixed to 1664x160. We want to display all the game with a x2 zoom -#define LEVEL_WIDTH 1664*2 -#define LEVEL_HEIGHT 160*2 +#define LEVEL_WIDTH 1664 +#define LEVEL_HEIGHT 160 #define MAX_NAMELEN 64 @@ -16,6 +15,9 @@ #define MAX_TERRAINS_COUNT 1024 #define MAX_STEELS_COUNT 256 +#define MAX_TILES_COUNT 128 +#define MAX_SOUNDS_COUNT 24 +#define MAX_LEMMANIM_COUNT 17 //////////////////////// LEVEL INI FILES //////////////////////// // Item should be an object, terrain or steel @@ -52,7 +54,6 @@ struct levelPackIni { //////////////////////// STYLE INI FILES //////////////////////// struct styleIni { - char name[MAX_NAMELEN]; uint32_t bgColor, debrisColor; int tiles, particleColorCount; uint32_t particleColor[MAX_PARTICLE_COLORS]; diff --git a/src/include/data_ress.h b/src/include/data_ress.h new file mode 100644 index 0000000..1b8bba7 --- /dev/null +++ b/src/include/data_ress.h @@ -0,0 +1,30 @@ +#ifndef DATA_RESS_H +#define DATA_RESS_H + +#include <SDL.h> /* SDL_texture def */ +#include <SDL_mixer.h> /* Mix_Chunk and Mix_Music defs */ +#include "data_ini.h" /* For MAX_* macros */ + +typedef struct { + SDL_Texture *t; + SDL_Rect size; + /* int frames; Already in gIni->style->frames, but convenient here also */ +} sprite_t; + +typedef struct { + /* Style */ + sprite_t tiles[MAX_TILES_COUNT]; + sprite_t objects[MAX_OBJECTS_COUNT]; + sprite_t objectMasks[MAX_OBJECTS_COUNT]; + /* Misc */ + sprite_t lemmingAnims[MAX_LEMMANIM_COUNT]; + sprite_t lemmingMasks[MAX_LEMMANIM_COUNT]; + sprite_t lemmingImask[MAX_LEMMANIM_COUNT]; + sprite_t font1, font2, countdown, cursor; + /* Music */ + Mix_Music *musics[MAX_MUSICS_COUNT]; + /* Sound */ + Mix_Chunk *sounds[MAX_SOUNDS_COUNT]; +} gameRess_t; + +#endif /*DATA_RESS_H*/ diff --git a/src/include/loader.h b/src/include/loader.h new file mode 100644 index 0000000..adf8777 --- /dev/null +++ b/src/include/loader.h @@ -0,0 +1,10 @@ +#ifndef LOADER_H +#define LOADER_H + +#include "data_ini.h" +#include "data_ress.h" + +// Load all textures needed for style and level from gIni +int loadRessources(gameIni_t *gIni, char databasepath[], gameRess_t *gRess); + +#endif /*LOADER_H*/ diff --git a/src/include/utils.h b/src/include/utils.h new file mode 100644 index 0000000..f0af3d0 --- /dev/null +++ b/src/include/utils.h @@ -0,0 +1,9 @@ + +/* Macro for error checking and logging */ +#define mpl_check(expr, fail_code, priority, ...) \ + if (! (expr)) { \ + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,priority,__VA_ARGS__); \ + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION,priority, \ + "-> last SDL error : %s\n", SDL_GetError()); \ + fail_code; \ + } |