#include "title.h" void title_handle_click_start(Game *g) { g->state = GAME_STATE_INITIALIZING; } void title_handle_click_options(Game *g) { g->state = GAME_STATE_OPTIONS; } void title_handle_click_quit(Game *g) { g->should_close = true; } Vector2 tmp; // stands for "title mouse position" void title_handle_input(Game *g) { tmp = GetMousePosition(); Title *t = g->title; t->hover_start = false; t->hover_options = false; t->hover_quit = false; t->hover_credits = false; t->hover_rules = false; int half_start_width = MeasureText("Start", 60) / 2; if (tmp.x > 700-half_start_width && tmp.x < 700+half_start_width && tmp.y > 350 && tmp.y < 410) { t->hover_start = true; if (IsMouseButtonPressed(0)) title_handle_click_start(g); } int half_options_width = MeasureText("Options", 60) / 2; if (tmp.x > 700-half_options_width && tmp.x < 700+half_options_width && tmp.y > 500 && tmp.y < 560) { t->hover_options = true; if (IsMouseButtonPressed(0)) title_handle_click_options(g); } int half_quit_width = MeasureText("Quit", 60) / 2; if (tmp.x > 700-half_quit_width && tmp.x < 700+half_quit_width && tmp.y > 650 && tmp.y < 710) { t->hover_quit = true; if (IsMouseButtonPressed(0)) title_handle_click_quit(g); } int half_credits_width = MeasureText("Credits", 40) / 2; if (tmp.x > 1100-half_credits_width && tmp.x < 1100+half_credits_width && tmp.y > 600 && tmp.y < 640) t->hover_credits = true; int half_rules_width = MeasureText("Rules", 40) / 2; if (tmp.x > 300-half_rules_width && tmp.x < 300+half_rules_width && tmp.y > 600 && tmp.y < 640) t->hover_rules = true; } void title_draw(Game *g) { Title *t = g->title; DrawTextCentered("Hanafuda Hachi-Hachi", 700, 100, 90, BLACK); DrawTextCentered("Start", 700, 350, 60, t->hover_start ? RED : BLACK); DrawTextCentered("Options", 700, 500, 60, t->hover_options ? RED : BLACK); DrawTextCentered("Quit", 700, 650, 60, t->hover_quit ? RED : BLACK); DrawTextCentered("Credits", 1100, 600, 40, t->hover_credits ? RED : BLACK); DrawTextCentered("Rules", 300, 600, 40, t->hover_rules ? RED : BLACK); }