add screensaver and optimize performance

Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
2025-06-19 23:21:43 +02:00
parent 3ac9565007
commit d3dd96c93a
20 changed files with 402 additions and 21 deletions

View File

@@ -0,0 +1,37 @@
#pragma once
#include "MenuOptions.h"
#include "common/Widget.h"
#include <cstdlib>
#include <vector>
class ScreenSaver final : public Widget
{
public:
explicit ScreenSaver(menu_options_t *options);
void update(uint64_t dt) override;
void render() override;
void onButtonClicked(ButtonType button) override;
private:
struct Star
{
float x;
float y;
float z;
float speed;
};
menu_options_t *m_options;
uint64_t m_animationCounter;
std::vector<Star> m_stars;
static constexpr int NUM_STARS = 10;
static constexpr float SPEED_MULTIPLIER = 0.02f;
static constexpr float Z_NEAR = 0.1f;
static constexpr float Z_FAR = 10.0f;
void initStars();
void resetStar(Star &star);
};