Fix snow instantiation & position

This commit is contained in:
Maple Redleaf
2025-12-12 11:47:56 -06:00
parent 795b54a90a
commit 2c15d64ab3
2 changed files with 9 additions and 12 deletions

View File

@@ -5,17 +5,13 @@
#include <raylib.h> #include <raylib.h>
namespace Snow { namespace Snow {
Snow::Snow() { Snow(GetRandomValue(0, 320)); } Snow::Snow() : Snow(GetRandomValue(0, 320)) {}
Snow::Snow(uint x) { Snow(raylib::Vector2(x, 0)); } Snow::Snow(int x) : Snow(raylib::Vector2(x, 0)) {}
Snow::Snow(raylib::Vector2 pos) { Snow::Snow(raylib::Vector2 pos) : position(pos) {}
position = pos;
currCycle = 0;
live = true;
}
void Snow::Move() { void Snow::Move() {
raylib::Vector2 move; raylib::Vector2 move;
uint hMove = GetRandomValue(0, INV_CHANCE); int hMove = GetRandomValue(0, INV_CHANCE);
if (hMove <= 1) { if (hMove <= 1) {
hMove = hMove * 2 - 1; hMove = hMove * 2 - 1;
} else { } else {
@@ -29,8 +25,9 @@ void Snow::Move() {
bool Snow::IsAlive() { return live; } bool Snow::IsAlive() { return live; }
void Snow::CheckLive() { void Snow::CheckLive() {
if (position.y >= SCREEN_HEIGHT) if (position.y >= SCREEN_HEIGHT) {
live = false; live = false;
}
} }
void Snow::Update() { void Snow::Update() {

View File

@@ -5,7 +5,7 @@ namespace Snow {
class Snow { class Snow {
public: public:
Snow(); Snow();
Snow(uint x); Snow(int x);
Snow(raylib::Vector2 pos); Snow(raylib::Vector2 pos);
void Update(); void Update();
@@ -16,8 +16,8 @@ public:
private: private:
raylib::Vector2 position; raylib::Vector2 position;
uint currCycle; uint currCycle = 0;
bool live; bool live = true;
inline void Move(); inline void Move();
inline void CheckLive(); inline void CheckLive();