Start of fighter database.

This commit is contained in:
Steve 2017-08-07 19:14:43 +01:00
parent ca64978d20
commit 41ce0e2281
53 changed files with 261 additions and 14 deletions

View File

@ -13,7 +13,7 @@ OBJS += battle.o bullets.o
OBJS += capitalShips.o challengeHome.o challenges.o cJSON.o controls.o credits.o
OBJS += debris.o dev.o draw.o
OBJS += effects.o entities.o
OBJS += fighters.o
OBJS += fighters.o fighterDatabase.o
OBJS += galacticMap.o game.o
OBJS += hud.o
OBJS += i18n.o init.o input.o io.o items.o

View File

@ -1,5 +1,6 @@
{
"name" : "Civilian",
"description" : "",
"health" : 15,
"speed" : 1.85,
"texture" : "gfx/craft/civilian01.png",

View File

@ -1,5 +1,6 @@
{
"name" : "INF Tug",
"description" : "TODO",
"health" : 50,
"speed" : 1.85,
"reloadTime" : 10,

View File

@ -1,5 +1,6 @@
{
"name" : "Munitions Transport",
"description" : "TODO",
"health" : 150,
"shield" : 50,
"speed" : 1.5,

View File

@ -1,5 +1,6 @@
{
"name" : "Shuttle",
"description" : "TODO",
"health" : 15,
"shield" : 15,
"speed" : 2,

View File

@ -1,5 +1,6 @@
{
"name" : "Supply Ship",
"description" : "TODO",
"health" : 150,
"shield" : 50,
"speed" : 1.5,

View File

@ -1,5 +1,6 @@
{
"name" : "Tug",
"description" : "TODO",
"health" : 50,
"speed" : 1.85,
"reloadTime" : 10,

View File

@ -1,5 +1,6 @@
{
"name" : "Angel",
"description" : "TODO",
"health" : 40,
"shield" : 40,
"speed" : 1.8,

View File

@ -1,5 +1,6 @@
{
"name" : "ATAF",
"description" : "TODO",
"health" : 150,
"shield" : 2500,
"speed" : 2.25,

View File

@ -1,5 +1,6 @@
{
"name" : "Blizzard",
"description" : "TODO",
"health" : 120,
"shield" : 70,
"speed" : 1.85,

View File

@ -1,5 +1,6 @@
{
"name" : "Cannon Dart",
"description" : "",
"health" : 15,
"speed" : 2.1,
"reloadTime" : 24,

View File

@ -1,5 +1,6 @@
{
"name" : "Dart",
"description" : "TODO",
"health" : 15,
"speed" : 2.1,
"reloadTime" : 24,

View File

@ -1,5 +1,6 @@
{
"name" : "Firefly",
"description" : "TODO",
"health" : 50,
"shield" : 50,
"speed" : 1.85,

View File

@ -1,5 +1,6 @@
{
"name" : "Hammerhead",
"description" : "TODO",
"health" : 60,
"shield" : 50,
"speed" : 1.7,

View File

@ -1,5 +1,6 @@
{
"name" : "Hyena-A",
"description" : "TODO",
"health" : 90,
"shield" : 45,
"speed" : 1.85,

View File

@ -1,5 +1,6 @@
{
"name" : "Hyena-B",
"description" : "TODO",
"health" : 90,
"shield" : 45,
"speed" : 1.85,

View File

@ -1,5 +1,6 @@
{
"name" : "Jackal",
"description" : "TODO",
"health" : 75,
"shield" : 75,
"speed" : 2,

View File

@ -1,5 +1,6 @@
{
"name" : "Khepri",
"description" : "TODO",
"health" : 60,
"shield" : 50,
"speed" : 1.7,

View File

@ -1,5 +1,6 @@
{
"name" : "Kingfisher",
"description" : "TODO",
"health" : 65,
"shield" : 65,
"speed" : 1.85,

View File

@ -1,5 +1,6 @@
{
"name" : "Leopard",
"description" : "TODO",
"health" : 125,
"shield" : 75,
"speed" : 1.7,

View File

@ -1,5 +1,6 @@
{
"name" : "Lynx",
"description" : "TODO",
"health" : 75,
"shield" : 50,
"speed" : 1.7,

View File

@ -1,5 +1,6 @@
{
"name" : "Mantis",
"description" : "TODO",
"health" : 50,
"shield" : 75,
"speed" : 1.85,

View File

@ -1,5 +1,6 @@
{
"name" : "Missile Dart",
"description" : "",
"health" : 15,
"speed" : 2.1,
"reloadTime" : 24,

View File

@ -1,5 +1,6 @@
{
"name" : "Nymph",
"description" : "TODO",
"health" : 45,
"shield" : 40,
"speed" : 2,

View File

@ -1,5 +1,6 @@
{
"name" : "Ray",
"description" : "TODO",
"health" : 70,
"shield" : 70,
"speed" : 1.85,

View File

@ -1,5 +1,6 @@
{
"name" : "Razor",
"description" : "TODO",
"health" : 45,
"shield" : 55,
"speed" : 1.75,

View File

@ -1,5 +1,6 @@
{
"name" : "Rocket Dart",
"description" : "",
"health" : 15,
"speed" : 2.1,
"reloadTime" : 35,

View File

@ -1,5 +1,6 @@
{
"name" : "Rook",
"description" : "TODO",
"health" : 110,
"shield" : 80,
"speed" : 1.7,

View File

@ -1,5 +1,6 @@
{
"name" : "Scarab",
"description" : "TODO",
"health" : 80,
"shield" : 65,
"speed" : 1.7,

View File

@ -1,5 +1,6 @@
{
"name" : "Shale",
"description" : "TODO",
"health" : 50,
"shield" : 50,
"speed" : 2,

View File

@ -1,5 +1,6 @@
{
"name" : "Simple Dart",
"description" : "",
"health" : 15,
"speed" : 2.1,
"reloadTime" : 24,

View File

@ -1,5 +1,6 @@
{
"name" : "SK-31",
"description" : "TODO",
"health" : 85,
"shield" : 50,
"speed" : 1.8,

View File

@ -1,5 +1,6 @@
{
"name" : "SK-34",
"description" : "TODO",
"health" : 100,
"shield" : 45,
"speed" : 1.7,

View File

@ -1,5 +1,6 @@
{
"name" : "Sphinx",
"description" : "TODO",
"health" : 110,
"shield" : 75,
"speed" : 1.85,

View File

@ -1,5 +1,6 @@
{
"name" : "Static Dart",
"description" : "",
"health" : 15,
"speed" : 0,
"reloadTime" : 24,

View File

@ -1,5 +1,6 @@
{
"name" : "Swarmer",
"description" : "TODO",
"health" : 5,
"speed" : 2,
"reloadTime" : 8,

View File

@ -1,5 +1,6 @@
{
"name" : "TAF",
"description" : "TODO",
"health" : 35,
"shield" : 35,
"speed" : 2,

View File

@ -1,5 +1,6 @@
{
"name" : "Thunderhead",
"description" : "TODO",
"health" : 90,
"shield" : 65,
"speed" : 1.7,

View File

@ -1,5 +1,6 @@
{
"name" : "Unarmed Dart",
"description" : "",
"health" : 15,
"speed" : 2.1,
"reloadTime" : 24,

View File

@ -1,5 +1,6 @@
{
"name" : "Unique Sphinx",
"description" : "",
"health" : 999,
"shield" : 999,
"speed" : 1.6,

View File

@ -1,5 +1,6 @@
{
"name" : "Plasma Turret",
"description" : "TODO",
"health" : 150,
"shield" : 25,
"speed" : 0,

View File

@ -1,5 +1,6 @@
{
"name" : "Rapid Plasma Turret",
"description" : "",
"health" : 150,
"shield" : 25,
"speed" : 0,

View File

@ -1,5 +1,6 @@
{
"name" : "Rocket Turret",
"description" : "TODO",
"health" : 125,
"shield" : 25,
"speed" : 0,

View File

@ -0,0 +1,32 @@
[
{
"name" : "prev",
"group" : "fighterDB",
"type" : "WT_IMG_BUTTON",
"x" : 540,
"y" : 110,
"w" : 150,
"h": 34,
"texture" : "gfx/widgets/optionsLeft.png"
},
{
"name" : "next",
"group" : "fighterDB",
"type" : "WT_IMG_BUTTON",
"x" : 720,
"y" : 110,
"w" : 150,
"h": 34,
"texture" : "gfx/widgets/optionsRight.png"
},
{
"name" : "ok",
"group" : "fighterDB",
"type" : "WT_BUTTON",
"text" : "OK",
"x" : 640,
"y" : 635,
"w" : 150,
"h": 34
}
]

View File

@ -15,7 +15,7 @@
"type" : "WT_BUTTON",
"text" : "Challenges",
"x" : -1,
"y" : 280,
"y" : 260,
"w" : 200,
"h": 34
},
@ -25,7 +25,7 @@
"type" : "WT_BUTTON",
"text" : "Trophies",
"x" : -1,
"y" : 360,
"y" : 320,
"w" : 200,
"h": 34
},
@ -35,6 +35,16 @@
"type" : "WT_BUTTON",
"text" : "Stats",
"x" : -1,
"y" : 380,
"w" : 200,
"h": 34
},
{
"name" : "fighterDB",
"group" : "title",
"type" : "WT_BUTTON",
"text" : "Fighter Database",
"x" : -1,
"y" : 440,
"w" : 200,
"h": 34
@ -45,7 +55,7 @@
"type" : "WT_BUTTON",
"text" : "Options",
"x" : -1,
"y" : 520,
"y" : 500,
"w" : 200,
"h": 34
},
@ -55,7 +65,7 @@
"type" : "WT_BUTTON",
"text" : "Credits",
"x" : -1,
"y" : 600,
"y" : 560,
"w" : 200,
"h": 34
},
@ -65,7 +75,7 @@
"type" : "WT_BUTTON",
"text" : "Quit",
"x" : -1,
"y" : 680,
"y" : 620,
"w" : 200,
"h": 34
}

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2015-2016 Parallel Realities
Copyright (C) 2015-2017 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -747,6 +747,36 @@ static Entity *getFighterDef(char *name)
exit(1);
}
Entity **getDBFighters(int *num)
{
Entity *e, **dbFighters;
int i;
i = *num = 0;
for (e = defHead.next ; e != NULL ; e = e->next)
{
if (strlen(e->description) > 0)
{
*num = *num + 1;
}
}
dbFighters = malloc(sizeof(Entity*) * *num);
for (e = defHead.next ; e != NULL ; e = e->next)
{
if (strlen(e->description) > 0)
{
dbFighters[i] = e;
}
i++;
}
return dbFighters;
}
void loadFighterDefs(void)
{
memset(&defHead, 0, sizeof(Entity));
@ -802,6 +832,7 @@ static void loadFighterDef(char *filename)
STRNCPY(e->name, cJSON_GetObjectItem(root, "name")->valuestring, MAX_NAME_LENGTH);
STRNCPY(e->defName, e->name, MAX_NAME_LENGTH);
STRNCPY(e->description, cJSON_GetObjectItem(root, "description")->valuestring, MAX_NAME_LENGTH);
e->health = e->maxHealth = cJSON_GetObjectItem(root, "health")->valueint;
e->shield = e->maxShield = getJSONValue(root, "shield", 0);
e->speed = cJSON_GetObjectItem(root, "speed")->valuedouble;

View File

@ -0,0 +1,84 @@
/*
Copyright (C) 2015-2017 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 "fighterDatabase.h"
static int page;
static int maxPages;
static Widget *prev;
static Widget *next;
static char *DB_TEXT;
static char *PAGE_TEXT;
static void prevFighter(void);
static void nextFighter(void);
void initFighterDatabase(void)
{
DB_TEXT = _("Fighter Database");
PAGE_TEXT = _("Page %d / %d");
}
void initFighterDatabaseDisplay(void)
{
page = 0;
maxPages = 1;
prev = getWidget("prev", "fighterDB");
prev->action = prevFighter;
prev->visible = 0;
next = getWidget("next", "fighterDB");
next->action = nextFighter;
next->visible = 1;
}
void drawFighterDatabase(void)
{
SDL_Rect r;
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_BLEND);
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 128);
SDL_RenderFillRect(app.renderer, NULL);
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
r.w = 800;
r.h = 650;
r.x = (SCREEN_WIDTH / 2) - r.w / 2;
r.y = (SCREEN_HEIGHT / 2) - r.h / 2;
SDL_SetRenderDrawColor(app.renderer, 0, 0, 0, 0);
SDL_RenderFillRect(app.renderer, &r);
SDL_SetRenderDrawColor(app.renderer, 200, 200, 200, 255);
SDL_RenderDrawRect(app.renderer, &r);
drawText(SCREEN_WIDTH / 2, 50, 28, TA_CENTER, colors.white, DB_TEXT);
drawText(SCREEN_WIDTH / 2, 90, 16, TA_CENTER, colors.lightGrey, PAGE_TEXT, page + 1, (int)maxPages);
drawWidgets("fighterDB");
}
static void prevFighter(void)
{
}
static void nextFighter(void)
{
}

View File

@ -0,0 +1,29 @@
/*
Copyright (C) 2015-2017 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"
extern void drawWidgets(char *groupName);
extern Widget *getWidget(const char *name, const char *group);
extern char *getTranslatedString(char *string);
extern void drawText(int x, int y, int size, int align, SDL_Color c, const char *format, ...);
extern App app;
extern Colors colors;

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2015-2016 Parallel Realities
Copyright (C) 2015-2017 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -30,6 +30,7 @@ static void campaign(void);
static void challenges(void);
static void trophies(void);
static void stats(void);
static void fighterDatabase(void);
static void ok(void);
static void options(void);
static void credits(void);
@ -82,6 +83,7 @@ void initTitle(void)
getWidget("challenges", "title")->action = challenges;
getWidget("trophies", "title")->action = trophies;
getWidget("stats", "title")->action = stats;
getWidget("fighterDB", "title")->action = fighterDatabase;
getWidget("options", "title")->action = options;
getWidget("credits", "title")->action = credits;
getWidget("quit", "title")->action = quit;
@ -181,7 +183,7 @@ static void draw(void)
blit(pandoranWar, SCREEN_WIDTH / 2, 110, 1);
drawText(10, SCREEN_HEIGHT - 25, 14, TA_LEFT, colors.white, "Copyright Parallel Realities, 2015-2016");
drawText(10, SCREEN_HEIGHT - 25, 14, TA_LEFT, colors.white, "Copyright Parallel Realities, 2015-2017");
drawText(SCREEN_WIDTH - 10, SCREEN_HEIGHT - 25, 14, TA_RIGHT, colors.white, "Version %.2f-%d", VERSION, REVISION);
switch (show)
@ -201,6 +203,10 @@ static void draw(void)
case SHOW_TROPHIES:
drawTrophies();
break;
case SHOW_FIGHTER_DB:
drawFighterDatabase();
break;
}
}
@ -250,6 +256,13 @@ static void trophies(void)
initTrophiesDisplay();
}
static void fighterDatabase(void)
{
show = SHOW_FIGHTER_DB;
initFighterDatabaseDisplay();
}
static void options(void)
{
selectWidget("ok", "options");

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2015-2016 Parallel Realities
Copyright (C) 2015-2017 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define SHOW_STATS 1
#define SHOW_OPTIONS 2
#define SHOW_TROPHIES 3
#define SHOW_FIGHTER_DB 4
#define NUM_FIGHTERS 12
@ -60,6 +61,8 @@ extern void clearInput(void);
extern void initTrophiesDisplay(void);
extern void drawTrophies(void);
extern void initCredits(void);
extern void drawFighterDatabase(void);
extern void initFighterDatabaseDisplay(void);
extern App app;
extern Battle battle;

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2015-2016 Parallel Realities
Copyright (C) 2015-2017 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -100,6 +100,7 @@ struct Entity {
char name[MAX_NAME_LENGTH];
char defName[MAX_NAME_LENGTH];
char groupName[MAX_NAME_LENGTH];
char description[MAX_DESCRIPTION_LENGTH];
int active;
int spawned;
int id;

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2015-2016 Parallel Realities
Copyright (C) 2015-2017 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -141,7 +141,8 @@ void initGameSystem(void)
initBackground,
initStars,
initControls,
initTrophies
initTrophies,
initFighterDatabase
};
numInitFuns = sizeof(initFuncs) / sizeof(void*);

View File

@ -1,5 +1,5 @@
/*
Copyright (C) 2015-2016 Parallel Realities
Copyright (C) 2015-2017 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
@ -48,6 +48,7 @@ extern void initWidgets(void);
extern void initBackground(void);
extern void initResources(void);
extern void initControls(void);
extern void initFighterDatabase(void);
extern void destroyLookups(void);
extern void destroyFonts(void);
extern void destroySounds(void);