[Fix] Small handling fixes, nothing special.
This commit is contained in:
parent
838bbcd2ab
commit
d39e7925ea
@ -100,7 +100,8 @@ int main(int argc, char** argv) {
|
|||||||
// Random numbers.
|
// Random numbers.
|
||||||
rng_init();
|
rng_init();
|
||||||
|
|
||||||
// default window params.
|
// SDL_Init is first called here, so it's important to be
|
||||||
|
// initialized first.
|
||||||
if(gl_init()) {
|
if(gl_init()) {
|
||||||
// Initializes video output.
|
// Initializes video output.
|
||||||
WARN("Error initializing video output, exiting...");
|
WARN("Error initializing video output, exiting...");
|
||||||
|
@ -38,16 +38,12 @@ Pilot* get_pilot(unsigned int id) {
|
|||||||
// Render the pilot.
|
// Render the pilot.
|
||||||
static void pilot_render(Pilot* pilot) {
|
static void pilot_render(Pilot* pilot) {
|
||||||
int sprite;
|
int sprite;
|
||||||
Vec2 pos;
|
|
||||||
gl_texture* texture = pilot->ship->gfx_ship;
|
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.
|
// Get the sprite corresponding to the direction facing.
|
||||||
sprite = (int)(pilot->solid->dir / (2.0*M_PI / (texture->sy * texture->sx)));
|
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.
|
// Update the pilot.
|
||||||
|
17
src/player.c
17
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) {
|
switch(button) {
|
||||||
case 0:
|
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;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
break;
|
break;
|
||||||
@ -114,8 +125,10 @@ void handle_input(SDL_Event* event) {
|
|||||||
handle_joyaxis(event->jaxis.axis, event->jaxis.value);
|
handle_joyaxis(event->jaxis.axis, event->jaxis.value);
|
||||||
break;
|
break;
|
||||||
case SDL_JOYBUTTONDOWN:
|
case SDL_JOYBUTTONDOWN:
|
||||||
handle_joybutton(event->jbutton.button);
|
handle_joydown(event->jbutton.button);
|
||||||
break;
|
break;
|
||||||
|
case SDL_JOYBUTTONUP:
|
||||||
|
handle_joyup(event->jbutton.button);
|
||||||
case SDL_KEYDOWN:
|
case SDL_KEYDOWN:
|
||||||
handle_keydown(event->key.keysym.sym);
|
handle_keydown(event->key.keysym.sym);
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user