Added debug keys.
This commit is contained in:
parent
7325bbe506
commit
b5dfab1bd5
|
@ -1,6 +1,6 @@
|
||||||
VERSION = 0.5
|
VERSION = 0.5
|
||||||
REVISION = $(shell date +"%y%m%d")
|
REVISION = $(shell date +"%y%m%d")
|
||||||
DEBUG = 0
|
DEBUG = $(shell stat dev 1>/dev/null 2>&1 && echo 1 || echo 0)
|
||||||
|
|
||||||
SEARCHPATH += src/ src/battle src/draw src/game src/galaxy src/json src/system src/test
|
SEARCHPATH += src/ src/battle src/draw src/game src/galaxy src/json src/system src/test
|
||||||
vpath %.c $(SEARCHPATH)
|
vpath %.c $(SEARCHPATH)
|
||||||
|
@ -11,7 +11,7 @@ DEPS += defs.h structs.h
|
||||||
OBJS += ai.o
|
OBJS += ai.o
|
||||||
OBJS += battle.o bullets.o
|
OBJS += battle.o bullets.o
|
||||||
OBJS += capitalShips.o challenges.o cJSON.o
|
OBJS += capitalShips.o challenges.o cJSON.o
|
||||||
OBJS += debris.o draw.o
|
OBJS += debris.o dev.o draw.o
|
||||||
OBJS += effects.o entities.o extractionPoint.o
|
OBJS += effects.o entities.o extractionPoint.o
|
||||||
OBJS += fighters.o
|
OBJS += fighters.o
|
||||||
OBJS += galacticMap.o game.o grid.o
|
OBJS += galacticMap.o game.o grid.o
|
||||||
|
|
|
@ -410,11 +410,17 @@ static void preAttack(void)
|
||||||
|
|
||||||
if (self->guns[0].type && (self->missiles == 0 || rand() % 50 > 0))
|
if (self->guns[0].type && (self->missiles == 0 || rand() % 50 > 0))
|
||||||
{
|
{
|
||||||
fireGuns(self);
|
if (!dev.noAIWeapons)
|
||||||
|
{
|
||||||
|
fireGuns(self);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (self->missiles && getDistance(self->x, self->y, self->target->x, self->target->y) >= 350)
|
else if (self->missiles && getDistance(self->x, self->y, self->target->x, self->target->y) >= 350)
|
||||||
{
|
{
|
||||||
fireMissile(self);
|
if (!dev.noAIWeapons)
|
||||||
|
{
|
||||||
|
fireMissile(self);
|
||||||
|
}
|
||||||
|
|
||||||
self->action = doAI;
|
self->action = doAI;
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,5 +40,6 @@ extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
||||||
|
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
extern Dev dev;
|
||||||
extern Entity *self;
|
extern Entity *self;
|
||||||
extern Entity *player;
|
extern Entity *player;
|
||||||
|
|
|
@ -406,6 +406,8 @@ static void loadComponents(Entity *parent, cJSON *components)
|
||||||
parent->health++;
|
parent->health++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
parent->maxHealth = parent->health;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void loadGuns(Entity *parent, cJSON *guns)
|
static void loadGuns(Entity *parent, cJSON *guns)
|
||||||
|
|
|
@ -72,8 +72,20 @@ void doEntities(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dev.playerImmortal)
|
||||||
|
{
|
||||||
|
player->health = player->maxHealth;
|
||||||
|
player->shield = player->maxShield;
|
||||||
|
}
|
||||||
|
|
||||||
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
for (e = battle.entityHead.next ; e != NULL ; e = e->next)
|
||||||
{
|
{
|
||||||
|
if (dev.allImmortal)
|
||||||
|
{
|
||||||
|
e->health = e->maxHealth;
|
||||||
|
e->shield = e->maxShield;
|
||||||
|
}
|
||||||
|
|
||||||
if (e->active)
|
if (e->active)
|
||||||
{
|
{
|
||||||
self = e;
|
self = e;
|
||||||
|
@ -120,6 +132,11 @@ void doEntities(void)
|
||||||
{
|
{
|
||||||
if (e->action != NULL)
|
if (e->action != NULL)
|
||||||
{
|
{
|
||||||
|
if (dev.noEntityActions)
|
||||||
|
{
|
||||||
|
e->thinkTime = 2;
|
||||||
|
}
|
||||||
|
|
||||||
if (--e->thinkTime <= 0)
|
if (--e->thinkTime <= 0)
|
||||||
{
|
{
|
||||||
e->thinkTime = 0;
|
e->thinkTime = 0;
|
||||||
|
|
|
@ -34,5 +34,6 @@ extern void destroyGrid(void);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
|
extern Dev dev;
|
||||||
extern Entity *self;
|
extern Entity *self;
|
||||||
extern Entity *player;
|
extern Entity *player;
|
||||||
|
|
|
@ -121,6 +121,11 @@ void doPlayer(void)
|
||||||
{
|
{
|
||||||
selectMissionTarget();
|
selectMissionTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dev.playerUnlimitedMissiles)
|
||||||
|
{
|
||||||
|
player->missiles = 999;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (battle.boostTimer == (int)BOOST_FINISHED_TIME)
|
if (battle.boostTimer == (int)BOOST_FINISHED_TIME)
|
||||||
|
|
|
@ -40,6 +40,7 @@ extern void addECMEffect(Entity *ent);
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Battle battle;
|
extern Battle battle;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
extern Dev dev;
|
||||||
extern Entity *player;
|
extern Entity *player;
|
||||||
extern Entity *self;
|
extern Entity *self;
|
||||||
extern Game game;
|
extern Game game;
|
||||||
|
|
|
@ -47,7 +47,11 @@ void prepareScene(void)
|
||||||
void presentScene(void)
|
void presentScene(void)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 25, 14, TA_CENTER, colors.white, "FPS: %d", app.fps);
|
drawText(5, SCREEN_HEIGHT - 25, 14, TA_LEFT, colors.white, "DEBUG MODE");
|
||||||
|
if (dev.showFPS)
|
||||||
|
{
|
||||||
|
drawText(SCREEN_WIDTH / 2, SCREEN_HEIGHT - 25, 14, TA_CENTER, colors.white, "FPS: %d", dev.fps);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
drawMouse();
|
drawMouse();
|
||||||
|
|
|
@ -25,3 +25,4 @@ extern void drawMouse(void);
|
||||||
|
|
||||||
extern App app;
|
extern App app;
|
||||||
extern Colors colors;
|
extern Colors colors;
|
||||||
|
extern Dev dev;
|
||||||
|
|
12
src/main.c
12
src/main.c
|
@ -28,6 +28,7 @@ int main(int argc, char *argv[])
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
memset(&app, 0, sizeof(App));
|
memset(&app, 0, sizeof(App));
|
||||||
|
memset(&dev, 0, sizeof(Dev));
|
||||||
|
|
||||||
atexit(cleanup);
|
atexit(cleanup);
|
||||||
|
|
||||||
|
@ -48,7 +49,7 @@ int main(int argc, char *argv[])
|
||||||
initTitle();
|
initTitle();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.fps = frames = td = 0;
|
dev.fps = frames = td = 0;
|
||||||
then = SDL_GetTicks();
|
then = SDL_GetTicks();
|
||||||
lastFrameTime = SDL_GetTicks() + 1000;
|
lastFrameTime = SDL_GetTicks() + 1000;
|
||||||
|
|
||||||
|
@ -104,15 +105,20 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
app.delegate.draw();
|
app.delegate.draw();
|
||||||
|
|
||||||
|
doDevKeys();
|
||||||
|
|
||||||
frames++;
|
frames++;
|
||||||
|
|
||||||
if (SDL_GetTicks() > lastFrameTime)
|
if (SDL_GetTicks() > lastFrameTime)
|
||||||
{
|
{
|
||||||
app.fps = frames;
|
dev.fps = frames;
|
||||||
frames = 0;
|
frames = 0;
|
||||||
lastFrameTime = SDL_GetTicks() + 1000;
|
lastFrameTime = SDL_GetTicks() + 1000;
|
||||||
|
|
||||||
/*saveScreenshot();*/
|
if (dev.takeScreenshots)
|
||||||
|
{
|
||||||
|
saveScreenshot();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Delay(1);
|
SDL_Delay(1);
|
||||||
|
|
|
@ -34,10 +34,12 @@ extern void saveScreenshot(void);
|
||||||
extern void doMouseDown(SDL_MouseButtonEvent *event);
|
extern void doMouseDown(SDL_MouseButtonEvent *event);
|
||||||
extern void doMouseUp(SDL_MouseButtonEvent *event);
|
extern void doMouseUp(SDL_MouseButtonEvent *event);
|
||||||
extern void doMouseWheel(SDL_MouseWheelEvent *event);
|
extern void doMouseWheel(SDL_MouseWheelEvent *event);
|
||||||
|
extern void doDevKeys(void);
|
||||||
|
|
||||||
App app;
|
App app;
|
||||||
Colors colors;
|
Colors colors;
|
||||||
Battle battle;
|
Battle battle;
|
||||||
|
Dev dev;
|
||||||
Entity *self;
|
Entity *self;
|
||||||
Entity *player;
|
Entity *player;
|
||||||
Game game;
|
Game game;
|
||||||
|
|
|
@ -36,6 +36,17 @@ typedef struct MessageBox MessageBox;
|
||||||
typedef struct GridCell GridCell;
|
typedef struct GridCell GridCell;
|
||||||
typedef struct ScriptRunner ScriptRunner;
|
typedef struct ScriptRunner ScriptRunner;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int takeScreenshots;
|
||||||
|
int noAIWeapons;
|
||||||
|
int showFPS;
|
||||||
|
int playerImmortal;
|
||||||
|
int playerUnlimitedMissiles;
|
||||||
|
int noEntityActions;
|
||||||
|
int allImmortal;
|
||||||
|
int fps;
|
||||||
|
} Dev;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
float x;
|
float x;
|
||||||
float y;
|
float y;
|
||||||
|
@ -334,7 +345,6 @@ typedef struct {
|
||||||
int musicVolume;
|
int musicVolume;
|
||||||
int soundVolume;
|
int soundVolume;
|
||||||
int vSync;
|
int vSync;
|
||||||
int fps;
|
|
||||||
Mouse mouse;
|
Mouse mouse;
|
||||||
int keyboard[MAX_KEYBOARD_KEYS];
|
int keyboard[MAX_KEYBOARD_KEYS];
|
||||||
SDL_Texture *backBuffer;
|
SDL_Texture *backBuffer;
|
||||||
|
|
|
@ -0,0 +1,75 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2015 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 "dev.h"
|
||||||
|
|
||||||
|
void doDevKeys(void)
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
if (app.keyboard[SDL_SCANCODE_1])
|
||||||
|
{
|
||||||
|
dev.playerImmortal = !dev.playerImmortal;
|
||||||
|
app.keyboard[SDL_SCANCODE_1] = 0;
|
||||||
|
printf("DEBUG: dev.playerImmortal=%d\n", dev.playerImmortal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_2])
|
||||||
|
{
|
||||||
|
dev.playerUnlimitedMissiles = !dev.playerUnlimitedMissiles;
|
||||||
|
app.keyboard[SDL_SCANCODE_2] = 0;
|
||||||
|
printf("DEBUG: dev.playerUnlimitedMissiles=%d\n", dev.playerUnlimitedMissiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_3])
|
||||||
|
{
|
||||||
|
dev.noAIWeapons = !dev.noAIWeapons;
|
||||||
|
app.keyboard[SDL_SCANCODE_3] = 0;
|
||||||
|
printf("DEBUG: dev.noAIWeapons=%d\n", dev.noAIWeapons);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_4])
|
||||||
|
{
|
||||||
|
dev.noEntityActions = !dev.noEntityActions;
|
||||||
|
app.keyboard[SDL_SCANCODE_4] = 0;
|
||||||
|
printf("DEBUG: dev.noEntityActions=%d\n", dev.noEntityActions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_5])
|
||||||
|
{
|
||||||
|
dev.allImmortal = !dev.allImmortal;
|
||||||
|
app.keyboard[SDL_SCANCODE_5] = 0;
|
||||||
|
printf("DEBUG: dev.allImmortal=%d\n", dev.allImmortal);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_9])
|
||||||
|
{
|
||||||
|
dev.showFPS = !dev.showFPS;
|
||||||
|
app.keyboard[SDL_SCANCODE_9] = 0;
|
||||||
|
printf("DEBUG: dev.showFPS=%d\n", dev.showFPS);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.keyboard[SDL_SCANCODE_0])
|
||||||
|
{
|
||||||
|
dev.takeScreenshots = !dev.takeScreenshots;
|
||||||
|
app.keyboard[SDL_SCANCODE_0] = 0;
|
||||||
|
printf("DEBUG: dev.takeScreenshots=%d\n", dev.takeScreenshots);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2015 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 App app;
|
||||||
|
extern Dev dev;
|
Loading…
Reference in New Issue