diff --git a/common.mk b/common.mk index b1cceb2..ee22f89 100644 --- a/common.mk +++ b/common.mk @@ -8,6 +8,7 @@ vpath %.h $(SEARCHPATH) DEPS += defs.h structs.h +OBJS += atlas.o OBJS += camera.o combat.o OBJS += draw.o OBJS += effects.o entities.o explosions.o diff --git a/src/structs.h b/src/structs.h index 4157c75..6e70c57 100644 --- a/src/structs.h +++ b/src/structs.h @@ -30,6 +30,7 @@ typedef struct Sprite Sprite; typedef struct Tuple Tuple; typedef struct HubMission HubMission; typedef struct Widget Widget; +typedef struct Atlas Atlas; typedef struct { int debug; @@ -313,3 +314,9 @@ struct Widget { int clicked; Widget *next; }; + +struct Atlas { + char filename[MAX_FILENAME_LENGTH]; + SDL_Rect rect; + Atlas *next; +}; diff --git a/src/system/atlas.c b/src/system/atlas.c new file mode 100644 index 0000000..a8e89a4 --- /dev/null +++ b/src/system/atlas.c @@ -0,0 +1,78 @@ +/* +Copyright (C) 2018 Parallel Realities + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "atlas.h" + +static void loadAtlasTexture(void); +static void loadAtlasData(void); + +static Atlas atlasHead; +static Atlas *atlasTail; +/* +static Texture atlasTexture; +static int atlasSize; +*/ + +void initAtlas(void) +{ + memset(&atlasHead, 0, sizeof(Atlas)); + atlasTail = &atlasHead; + + loadAtlasTexture(); + + loadAtlasData(); +} + +Atlas *getImageFromAtlas(char *filename) +{ + Atlas *a; + + for (a = atlasHead.next ; a != NULL ; a = a->next) + { + if (strcmp(a->filename, filename) == 0) + { + return a; + } + } + + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_ERROR, "No such atlas image '%s'", filename); + exit(1); +} + +static void loadAtlasTexture(void) +{ + +} + +static void loadAtlasData(void) +{ + +} + +void loadImageData(cJSON *root) +{ + +} + +void createRectangle(char *filename, int x, int y, int w, int h) +{ + +} + diff --git a/src/system/atlas.h b/src/system/atlas.h new file mode 100644 index 0000000..ce513f6 --- /dev/null +++ b/src/system/atlas.h @@ -0,0 +1,22 @@ +/* +Copyright (C) 2018 Parallel Realities + +This program is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +*/ + +#include "../common.h" +#include "../json/cJSON.h"