diff --git a/assets/ui/switch_button_a.png b/assets/ui/switch_button_a.png new file mode 100644 index 0000000..9202083 Binary files /dev/null and b/assets/ui/switch_button_a.png differ diff --git a/assets/ui/switch_button_b.png b/assets/ui/switch_button_b.png new file mode 100644 index 0000000..acbc022 Binary files /dev/null and b/assets/ui/switch_button_b.png differ diff --git a/assets/ui/switch_button_l.png b/assets/ui/switch_button_l.png new file mode 100644 index 0000000..4d175ee Binary files /dev/null and b/assets/ui/switch_button_l.png differ diff --git a/assets/ui/switch_button_r.png b/assets/ui/switch_button_r.png new file mode 100644 index 0000000..0d3d20a Binary files /dev/null and b/assets/ui/switch_button_r.png differ diff --git a/assets/ui/switch_button_x.png b/assets/ui/switch_button_x.png new file mode 100644 index 0000000..a7949a5 Binary files /dev/null and b/assets/ui/switch_button_x.png differ diff --git a/assets/ui/switch_button_y.png b/assets/ui/switch_button_y.png new file mode 100644 index 0000000..1f854de Binary files /dev/null and b/assets/ui/switch_button_y.png differ diff --git a/assets/ui/switch_button_zl.png b/assets/ui/switch_button_zl.png new file mode 100644 index 0000000..8e23733 Binary files /dev/null and b/assets/ui/switch_button_zl.png differ diff --git a/assets/ui/switch_button_zr.png b/assets/ui/switch_button_zr.png new file mode 100644 index 0000000..67eaa0d Binary files /dev/null and b/assets/ui/switch_button_zr.png differ diff --git a/assets/ui/switch_dpad_down.png b/assets/ui/switch_dpad_down.png new file mode 100644 index 0000000..8462aca Binary files /dev/null and b/assets/ui/switch_dpad_down.png differ diff --git a/assets/ui/switch_dpad_left.png b/assets/ui/switch_dpad_left.png new file mode 100644 index 0000000..bd7f2c6 Binary files /dev/null and b/assets/ui/switch_dpad_left.png differ diff --git a/assets/ui/switch_dpad_right.png b/assets/ui/switch_dpad_right.png new file mode 100644 index 0000000..0b0f4bd Binary files /dev/null and b/assets/ui/switch_dpad_right.png differ diff --git a/assets/ui/switch_dpad_up.png b/assets/ui/switch_dpad_up.png new file mode 100644 index 0000000..e9f4571 Binary files /dev/null and b/assets/ui/switch_dpad_up.png differ diff --git a/src/samples/ghhb_game.h b/src/samples/ghhb_game.h index b105e3b..75adc7f 100644 --- a/src/samples/ghhb_game.h +++ b/src/samples/ghhb_game.h @@ -31,16 +31,16 @@ constexpr float MIN_SUSTAIN_FALLBACK_SEC = 0.05f; constexpr float MIN_GLYPH_DURATION_SEC = 0.1f; const int GAMEPAD_BUTTONS[LANE_COUNT] = { - GAMEPAD_BUTTON_LEFT_FACE_LEFT, // Left - GAMEPAD_BUTTON_LEFT_FACE_UP, // Up - GAMEPAD_BUTTON_LEFT_FACE_RIGHT, // Right - GAMEPAD_BUTTON_LEFT_FACE_DOWN, // Down - GAMEPAD_BUTTON_RIGHT_FACE_LEFT, // X - GAMEPAD_BUTTON_RIGHT_FACE_UP, // Y - GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, // B - GAMEPAD_BUTTON_RIGHT_FACE_DOWN, // A GAMEPAD_BUTTON_LEFT_TRIGGER_2, // LT GAMEPAD_BUTTON_LEFT_TRIGGER_1, // LB + GAMEPAD_BUTTON_LEFT_FACE_LEFT, // Left + GAMEPAD_BUTTON_LEFT_FACE_UP, // Up + GAMEPAD_BUTTON_LEFT_FACE_DOWN, // Down + GAMEPAD_BUTTON_LEFT_FACE_RIGHT, // Right + GAMEPAD_BUTTON_RIGHT_FACE_LEFT, // X + GAMEPAD_BUTTON_RIGHT_FACE_UP, // Y + GAMEPAD_BUTTON_RIGHT_FACE_DOWN, // A + GAMEPAD_BUTTON_RIGHT_FACE_RIGHT, // B GAMEPAD_BUTTON_RIGHT_TRIGGER_1, // RB GAMEPAD_BUTTON_RIGHT_TRIGGER_2, // RT }; @@ -49,6 +49,21 @@ const char* const GAMEPAD_BUTTON_LABELS[LANE_COUNT] = { "<", "^", ">", "v", "X", "Y", "B", "A", "LT", "LB", "RB", "RT", }; +const char* const GAMEPAD_BUTTON_ICONS[LANE_COUNT] = { + "assets/ui/switch_button_zl.png", + "assets/ui/switch_button_l.png", + "assets/ui/switch_dpad_left.png", + "assets/ui/switch_dpad_up.png", + "assets/ui/switch_dpad_down.png", + "assets/ui/switch_dpad_right.png", + "assets/ui/switch_button_x.png", + "assets/ui/switch_button_y.png", + "assets/ui/switch_button_a.png", + "assets/ui/switch_button_b.png", + "assets/ui/switch_button_r.png", + "assets/ui/switch_button_zr.png", +}; + constexpr int COMBO_TIER_COUNT = 20; constexpr int COMBO_DISPLAY_THRESHOLD = 5; constexpr int COMBO_NOTES_PER_TIER = 10; @@ -59,21 +74,6 @@ const char* const COMBO_TIER_LABELS[COMBO_TIER_COUNT] = { "Stellar!", "Legendary!", "Epic!", "Divine!", "Godlike!", }; -const int KEY_KEYS[LANE_COUNT] = { - KEY_Q, - KEY_W, - KEY_E, - KEY_R, - KEY_A, - KEY_S, - KEY_D, - KEY_F, - KEY_Z, - KEY_X, - KEY_C, - KEY_V, -}; - /* One color per track (track index % MAX_INSTRUMENT_TYPES). */ const Color INSTRUMENT_COLORS[MAX_INSTRUMENT_TYPES] = { {220, 100, 100, 255}, // red @@ -472,10 +472,6 @@ public: bool is_lane_pressed(int lane) const { - if (IsKeyPressed(KEY_KEYS[lane])) - { - return true; - } for (int i = 0; i < MAX_GAMEPADS; i++) { if (IsGamepadAvailable(i) && IsGamepadButtonPressed(i, GAMEPAD_BUTTONS[lane])) @@ -989,17 +985,17 @@ public: } } - const float button_label_font_size = 28.0f; - float label_height = MeasureTextEx(font, "X", button_label_font_size, 1).y; - float button_label_y = (upper_bar_y + hit_line_y) / 2.0f - label_height / 2.0f; + const float button_icon_height = 50.0f; + float button_icon_y = (upper_bar_y + hit_line_y) / 2.0f - button_icon_height / 2.0f; + auto* tex_svc = get_service(); for (int lane = 0; lane < LANE_COUNT; lane++) { - const char* label = GAMEPAD_BUTTON_LABELS[lane]; - float label_w = MeasureTextEx(font, label, button_label_font_size, 1).x; + Texture2D& tex = tex_svc->get_texture(GAMEPAD_BUTTON_ICONS[lane]); + float scale = button_icon_height / static_cast(tex.height); + float w = static_cast(tex.width) * scale; float cx = lane_center_x(lane); - DrawTextEx(font, label, - {cx - label_w / 2.0f, button_label_y}, - button_label_font_size, 1, Color{220, 220, 240, 255}); + DrawTextureEx(tex, {cx - w / 2.0f, button_icon_y}, 0.0f, scale, + Color{220, 220, 240, 255}); } std::string score_text = "Score: " + std::to_string(score);