Moved most structs to the modules they obviously belong to.
The ones with names that don't correspond to modules and are used in multiple places have been left alone.
This commit is contained in:
parent
d336bb2c83
commit
1ba51f0e58
|
@ -20,9 +20,24 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#ifndef COLLECTABLE_H
|
#ifndef COLLECTABLE_H
|
||||||
#define COLLECTABLE_H
|
#define COLLECTABLE_H
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
|
typedef struct Collectable_ {
|
||||||
|
|
||||||
|
int active;
|
||||||
|
float x, y, dx, dy;
|
||||||
|
SDL_Surface *image;
|
||||||
|
int type; // What kind of collectable is it?
|
||||||
|
int value; // How much is it worth?
|
||||||
|
int life; // How long it will stay around for
|
||||||
|
|
||||||
|
struct Collectable_ *next;
|
||||||
|
|
||||||
|
} Collectable;
|
||||||
|
|
||||||
void collectable_add(float x, float y, int type, int value, int life);
|
void collectable_add(float x, float y, int type, int value, int life);
|
||||||
int collectable_collision(Collectable *collectable, Object *ship);
|
int collectable_collision(Collectable *collectable, Object *ship);
|
||||||
void collectable_explode(Collectable *collectable);
|
void collectable_explode(Collectable *collectable);
|
||||||
|
|
|
@ -25,6 +25,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
|
#include "collectable.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct Engine_ {
|
typedef struct Engine_ {
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,13 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include "radio.h"
|
#include "radio.h"
|
||||||
|
|
||||||
|
typedef struct Star_ {
|
||||||
|
|
||||||
|
float x, y, dx, dy;
|
||||||
|
int speed; // How fast the star moves
|
||||||
|
|
||||||
|
} Star;
|
||||||
|
|
||||||
Game game;
|
Game game;
|
||||||
|
|
||||||
static Star stars[STARS_NUM];
|
static Star stars[STARS_NUM];
|
||||||
|
|
75
src/game.h
75
src/game.h
|
@ -20,9 +20,84 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#ifndef GAME_H
|
#ifndef GAME_H
|
||||||
#define GAME_H
|
#define GAME_H
|
||||||
|
|
||||||
|
#include "SDL.h"
|
||||||
|
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
|
typedef struct Game_ {
|
||||||
|
Object thePlayer;
|
||||||
|
Object playerWeapon;
|
||||||
|
|
||||||
|
int saveFormat;
|
||||||
|
|
||||||
|
int difficulty;
|
||||||
|
|
||||||
|
int system;
|
||||||
|
int area;
|
||||||
|
int musicVolume;
|
||||||
|
int sfxVolume;
|
||||||
|
|
||||||
|
int cash;
|
||||||
|
int cashEarned;
|
||||||
|
|
||||||
|
int shots;
|
||||||
|
int hits;
|
||||||
|
int accuracy;
|
||||||
|
int hasWingMate1;
|
||||||
|
int hasWingMate2;
|
||||||
|
int totalKills;
|
||||||
|
int wingMate1Kills;
|
||||||
|
int wingMate2Kills;
|
||||||
|
int wingMate1Ejects;
|
||||||
|
int wingMate2Ejects;
|
||||||
|
int totalOtherKills;
|
||||||
|
int secondaryMissions;
|
||||||
|
int secondaryMissionsCompleted;
|
||||||
|
int shieldPickups;
|
||||||
|
int rocketPickups;
|
||||||
|
int cellPickups;
|
||||||
|
int powerups;
|
||||||
|
int minesKilled;
|
||||||
|
int cargoPickups;
|
||||||
|
|
||||||
|
// slaves for Eyananth
|
||||||
|
int slavesRescued;
|
||||||
|
|
||||||
|
// remaining shield for experimental fighter
|
||||||
|
int experimentalShield;
|
||||||
|
|
||||||
|
Uint32 timeTaken; // In seconds
|
||||||
|
int missionCompleted[10];
|
||||||
|
|
||||||
|
int stationedPlanet;
|
||||||
|
int destinationPlanet;
|
||||||
|
|
||||||
|
char stationedName[20];
|
||||||
|
char destinationName[20];
|
||||||
|
int distanceCovered;
|
||||||
|
|
||||||
|
int minPlasmaRate;
|
||||||
|
int minPlasmaDamage;
|
||||||
|
int minPlasmaOutput;
|
||||||
|
int maxPlasmaRate;
|
||||||
|
int maxPlasmaDamage;
|
||||||
|
int maxPlasmaOutput;
|
||||||
|
int maxPlasmaAmmo;
|
||||||
|
int maxRocketAmmo;
|
||||||
|
|
||||||
|
// Limits on shop upgrades
|
||||||
|
int minPlasmaRateLimit;
|
||||||
|
int minPlasmaDamageLimit;
|
||||||
|
int minPlasmaOutputLimit;
|
||||||
|
int maxPlasmaRateLimit;
|
||||||
|
int maxPlasmaDamageLimit;
|
||||||
|
int maxPlasmaOutputLimit;
|
||||||
|
int maxPlasmaAmmoLimit;
|
||||||
|
int maxRocketAmmoLimit;
|
||||||
|
|
||||||
|
} Game;
|
||||||
|
|
||||||
extern Game game;
|
extern Game game;
|
||||||
|
|
||||||
void game_init();
|
void game_init();
|
||||||
|
|
|
@ -30,7 +30,7 @@ SDL_Surface *gfx_faceSprites[FS_MAX];
|
||||||
SDL_Surface *gfx_shipSprites[SS_MAX];
|
SDL_Surface *gfx_shipSprites[SS_MAX];
|
||||||
SDL_Surface *gfx_fontSprites[FONT_MAX];
|
SDL_Surface *gfx_fontSprites[FONT_MAX];
|
||||||
SDL_Surface *gfx_shopSprites[SHOP_S_MAX];
|
SDL_Surface *gfx_shopSprites[SHOP_S_MAX];
|
||||||
textObject gfx_textSprites[TS_MAX];
|
TextObject gfx_textSprites[TS_MAX];
|
||||||
SDL_Surface *gfx_messageBox;
|
SDL_Surface *gfx_messageBox;
|
||||||
|
|
||||||
void gfx_init()
|
void gfx_init()
|
||||||
|
|
|
@ -31,7 +31,7 @@ extern SDL_Surface *gfx_faceSprites[FS_MAX];
|
||||||
extern SDL_Surface *gfx_shipSprites[SS_MAX];
|
extern SDL_Surface *gfx_shipSprites[SS_MAX];
|
||||||
extern SDL_Surface *gfx_fontSprites[FONT_MAX];
|
extern SDL_Surface *gfx_fontSprites[FONT_MAX];
|
||||||
extern SDL_Surface *gfx_shopSprites[SHOP_S_MAX];
|
extern SDL_Surface *gfx_shopSprites[SHOP_S_MAX];
|
||||||
extern textObject gfx_textSprites[TS_MAX];
|
extern TextObject gfx_textSprites[TS_MAX];
|
||||||
extern SDL_Surface *gfx_messageBox;
|
extern SDL_Surface *gfx_messageBox;
|
||||||
|
|
||||||
void gfx_init();
|
void gfx_init();
|
||||||
|
|
|
@ -23,6 +23,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
|
typedef struct Mission_ {
|
||||||
|
|
||||||
|
char primaryObjective[3][50]; // Description
|
||||||
|
int primaryType[3]; // The type of mission this is
|
||||||
|
int target1[3]; // index of target in aliens array
|
||||||
|
int targetValue1[3]; // Number of things to collect (slaves, cash, etc)
|
||||||
|
int timeLimit1[3]; // In minutes
|
||||||
|
int completed1[3];
|
||||||
|
|
||||||
|
char secondaryObjective[3][50]; // Description
|
||||||
|
int secondaryType[3]; // The type of mission this is
|
||||||
|
int target2[3]; // index of target in aliens array
|
||||||
|
int targetValue2[3]; // Number of things to collect (slaves, cash, etc)
|
||||||
|
int timeLimit2[3]; // In minutes
|
||||||
|
int completed2[3];
|
||||||
|
|
||||||
|
int remainingObjectives1;
|
||||||
|
int remainingObjectives2;
|
||||||
|
int addAliens; // How often to add new enemies
|
||||||
|
|
||||||
|
} Mission;
|
||||||
|
|
||||||
extern Mission mission;
|
extern Mission mission;
|
||||||
|
|
||||||
void mission_set(int mission);
|
void mission_set(int mission);
|
||||||
|
|
10
src/shop.cpp
10
src/shop.cpp
|
@ -22,6 +22,16 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#include "defs.h"
|
#include "defs.h"
|
||||||
#include "structs.h"
|
#include "structs.h"
|
||||||
|
|
||||||
|
typedef struct ShopItem_ {
|
||||||
|
|
||||||
|
int x, y;
|
||||||
|
int price;
|
||||||
|
char name[50];
|
||||||
|
char description[255];
|
||||||
|
int image;
|
||||||
|
|
||||||
|
} ShopItem;
|
||||||
|
|
||||||
static ShopItem shopItems[SHOP_MAX];
|
static ShopItem shopItems[SHOP_MAX];
|
||||||
static int shopSelectedItem;
|
static int shopSelectedItem;
|
||||||
|
|
||||||
|
|
129
src/structs.h
129
src/structs.h
|
@ -68,49 +68,7 @@ typedef struct Object_ {
|
||||||
|
|
||||||
} Object;
|
} Object;
|
||||||
|
|
||||||
typedef struct Mission_ {
|
typedef struct TextObject_ {
|
||||||
|
|
||||||
char primaryObjective[3][50]; // Description
|
|
||||||
int primaryType[3]; // The type of mission this is
|
|
||||||
int target1[3]; // index of target in aliens array
|
|
||||||
int targetValue1[3]; // Number of things to collect (slaves, cash, etc)
|
|
||||||
int timeLimit1[3]; // In minutes
|
|
||||||
int completed1[3];
|
|
||||||
|
|
||||||
char secondaryObjective[3][50]; // Description
|
|
||||||
int secondaryType[3]; // The type of mission this is
|
|
||||||
int target2[3]; // index of target in aliens array
|
|
||||||
int targetValue2[3]; // Number of things to collect (slaves, cash, etc)
|
|
||||||
int timeLimit2[3]; // In minutes
|
|
||||||
int completed2[3];
|
|
||||||
|
|
||||||
int remainingObjectives1;
|
|
||||||
int remainingObjectives2;
|
|
||||||
int addAliens; // How often to add new enemies
|
|
||||||
|
|
||||||
} Mission;
|
|
||||||
|
|
||||||
typedef struct Star_ {
|
|
||||||
|
|
||||||
float x, y, dx, dy;
|
|
||||||
int speed; // How fast the star moves
|
|
||||||
|
|
||||||
} Star;
|
|
||||||
|
|
||||||
typedef struct Collectable_ {
|
|
||||||
|
|
||||||
int active;
|
|
||||||
float x, y, dx, dy;
|
|
||||||
SDL_Surface *image;
|
|
||||||
int type; // What kind of collectable is it?
|
|
||||||
int value; // How much is it worth?
|
|
||||||
int life; // How long it will stay around for
|
|
||||||
|
|
||||||
struct Collectable_ *next;
|
|
||||||
|
|
||||||
} Collectable;
|
|
||||||
|
|
||||||
typedef struct textObject_ {
|
|
||||||
|
|
||||||
SDL_Surface *image;
|
SDL_Surface *image;
|
||||||
int life;
|
int life;
|
||||||
|
@ -118,90 +76,7 @@ typedef struct textObject_ {
|
||||||
int fontColor;
|
int fontColor;
|
||||||
char text[255];
|
char text[255];
|
||||||
|
|
||||||
} textObject;
|
} TextObject;
|
||||||
|
|
||||||
typedef struct Game_ {
|
|
||||||
Object thePlayer;
|
|
||||||
Object playerWeapon;
|
|
||||||
|
|
||||||
int saveFormat;
|
|
||||||
|
|
||||||
int difficulty;
|
|
||||||
|
|
||||||
int system;
|
|
||||||
int area;
|
|
||||||
int musicVolume;
|
|
||||||
int sfxVolume;
|
|
||||||
|
|
||||||
int cash;
|
|
||||||
int cashEarned;
|
|
||||||
|
|
||||||
int shots;
|
|
||||||
int hits;
|
|
||||||
int accuracy;
|
|
||||||
int hasWingMate1;
|
|
||||||
int hasWingMate2;
|
|
||||||
int totalKills;
|
|
||||||
int wingMate1Kills;
|
|
||||||
int wingMate2Kills;
|
|
||||||
int wingMate1Ejects;
|
|
||||||
int wingMate2Ejects;
|
|
||||||
int totalOtherKills;
|
|
||||||
int secondaryMissions;
|
|
||||||
int secondaryMissionsCompleted;
|
|
||||||
int shieldPickups;
|
|
||||||
int rocketPickups;
|
|
||||||
int cellPickups;
|
|
||||||
int powerups;
|
|
||||||
int minesKilled;
|
|
||||||
int cargoPickups;
|
|
||||||
|
|
||||||
// slaves for Eyananth
|
|
||||||
int slavesRescued;
|
|
||||||
|
|
||||||
// remaining shield for experimental fighter
|
|
||||||
int experimentalShield;
|
|
||||||
|
|
||||||
Uint32 timeTaken; // In seconds
|
|
||||||
int missionCompleted[10];
|
|
||||||
|
|
||||||
int stationedPlanet;
|
|
||||||
int destinationPlanet;
|
|
||||||
|
|
||||||
char stationedName[20];
|
|
||||||
char destinationName[20];
|
|
||||||
int distanceCovered;
|
|
||||||
|
|
||||||
int minPlasmaRate;
|
|
||||||
int minPlasmaDamage;
|
|
||||||
int minPlasmaOutput;
|
|
||||||
int maxPlasmaRate;
|
|
||||||
int maxPlasmaDamage;
|
|
||||||
int maxPlasmaOutput;
|
|
||||||
int maxPlasmaAmmo;
|
|
||||||
int maxRocketAmmo;
|
|
||||||
|
|
||||||
// Limits on shop upgrades
|
|
||||||
int minPlasmaRateLimit;
|
|
||||||
int minPlasmaDamageLimit;
|
|
||||||
int minPlasmaOutputLimit;
|
|
||||||
int maxPlasmaRateLimit;
|
|
||||||
int maxPlasmaDamageLimit;
|
|
||||||
int maxPlasmaOutputLimit;
|
|
||||||
int maxPlasmaAmmoLimit;
|
|
||||||
int maxRocketAmmoLimit;
|
|
||||||
|
|
||||||
} Game;
|
|
||||||
|
|
||||||
typedef struct ShopItem_ {
|
|
||||||
|
|
||||||
int x, y;
|
|
||||||
int price;
|
|
||||||
char name[50];
|
|
||||||
char description[255];
|
|
||||||
int image;
|
|
||||||
|
|
||||||
} ShopItem;
|
|
||||||
|
|
||||||
typedef struct bRect_ {
|
typedef struct bRect_ {
|
||||||
|
|
||||||
|
|
|
@ -625,7 +625,7 @@ void title_showCredits()
|
||||||
char text[255];
|
char text[255];
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
textObject *credit;
|
TextObject *credit;
|
||||||
|
|
||||||
screen_clear(black);
|
screen_clear(black);
|
||||||
renderer_update();
|
renderer_update();
|
||||||
|
@ -639,7 +639,7 @@ void title_showCredits()
|
||||||
// FIXME: It would be nice for the size of this array to be determined
|
// FIXME: It would be nice for the size of this array to be determined
|
||||||
// by the number of lines in the text file. I'm not sure how to do
|
// by the number of lines in the text file. I'm not sure how to do
|
||||||
// that at the moment, so just giving it a very large number for now.
|
// that at the moment, so just giving it a very large number for now.
|
||||||
credit = (textObject*) malloc(sizeof(textObject) * 300);
|
credit = (TextObject*) malloc(sizeof(TextObject) * 300);
|
||||||
|
|
||||||
while (fscanf(fp, "%d %[^\n]%*c", &yPos, text) == 2)
|
while (fscanf(fp, "%d %[^\n]%*c", &yPos, text) == 2)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue