Full screen skelly. Increase hit zone.

This commit is contained in:
Gordon Weeks 2026-01-31 03:47:24 -08:00
parent a092de9d35
commit f16e4e0c6f
2 changed files with 37 additions and 13 deletions

View File

@ -1,12 +1,15 @@
#pragma once #pragma once
#include "engine/prefabs/includes.h" #include "engine/prefabs/includes.h"
#include <algorithm>
class Background : public GameObject { class Background : public GameObject
{
public: public:
AnimationController *animation; AnimationController* animation = nullptr;
void init() override { void init() override
{
animation = add_component<AnimationController>(); animation = add_component<AnimationController>();
animation->add_animation("skelly", std::vector<std::string>{ animation->add_animation("skelly", std::vector<std::string>{
"assets/skelly/skel_1.png", "assets/skelly/skel_1.png",
@ -33,5 +36,23 @@ class Background : public GameObject {
"assets/skelly/skel_22.png" "assets/skelly/skel_22.png"
}, 10.0f); }, 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<float>(tex.width);
float th = static_cast<float>(tex.height);
float sw = static_cast<float>(GetScreenWidth());
float sh = static_cast<float>(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;
}
}; };

View File

@ -15,6 +15,7 @@ constexpr int LANE_COUNT = 12;
constexpr int MAX_INSTRUMENT_TYPES = 8; constexpr int MAX_INSTRUMENT_TYPES = 8;
constexpr int MAX_GAMEPADS = 4; constexpr int MAX_GAMEPADS = 4;
constexpr float RECEPTOR_HEIGHT = 150.0f; constexpr float RECEPTOR_HEIGHT = 150.0f;
constexpr float HIT_ZONE_MARGIN = 20.0f;
constexpr float SCROLL_PX_PER_SEC = 350.0f; constexpr float SCROLL_PX_PER_SEC = 350.0f;
constexpr float LEAD_OFFSET_SECONDS = 3.0f; constexpr float LEAD_OFFSET_SECONDS = 3.0f;
@ -344,7 +345,7 @@ public:
bool is_note_hittable(const Glyph& n) const bool is_note_hittable(const Glyph& n) const
{ {
float y = glyph_y(n); 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) void consume_note(Glyph* n)
@ -418,7 +419,7 @@ public:
{ {
Glyph* n = *it; Glyph* n = *it;
float y = glyph_y(*n); 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; miss_flash_timer[n->lane] = MISS_FLASH_DURATION;
completed_notes.insert(n); completed_notes.insert(n);
@ -492,18 +493,20 @@ public:
} }
} }
void draw_scene() override
{
if (background)
{
background->draw_object();
}
draw();
}
void draw() override void draw() override
{ {
ClearBackground(Color{30, 30, 46, 255});
for (int lane = 0; lane < LANE_COUNT; lane++) for (int lane = 0; lane < LANE_COUNT; lane++)
{ {
float cx = lane_center_x(lane); float cx = lane_center_x(lane);
DrawRectangle(static_cast<int>(lane * lane_width),
0,
static_cast<int>(lane_width),
static_cast<int>(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}); DrawLineEx(Vector2{cx, 0}, Vector2{cx, screen_height}, 2.0f, Color{70, 70, 90, 255});
} }