diff --git a/src/main.c b/src/main.c index 3a80964..99ebd0a 100644 --- a/src/main.c +++ b/src/main.c @@ -100,7 +100,8 @@ int main(int argc, char** argv) { // Random numbers. rng_init(); - // default window params. + // SDL_Init is first called here, so it's important to be + // initialized first. if(gl_init()) { // Initializes video output. WARN("Error initializing video output, exiting..."); diff --git a/src/pilot.c b/src/pilot.c index 029109c..da2fd53 100644 --- a/src/pilot.c +++ b/src/pilot.c @@ -38,16 +38,12 @@ Pilot* get_pilot(unsigned int id) { // Render the pilot. static void pilot_render(Pilot* pilot) { int sprite; - Vec2 pos; gl_texture* texture = pilot->ship->gfx_ship; - pos.x = pilot->solid->pos.x; - pos.y = pilot->solid->pos.y; - // Get the sprite corresponding to the direction facing. sprite = (int)(pilot->solid->dir / (2.0*M_PI / (texture->sy * texture->sx))); - gl_blitSprite(texture, &pos, sprite % (int)texture->sx, sprite / (int)texture->sy); + gl_blitSprite(texture, &pilot->solid->pos, sprite % (int)texture->sx, sprite / (int)texture->sy); } // Update the pilot. diff --git a/src/player.c b/src/player.c index c3bb3a7..d3fb603 100644 --- a/src/player.c +++ b/src/player.c @@ -54,9 +54,20 @@ static void handle_joyaxis(int axis, int value) { } } -static void handle_joybutton(int button) { +static void handle_joydown(int button) { switch(button) { case 0: + player_acc += (FP)(1<<15); + break; + case 1: + break; + } +} + +static void handle_joyup(int button) { + switch(button) { + case 0: + player_acc -=(FP)(1<<15); break; case 1: break; @@ -114,8 +125,10 @@ void handle_input(SDL_Event* event) { handle_joyaxis(event->jaxis.axis, event->jaxis.value); break; case SDL_JOYBUTTONDOWN: - handle_joybutton(event->jbutton.button); + handle_joydown(event->jbutton.button); break; + case SDL_JOYBUTTONUP: + handle_joyup(event->jbutton.button); case SDL_KEYDOWN: handle_keydown(event->key.keysym.sym); break;