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