40
src/main.c
40
src/main.c
@@ -97,9 +97,10 @@ uint8_t menu_background_color[3] = {0, 255, 255};
|
|||||||
char menu_background_color_index; // 1 or -1, is used to cycle between the colors of the menu
|
char menu_background_color_index; // 1 or -1, is used to cycle between the colors of the menu
|
||||||
|
|
||||||
menu_window_state menu_active_window;
|
menu_window_state menu_active_window;
|
||||||
uint8_t menu_selected_window; // 0 is how to play, 1 is ship color select, 2 is game
|
uint8_t menu_selected_window; // 0 is how to play, 1 is ship color select, 2 is game
|
||||||
uint8_t menu_left_right_pressed; // 0 is none, 1 is left, 2 is right
|
uint8_t menu_left_right_pressed; // 0 is none, 1 is left, 2 is right
|
||||||
uint8_t last_menu_left_right_pressed; // what we pressed last update loop
|
uint8_t last_menu_left_right_pressed; // what we pressed last update loop
|
||||||
|
uint8_t menu_needs_to_switch;
|
||||||
timing_timer menu_selected_window_input_delay_timer = {0, 300, 0}; // 0 as starting time, 300 ms timeout, not elapsed
|
timing_timer menu_selected_window_input_delay_timer = {0, 300, 0}; // 0 as starting time, 300 ms timeout, not elapsed
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,6 +141,7 @@ void init_variables()
|
|||||||
menu_selected_window = MENU_WINDOW_TUTORIAL;
|
menu_selected_window = MENU_WINDOW_TUTORIAL;
|
||||||
menu_left_right_pressed = MENU_LEFT_RIGHT_NONE;
|
menu_left_right_pressed = MENU_LEFT_RIGHT_NONE;
|
||||||
last_menu_left_right_pressed = MENU_LEFT_RIGHT_NONE;
|
last_menu_left_right_pressed = MENU_LEFT_RIGHT_NONE;
|
||||||
|
menu_needs_to_switch = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ################################################################
|
// ################################################################
|
||||||
@@ -440,20 +442,28 @@ void update_menu()
|
|||||||
{
|
{
|
||||||
if (menu_left_right_pressed == MENU_LEFT_RIGHT_LEFT) // left
|
if (menu_left_right_pressed == MENU_LEFT_RIGHT_LEFT) // left
|
||||||
{
|
{
|
||||||
menu_selected_window -= 1;
|
menu_needs_to_switch = !menu_needs_to_switch;
|
||||||
if (menu_selected_window == 255)
|
if (menu_needs_to_switch)
|
||||||
menu_selected_window = MENU_WINDOW_START;
|
{
|
||||||
menu_left_right_pressed = MENU_LEFT_RIGHT_NONE;
|
menu_selected_window -= 1;
|
||||||
menu_selected_window_input_delay_timer.elapsed = 0;
|
if (menu_selected_window == 255)
|
||||||
|
menu_selected_window = MENU_WINDOW_START;
|
||||||
|
menu_left_right_pressed = MENU_LEFT_RIGHT_NONE;
|
||||||
|
menu_selected_window_input_delay_timer.elapsed = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (menu_left_right_pressed == MENU_LEFT_RIGHT_RIGHT) // right
|
if (menu_left_right_pressed == MENU_LEFT_RIGHT_RIGHT) // right
|
||||||
{
|
{
|
||||||
menu_selected_window += 1;
|
menu_needs_to_switch = !menu_needs_to_switch;
|
||||||
if (menu_selected_window == 3)
|
if (menu_needs_to_switch)
|
||||||
menu_selected_window = MENU_WINDOW_TUTORIAL;
|
{
|
||||||
menu_left_right_pressed = MENU_LEFT_RIGHT_NONE;
|
menu_selected_window += 1;
|
||||||
menu_selected_window_input_delay_timer.elapsed = 0;
|
if (menu_selected_window == 3)
|
||||||
|
menu_selected_window = MENU_WINDOW_TUTORIAL;
|
||||||
|
menu_left_right_pressed = MENU_LEFT_RIGHT_NONE;
|
||||||
|
menu_selected_window_input_delay_timer.elapsed = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -600,13 +610,12 @@ void update()
|
|||||||
if (pad.buttons & SCE_CTRL_CROSS)
|
if (pad.buttons & SCE_CTRL_CROSS)
|
||||||
cross_pressed = 1;
|
cross_pressed = 1;
|
||||||
|
|
||||||
//TODO check on button release?
|
//TODO check on button release?
|
||||||
if (pad.buttons & SCE_CTRL_LEFT)
|
if (pad.buttons & SCE_CTRL_LEFT)
|
||||||
menu_left_right_pressed = MENU_LEFT_RIGHT_LEFT;
|
menu_left_right_pressed = MENU_LEFT_RIGHT_LEFT;
|
||||||
if (pad.buttons & SCE_CTRL_RIGHT)
|
if (pad.buttons & SCE_CTRL_RIGHT)
|
||||||
menu_left_right_pressed = MENU_LEFT_RIGHT_RIGHT;
|
menu_left_right_pressed = MENU_LEFT_RIGHT_RIGHT;
|
||||||
|
|
||||||
|
|
||||||
ctrl_input_get_leftstick(&pad, &left_stick);
|
ctrl_input_get_leftstick(&pad, &left_stick);
|
||||||
|
|
||||||
// ctrl_input_get_rightstick(&pad, &right_stick);
|
// ctrl_input_get_rightstick(&pad, &right_stick);
|
||||||
@@ -638,7 +647,6 @@ void update()
|
|||||||
// ------------------------ DRAW FUNCTIONS ------------------
|
// ------------------------ DRAW FUNCTIONS ------------------
|
||||||
// ################################################################
|
// ################################################################
|
||||||
|
|
||||||
|
|
||||||
void draw_start()
|
void draw_start()
|
||||||
{
|
{
|
||||||
unsigned int text_color;
|
unsigned int text_color;
|
||||||
|
|||||||
Reference in New Issue
Block a user