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