Load meta information.
This commit is contained in:
parent
118b570484
commit
fc542ecd82
|
@ -20,13 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
#include "game.h"
|
||||
|
||||
/*
|
||||
public Map<String, MissionStatus> missionStatuses;
|
||||
|
||||
public List<String> mias;
|
||||
public List<String> targets;
|
||||
public Map<String, AtomicInteger> keys;
|
||||
*/
|
||||
static void loadMetaInfo(void);
|
||||
|
||||
void initGame(void)
|
||||
{
|
||||
|
@ -36,6 +30,8 @@ void initGame(void)
|
|||
game.hearts = 10;
|
||||
|
||||
game.timePlayed = 0;
|
||||
|
||||
loadMetaInfo();
|
||||
}
|
||||
|
||||
void addRescuedMIA(char *name)
|
||||
|
@ -85,6 +81,28 @@ void removeItem(char *name)
|
|||
{
|
||||
}
|
||||
|
||||
static void loadMetaInfo(void)
|
||||
{
|
||||
cJSON *root;
|
||||
char *text;
|
||||
|
||||
text = readFile("data/meta/meta.json");
|
||||
|
||||
root = cJSON_Parse(text);
|
||||
|
||||
game.totalKeys = cJSON_GetObjectItem(root, "totalKeys")->valueint;
|
||||
game.totalTargets = cJSON_GetObjectItem(root, "totalTargets")->valueint;
|
||||
game.totalMIAs = cJSON_GetObjectItem(root, "totalMIAs")->valueint;
|
||||
game.totalHearts = cJSON_GetObjectItem(root, "totalHearts")->valueint;
|
||||
game.totalCells = cJSON_GetObjectItem(root, "totalCells")->valueint;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Meta [keys=%d, targets=%d, mias=%d, hearts=%d, cells=%d]", game.totalKeys, game.totalTargets, game.totalMIAs, game.totalHearts, game.totalCells);
|
||||
|
||||
cJSON_Delete(root);
|
||||
|
||||
free(text);
|
||||
}
|
||||
|
||||
void destroyGame(void)
|
||||
{
|
||||
}
|
||||
|
|
|
@ -19,5 +19,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
*/
|
||||
|
||||
#include "../common.h"
|
||||
#include "../json/cJSON.h"
|
||||
|
||||
extern char *readFile(const char *filename);
|
||||
|
||||
extern Game game;
|
||||
|
|
|
@ -28,6 +28,8 @@ static Texture *atlasTexture;
|
|||
|
||||
void initAtlasTest(void)
|
||||
{
|
||||
initGame();
|
||||
|
||||
app.delegate.logic = &logic;
|
||||
app.delegate.draw = &draw;
|
||||
|
||||
|
|
|
@ -24,5 +24,6 @@ extern Atlas *getImageFromAtlas(char *filename);
|
|||
extern Texture *getTexture(const char *filename);
|
||||
extern void blitRect(SDL_Texture *texture, int x, int y, SDL_Rect *srcRect, int center);
|
||||
extern void loadMapData(char *filename);
|
||||
extern void initGame(void);
|
||||
|
||||
extern App app;
|
||||
|
|
Loading…
Reference in New Issue