mirror of
https://github.com/NickTheFox99/ChristmOS.git
synced 2026-06-28 16:55:11 -04:00
Finish creating singular lights
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "light.h"
|
||||
#include "../consts.cpp"
|
||||
#include "Vector2.hpp"
|
||||
#include "raylib.h"
|
||||
|
||||
namespace Lights {
|
||||
Light::Light(raylib::Vector2 position, raylib::Color color1,
|
||||
@@ -8,6 +9,7 @@ Light::Light(raylib::Vector2 position, raylib::Color color1,
|
||||
int startingCycle)
|
||||
: position(position), radius(radius), color1(color1), color2(color2),
|
||||
state(startingState), cycle(startingCycle) {};
|
||||
Light::~Light() = default;
|
||||
|
||||
void Light::Update() {
|
||||
cycle++;
|
||||
@@ -15,7 +17,18 @@ void Light::Update() {
|
||||
SwitchState();
|
||||
}
|
||||
|
||||
void Light::SwitchState() {
|
||||
switch (state) { case Lights::LightState::color1: }
|
||||
void Light::Draw() {
|
||||
DrawCircleV(position, radius,
|
||||
(state == Lights::LightState::color1) ? color1 : color2);
|
||||
}
|
||||
|
||||
Lights::LightState Light::SwitchState() {
|
||||
switch (state) {
|
||||
case Lights::LightState::color1:
|
||||
return state = Lights::LightState::color2;
|
||||
case Lights::LightState::color2:
|
||||
return state = Lights::LightState::color1;
|
||||
}
|
||||
return state;
|
||||
}
|
||||
} // namespace Lights
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
~Light();
|
||||
|
||||
private:
|
||||
void SwitchState();
|
||||
LightState SwitchState();
|
||||
|
||||
raylib::Vector2 position;
|
||||
int radius;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#include "Vector2.hpp"
|
||||
#include "consts.cpp"
|
||||
#include "lights/light.h"
|
||||
#include "snow/manager.h"
|
||||
#include <raylib-cpp.hpp>
|
||||
#include <raylib.h>
|
||||
@@ -19,6 +21,9 @@ raylib::RenderTexture2D target(SCREEN_WIDTH, SCREEN_HEIGHT);
|
||||
|
||||
Snow::Manager sMgr;
|
||||
|
||||
Lights::Light tLight(raylib::Vector2(160, 120), raylib::Color::Green(),
|
||||
raylib::Color::Red(), 5, Lights::color1, 0);
|
||||
|
||||
int main(void) {
|
||||
window.SetMinSize({320, 240});
|
||||
window.SetTargetFPS(60);
|
||||
@@ -43,11 +48,13 @@ void MainLoop() {
|
||||
MIN((float)winWidth / SCREEN_WIDTH, (float)winHeight / SCREEN_HEIGHT);
|
||||
|
||||
sMgr.Update();
|
||||
tLight.Update();
|
||||
|
||||
target.BeginMode();
|
||||
{
|
||||
ClearBackground(BLACK);
|
||||
sMgr.Draw();
|
||||
tLight.Draw();
|
||||
}
|
||||
target.EndMode();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user