Control and input updates.
This commit is contained in:
parent
b00b9dcdb4
commit
ccf228f875
|
@ -191,7 +191,8 @@ enum
|
||||||
CONTROL_FIRE,
|
CONTROL_FIRE,
|
||||||
CONTROL_JUMP,
|
CONTROL_JUMP,
|
||||||
CONTROL_JETPACK,
|
CONTROL_JETPACK,
|
||||||
CONTROL_STATUS,
|
CONTROL_PAUSE,
|
||||||
|
CONTROL_MAP,
|
||||||
CONTROL_MAX
|
CONTROL_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -309,6 +309,14 @@ typedef struct {
|
||||||
int dragging;
|
int dragging;
|
||||||
} Mouse;
|
} Mouse;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int fullscreen;
|
||||||
|
int soundVolume;
|
||||||
|
int musicVolume;
|
||||||
|
int keyControls[CONTROL_MAX];
|
||||||
|
int joypadControls[CONTROL_MAX];
|
||||||
|
} Config;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char saveDir[MAX_FILENAME_LENGTH];
|
char saveDir[MAX_FILENAME_LENGTH];
|
||||||
int winWidth;
|
int winWidth;
|
||||||
|
@ -328,17 +336,9 @@ typedef struct {
|
||||||
int awaitingWidgetInput;
|
int awaitingWidgetInput;
|
||||||
int lastKeyPressed;
|
int lastKeyPressed;
|
||||||
int lastButtonPressed;
|
int lastButtonPressed;
|
||||||
|
Config config;
|
||||||
} App;
|
} App;
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
int fullscreen;
|
|
||||||
int soundVolume;
|
|
||||||
int musicVolume;
|
|
||||||
int control[CONTROL_MAX];
|
|
||||||
int keyControls[CONTROL_MAX];
|
|
||||||
int joypadControls[CONTROL_MAX];
|
|
||||||
} Config;
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int cells;
|
int cells;
|
||||||
int hearts;
|
int hearts;
|
||||||
|
@ -361,7 +361,6 @@ typedef struct {
|
||||||
char **targets;
|
char **targets;
|
||||||
Tuple keys[MAX_KEY_TYPES];
|
Tuple keys[MAX_KEY_TYPES];
|
||||||
Tuple missionStatusHead, *missionStatusTail;
|
Tuple missionStatusHead, *missionStatusTail;
|
||||||
Config config;
|
|
||||||
} Game;
|
} Game;
|
||||||
|
|
||||||
struct Marker {
|
struct Marker {
|
||||||
|
|
|
@ -24,32 +24,32 @@ void initControls(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
game.config.keyControls[CONTROL_LEFT] = SDL_SCANCODE_A;
|
app.config.keyControls[CONTROL_LEFT] = SDL_SCANCODE_A;
|
||||||
game.config.keyControls[CONTROL_RIGHT] = SDL_SCANCODE_D;
|
app.config.keyControls[CONTROL_RIGHT] = SDL_SCANCODE_D;
|
||||||
game.config.keyControls[CONTROL_UP] = SDL_SCANCODE_W;
|
app.config.keyControls[CONTROL_UP] = SDL_SCANCODE_W;
|
||||||
game.config.keyControls[CONTROL_DOWN] = SDL_SCANCODE_S;
|
app.config.keyControls[CONTROL_DOWN] = SDL_SCANCODE_S;
|
||||||
game.config.keyControls[CONTROL_JUMP] = SDL_SCANCODE_I;
|
app.config.keyControls[CONTROL_JUMP] = SDL_SCANCODE_I;
|
||||||
game.config.keyControls[CONTROL_FIRE] = SDL_SCANCODE_J;
|
app.config.keyControls[CONTROL_FIRE] = SDL_SCANCODE_J;
|
||||||
game.config.keyControls[CONTROL_JETPACK] = SDL_SCANCODE_L;
|
app.config.keyControls[CONTROL_JETPACK] = SDL_SCANCODE_L;
|
||||||
game.config.keyControls[CONTROL_STATUS] = SDL_SCANCODE_TAB;
|
app.config.keyControls[CONTROL_PAUSE] = SDL_SCANCODE_TAB;
|
||||||
|
|
||||||
/* can't use memset here, as it doesn't work */
|
/* can't use memset here, as it doesn't work */
|
||||||
for (i = 0 ; i < CONTROL_MAX ; i++)
|
for (i = 0 ; i < CONTROL_MAX ; i++)
|
||||||
{
|
{
|
||||||
game.config.joypadControls[i] = -1;
|
app.config.joypadControls[i] = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
game.config.joypadControls[CONTROL_JUMP] = 1;
|
app.config.joypadControls[CONTROL_JUMP] = 1;
|
||||||
game.config.joypadControls[CONTROL_FIRE] = 3;
|
app.config.joypadControls[CONTROL_FIRE] = 3;
|
||||||
game.config.joypadControls[CONTROL_JETPACK] = 2;
|
app.config.joypadControls[CONTROL_JETPACK] = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int isControl(int type)
|
int isControl(int type)
|
||||||
{
|
{
|
||||||
int key, btn;
|
int key, btn;
|
||||||
|
|
||||||
key = game.config.keyControls[type];
|
key = app.config.keyControls[type];
|
||||||
btn = game.config.joypadControls[type];
|
btn = app.config.joypadControls[type];
|
||||||
|
|
||||||
if (type == CONTROL_LEFT && app.joypadAxis[JOYPAD_AXIS_X] <= -16384)
|
if (type == CONTROL_LEFT && app.joypadAxis[JOYPAD_AXIS_X] <= -16384)
|
||||||
{
|
{
|
||||||
|
@ -81,8 +81,8 @@ int isAcceptControl(void)
|
||||||
|
|
||||||
void clearControl(int type)
|
void clearControl(int type)
|
||||||
{
|
{
|
||||||
int key = game.config.keyControls[type];
|
int key = app.config.keyControls[type];
|
||||||
int btn = game.config.joypadControls[type];
|
int btn = app.config.joypadControls[type];
|
||||||
|
|
||||||
if (key != 0)
|
if (key != 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -242,10 +242,10 @@ static void doWorldInProgress(void)
|
||||||
|
|
||||||
doLocationTriggers();
|
doLocationTriggers();
|
||||||
|
|
||||||
if (isControl(CONTROL_STATUS))
|
if (isControl(CONTROL_PAUSE))
|
||||||
{
|
{
|
||||||
world.state = WS_PAUSED;
|
world.state = WS_PAUSED;
|
||||||
clearControl(CONTROL_STATUS);
|
clearControl(CONTROL_PAUSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (world.allObjectivesComplete && world.state != WS_COMPLETE)
|
if (world.allObjectivesComplete && world.state != WS_COMPLETE)
|
||||||
|
@ -315,10 +315,10 @@ static void doWorldPaused(void)
|
||||||
{
|
{
|
||||||
animateSprites();
|
animateSprites();
|
||||||
|
|
||||||
if (isControl(CONTROL_STATUS))
|
if (isControl(CONTROL_PAUSE))
|
||||||
{
|
{
|
||||||
world.state = WS_IN_PROGRESS;
|
world.state = WS_IN_PROGRESS;
|
||||||
clearControl(CONTROL_STATUS);
|
clearControl(CONTROL_PAUSE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -451,7 +451,7 @@ static void spawnEnemies(void)
|
||||||
|
|
||||||
if (x >= world.map.bounds.x && y >= world.map.bounds.y && x < world.map.bounds.w + SCREEN_WIDTH - 64 && y < world.map.bounds.h + SCREEN_HEIGHT - 64)
|
if (x >= world.map.bounds.x && y >= world.map.bounds.y && x < world.map.bounds.w + SCREEN_WIDTH - 64 && y < world.map.bounds.h + SCREEN_HEIGHT - 64)
|
||||||
{
|
{
|
||||||
sprintf(name, "%s%s", world.enemyTypes[r], (rand() % 2 ? "Blob" : "Droid"));
|
sprintf(name, "%s%s", world.enemyTypes[r], (rand() % 2 ? "Blob" : "EyeDroid"));
|
||||||
|
|
||||||
u = (Unit*) createEntity(name);
|
u = (Unit*) createEntity(name);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue