From ac54375376585a5c00f06eb833b72336e7aeac9a Mon Sep 17 00:00:00 2001 From: Thomas Perl Date: Thu, 20 Mar 2008 14:19:00 +0100 Subject: [PATCH] Fix mouse control, add mouse rectangle, enable mouse by default Fix problems with mouse control (lock the mouse if we are using the keyboard). This makes the mouse control work nicely together with the keyboard control, so we enable mouse control by default now. Draw a mouse rectangle on the screen so the user knows what's going on when using mouse control. This should make playing Tennix a bit easier with the mouse, because the racket is always sloppy (you can move the mouse faster than you can move the racket. --- TODO | 1 - game.c | 13 +++++++++++++ game.h | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index 095a40e..8d3896c 100644 --- a/TODO +++ b/TODO @@ -20,5 +20,4 @@ MAEMO TODO Main screen should look like all other maemo games Fix sounds (wav, mp3? - ogg doesn't seem to be supported) Widescreen support (??) -Fix touchpad + D-Pad (d-pad doesn't work with mouse enabled) diff --git a/game.c b/game.c index c8235b1..8dae3be 100644 --- a/game.c +++ b/game.c @@ -371,6 +371,11 @@ void render( GameState* s) { show_sprite( GR_BALL, 0, 4, s->ball.x-BALL_X_MID, s->ball.y-BALL_Y_MID, 255); } + /* Player 1's mouse rectangle */ + if (!(s->player1.mouse_locked)) { + rectangle(s->player1.x-2+5, s->player1.mouse_y-2, 4, 4, 255, 255, 255); + rectangle(s->player1.x-1+5, s->player1.mouse_y-1, 2, 2, 0, 0, 0); + } font_draw_string( GR_DKC2_FONT, s->game_score_str, 14, 14, 0, ANIMATION_NONE); font_draw_string( GR_DKC2_FONT, s->sets_score_str, (WIDTH-font_get_string_width( GR_DKC2_FONT, s->sets_score_str))-14, 14, 0, ANIMATION_NONE); @@ -469,6 +474,14 @@ void input_human( Player* player, bool up, bool down, bool hit, bool use_mouse, * this way, keyboard control still works when mouse control is * enabled. **/ + if (use_mouse && (down || up || hit)) { + /** + * this is here so if the user decides to play + * with keyboard controls, we will lock the + * mouse and disable displaying the mouse cursor + **/ + player->mouse_locked = true; + } if (use_mouse && !down && !up && !hit) { mb = SDL_GetMouseState(&(player->mouse_x), &(player->mouse_y)); if (mb&SDL_BUTTON(SDL_BUTTON_LEFT)) { diff --git a/game.h b/game.h index 6778736..4272c61 100644 --- a/game.h +++ b/game.h @@ -169,7 +169,7 @@ typedef struct { #define MOVE_Y_SEED 3 /* Comment out the following #define to enable mouse control */ -//#define ENABLE_MOUSE +#define ENABLE_MOUSE /* Comment the following #define to disable FPS limiting */ #define ENABLE_FPS_LIMIT -- 2.11.4.GIT