summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/help.c71
1 files changed, 65 insertions, 6 deletions
diff --git a/src/help.c b/src/help.c
index 60bcdb7..39db3cb 100644
--- a/src/help.c
+++ b/src/help.c
@@ -56,6 +56,8 @@ const char *_db_help_text =
"they bounce off walls in the opposite direction. To stop, move "
"against a wall.";
+static int _db_help_quit;
+
static void
_db_help_triangle(SDL_Renderer *renderer, Uint8 r, Uint8 g, Uint8 b, Uint8 a,
int x_min, int y_min, int dir)
@@ -92,6 +94,7 @@ db_help(void)
SDL_Texture *texture;
SDL_Rect text_src_rect;
SDL_Rect text_dst_rect;
+ SDL_Event event;
font_path = db_strcat(db_get_fonts_dir(), "/UbuntuTitling-Bold.ttf");
@@ -132,10 +135,66 @@ db_help(void)
text_dst_rect.w = 592;
text_dst_rect.h = 448;
- SDL_RenderClear(renderer);
- SDL_RenderCopy(renderer, texture, &text_src_rect, &text_dst_rect);
- _db_help_triangle(renderer, 0x3F, 0x3F, 0x7F, 0xFF, 608, 16, -1);
- _db_help_triangle(renderer, 0x00, 0x00, 0xFF, 0xFF, 608, 456, 1);
- SDL_RenderPresent(renderer);
- SDL_Delay(1000);
+ _db_help_quit = 0;
+ while (SDL_WaitEvent(&event)) {
+ switch (event.type) {
+ case SDL_QUIT:
+ _db_help_quit = 1;
+ break;
+ case SDL_KEYDOWN:
+ switch (event.key.keysym.sym) {
+ case SDLK_UP:
+ text_src_rect.y -= 16;
+ if (text_src_rect.y < 0) {
+ text_src_rect.y = 0;
+ }
+ break;
+ case SDLK_DOWN:
+ text_src_rect.y += 16;
+ if (text_src_rect.y > surface->h
+ -
+ text_src_rect.h)
+ {
+ text_src_rect.y =
+ surface->h -
+ text_src_rect.h;
+ }
+ break;
+ case SDLK_HOME:
+ text_src_rect.y = 0;
+ break;
+ case SDLK_END:
+ text_src_rect.y = surface->h -
+ text_src_rect.h;
+ break;
+ default:
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ if (_db_help_quit == 1) {
+ break;
+ }
+ SDL_SetRenderDrawColor(renderer, 0x7F, 0x7F, 0x7F, 0xFF);
+ SDL_RenderClear(renderer);
+ SDL_RenderCopy(renderer, texture,
+ &text_src_rect, &text_dst_rect);
+ if (text_src_rect.y > 0) {
+ _db_help_triangle(renderer,
+ 0x00, 0x00, 0xFF, 0xFF, 608, 16, -1);
+ } else {
+ _db_help_triangle(renderer,
+ 0x3F, 0x3F, 0x7F, 0xFF, 608, 16, -1);
+ }
+ if (text_src_rect.y < surface->h - text_src_rect.h) {
+ _db_help_triangle(renderer,
+ 0x00, 0x00, 0xFF, 0xFF, 608, 456, 1);
+ } else {
+ _db_help_triangle(renderer,
+ 0x3F, 0x3F, 0x7F, 0xFF, 608, 456, 1);
+ }
+ SDL_RenderPresent(renderer);
+ }
}