1
1
Fork 0
Browse Source

fix mouse controlscheme

master
alistair 3 years ago
parent
commit
738a69d47d
  1. 2
      src/controlscheme.c
  2. 3
      src/controlscheme.h
  3. 2
      src/draw.c
  4. 10
      src/game.c

2
src/controlscheme.c

@ -32,6 +32,8 @@ void get_input_map(void) { @@ -32,6 +32,8 @@ void get_input_map(void) {
input_map.mute = SDL_SCANCODE_M;
input_map.pause = SDL_SCANCODE_ESCAPE;
input_map.quit = SDL_SCANCODE_Q;
input_map.mouse_attach_rope_pull = SDL_BUTTON_LEFT;
input_map.mouse_attach_rope = SDL_BUTTON_RIGHT;
}
struct Buffer {

3
src/controlscheme.h

@ -10,6 +10,7 @@ enum Game_Interaction { @@ -10,6 +10,7 @@ enum Game_Interaction {
PLAYER_LEFT
};
struct InputMap {
SDL_Scancode player_up;
SDL_Scancode player_down;
@ -20,6 +21,8 @@ struct InputMap { @@ -20,6 +21,8 @@ struct InputMap {
SDL_Scancode mute;
SDL_Scancode quit;
SDL_Scancode pause;
Uint8 mouse_attach_rope_pull;
Uint8 mouse_attach_rope;
};
extern struct InputMap input_map;

2
src/draw.c

@ -766,7 +766,7 @@ void redraw_buffer(SDL_Renderer * ren) { @@ -766,7 +766,7 @@ void redraw_buffer(SDL_Renderer * ren) {
if (SDL_LockMutex(player.physics->lock) == 0){
lplayer = *player.physics;
accel_update_viewport(&lplayer);
update_viewport(&lplayer);
} else {
return;
}

10
src/game.c

@ -982,7 +982,6 @@ void pull_rope(double newtons) { @@ -982,7 +982,6 @@ void pull_rope(double newtons) {
return;
}
// set force
set_motor_newtons(player.physics, M_WINCH, 0, newtons);
set_motor_status(player.physics, M_WINCH, true);
@ -1699,23 +1698,24 @@ void handle_input_event(SDL_Event event) { @@ -1699,23 +1698,24 @@ void handle_input_event(SDL_Event event) {
if (sc == input_map.player_pull_rope) {
stop_pull_rope();
}
// DEBUGINFO
if (event.key.keysym.scancode == SDL_SCANCODE_F10) {
next_level();
}
break;
case SDL_MOUSEBUTTONDOWN:
add_rope(event.button.x, event.button.y);
if (event.button.button == SDL_BUTTON_LEFT)
if (event.button.button == input_map.mouse_attach_rope)
mouse_down = true;
if (event.button.button == SDL_BUTTON_RIGHT)
if (event.button.button == input_map.mouse_attach_rope_pull)
pull_rope(900);
break;
case SDL_MOUSEBUTTONUP:
if (event.button.button == SDL_BUTTON_LEFT) {
if (event.button.button == input_map.mouse_attach_rope) {
mouse_down = false;
delete_rope();
}
if (event.button.button == SDL_BUTTON_RIGHT) {
if (event.button.button == input_map.mouse_attach_rope_pull) {
stop_pull_rope();
if (!mouse_down) {
delete_rope();

Loading…
Cancel
Save