From f16e4e0c6fc649624d91ad0b54346b5bf07ac507 Mon Sep 17 00:00:00 2001 From: Gordon Weeks <627684+gcweeks@users.noreply.github.com> Date: Sat, 31 Jan 2026 03:47:24 -0800 Subject: [PATCH] Full screen skelly. Increase hit zone. --- src/samples/background.h | 29 +++++++++++++++++++++++++---- src/samples/ghhb_game.h | 21 ++++++++++++--------- 2 files changed, 37 insertions(+), 13 deletions(-) diff --git a/src/samples/background.h b/src/samples/background.h index 9cedd97..60c54f9 100644 --- a/src/samples/background.h +++ b/src/samples/background.h @@ -1,12 +1,15 @@ #pragma once #include "engine/prefabs/includes.h" +#include -class Background : public GameObject { - public: - AnimationController *animation; +class Background : public GameObject +{ +public: + AnimationController* animation = nullptr; - void init() override { + void init() override + { animation = add_component(); animation->add_animation("skelly", std::vector{ "assets/skelly/skel_1.png", @@ -33,5 +36,23 @@ class Background : public GameObject { "assets/skelly/skel_22.png" }, 10.0f); } + + void draw() override + { + if (!animation || !animation->current_animation || animation->current_animation->frames.empty()) + { + return; + } + const Texture2D& tex = + animation->current_animation->frames[animation->current_animation->current_frame]; + float tw = static_cast(tex.width); + float th = static_cast(tex.height); + float sw = static_cast(GetScreenWidth()); + float sh = static_cast(GetScreenHeight()); + float scale = std::max(sw / tw, sh / th); + animation->position = {sw / 2.0f, sh / 2.0f}; + animation->origin = {tw / 2.0f, th / 2.0f}; + animation->scale = scale; + } }; diff --git a/src/samples/ghhb_game.h b/src/samples/ghhb_game.h index 4f127aa..d09e640 100644 --- a/src/samples/ghhb_game.h +++ b/src/samples/ghhb_game.h @@ -15,6 +15,7 @@ constexpr int LANE_COUNT = 12; constexpr int MAX_INSTRUMENT_TYPES = 8; constexpr int MAX_GAMEPADS = 4; constexpr float RECEPTOR_HEIGHT = 150.0f; +constexpr float HIT_ZONE_MARGIN = 20.0f; constexpr float SCROLL_PX_PER_SEC = 350.0f; constexpr float LEAD_OFFSET_SECONDS = 3.0f; @@ -344,7 +345,7 @@ public: bool is_note_hittable(const Glyph& n) const { float y = glyph_y(n); - return y >= upper_bar_y && y <= hit_line_y; + return y >= upper_bar_y - HIT_ZONE_MARGIN && y <= hit_line_y + HIT_ZONE_MARGIN; } void consume_note(Glyph* n) @@ -418,7 +419,7 @@ public: { Glyph* n = *it; float y = glyph_y(*n); - if (y > hit_line_y) + if (y > hit_line_y + HIT_ZONE_MARGIN) { miss_flash_timer[n->lane] = MISS_FLASH_DURATION; completed_notes.insert(n); @@ -492,18 +493,20 @@ public: } } + void draw_scene() override + { + if (background) + { + background->draw_object(); + } + draw(); + } + void draw() override { - ClearBackground(Color{30, 30, 46, 255}); - for (int lane = 0; lane < LANE_COUNT; lane++) { float cx = lane_center_x(lane); - DrawRectangle(static_cast(lane * lane_width), - 0, - static_cast(lane_width), - static_cast(screen_height), - lane % 2 == 0 ? Color{50, 50, 70, 255} : Color{45, 45, 65, 255}); DrawLineEx(Vector2{cx, 0}, Vector2{cx, screen_height}, 2.0f, Color{70, 70, 90, 255}); }