summaryrefslogtreecommitdiffstats
path: root/src/main-menu.c
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-18 19:08:32 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-18 19:10:07 (EDT)
commitb9b74df6999a4caa1832e52982a40e6d7a656cc0 (patch)
tree6c16f8fa69548e64bbddd0576c0675fbdbf2d11a /src/main-menu.c
parent780e50396c7d4b60e8a3483fa962962ea7481fe4 (diff)
downloaddodge-balls-b9b74df6999a4caa1832e52982a40e6d7a656cc0.zip
dodge-balls-b9b74df6999a4caa1832e52982a40e6d7a656cc0.tar.gz
dodge-balls-b9b74df6999a4caa1832e52982a40e6d7a656cc0.tar.bz2
main-menu: Render all buttons in one loop
Diffstat (limited to 'src/main-menu.c')
-rw-r--r--src/main-menu.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/src/main-menu.c b/src/main-menu.c
index 4a46380..243fcdd 100644
--- a/src/main-menu.c
+++ b/src/main-menu.c
@@ -153,8 +153,6 @@ db_main_menu(void)
}
buttons[0]->rect.x = 640 - 16 - buttons[0]->rect.w;
buttons[0]->rect.y = 16;
- SDL_RenderCopy(renderer, buttons[0]->texture_text, NULL,
- &buttons[0]->rect);
/* Render quit button */
buttons[1] = malloc(sizeof(**buttons));
@@ -174,8 +172,6 @@ db_main_menu(void)
}
buttons[1]->rect.x = 640 - 16 - buttons[1]->rect.w;
buttons[1]->rect.y = 48;
- SDL_RenderCopy(renderer, buttons[1]->texture_text, NULL,
- &buttons[1]->rect);
/* Render game buttons */
buttons[1]->n = buttons[0]; /* Quit button link (may change below) */
@@ -194,20 +190,18 @@ db_main_menu(void)
}
sprintf(name_desc, "%s\n%s", db_game_get_name(games[i]),
db_game_get_desc(games[i]));
+ buttons[i + 2]->rect.x = 16;
+ buttons[i + 2]->rect.y = 80 + 48 * i + 2;
buttons[i + 2]->texture_text = _db_main_menu_text(font,
name_desc, &text_color, 608, renderer,
- &dest_rect);
+ &buttons[i + 2]->rect);
if (buttons[i + 2]->texture_text == NULL) {
free(name_desc);
goto err;
}
- dest_rect.x = 16;
- dest_rect.y = 80 + 48 * i + 2;
- SDL_RenderCopy(renderer, buttons[i + 2]->texture_text, NULL,
- &dest_rect);
buttons[i + 2]->texture_over = _db_main_menu_text(font,
name_desc, &over_color, 608, renderer,
- &dest_rect);
+ &buttons[i + 2]->rect);
free(name_desc);
if (buttons[i + 2]->texture_over == NULL) {
goto err;
@@ -248,6 +242,11 @@ db_main_menu(void)
buttons[1]->r = NULL;
buttons[1]->p = buttons[0];
+ for (i = 0; i < n + 2; ++i) {
+ SDL_RenderCopy(renderer, buttons[i]->texture_text, NULL,
+ &buttons[i]->rect);
+ }
+
SDL_RenderPresent(renderer);
SDL_Delay(1000);