summaryrefslogtreecommitdiff
path: root/src/rb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rb.c')
-rw-r--r--src/rb.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/rb.c b/src/rb.c
index 7486d93..83a7f28 100644
--- a/src/rb.c
+++ b/src/rb.c
@@ -47,6 +47,9 @@ initialize_allegro(struct rb **p)
if (!al_install_keyboard())
goto err_alloc;
+ if (!al_install_mouse())
+ goto err_alloc;
+
rb->timer = al_create_timer(rb->fps);
if (!rb->timer)
goto err_alloc;
@@ -102,6 +105,9 @@ register_events(struct rb *rb)
al_get_display_event_source(rb->display));
al_register_event_source(rb->event_queue,
al_get_timer_event_source(rb->timer));
+ al_register_event_source(rb->event_queue,
+ al_get_mouse_event_source());
+ al_hide_mouse_cursor(rb->display);
}
void
@@ -145,6 +151,11 @@ start_game(struct rb *rb)
redraw = true;
break;
+ case ALLEGRO_EVENT_MOUSE_AXES:
+ x = event.mouse.x;
+ y = event.mouse.y;
+ break;
+
case ALLEGRO_EVENT_KEY_DOWN:
key[event.keyboard.keycode] = KEY_SEEN | KEY_DOWN;
break;
@@ -180,7 +191,7 @@ start_game(struct rb *rb)
al_draw_textf(rb->font, al_map_rgb(255, 255, 255),
0, 0, 0,
"X: %.1f Y: %.1f", x, y);
- al_draw_filled_rectangle(x, y, x+10, y+10,
+ al_draw_filled_rectangle(x, y, x+40, y+120,
al_map_rgb(255, 0, 0));
al_flip_display();