mirror of
https://github.com/zoriya/Bomberman.git
synced 2026-05-27 08:13:18 +00:00
Fixing movements
This commit is contained in:
+23
-25
@@ -6,15 +6,28 @@
|
||||
*/
|
||||
|
||||
#include "Window.hpp"
|
||||
|
||||
#include <utility>
|
||||
#include <stdexcept>
|
||||
#include "Controllers/Mouse.hpp"
|
||||
#include "Drawables/ADrawable2D.hpp"
|
||||
#include "Drawables/ADrawable3D.hpp"
|
||||
|
||||
RAY::Window &RAY::Window::getInstance(int width, int height, const std::string &title, unsigned flags, bool openNow)
|
||||
std::optional<RAY::Window> RAY::Window::_instance = std::nullopt;
|
||||
|
||||
RAY::Window &RAY::Window::getInstance()
|
||||
{
|
||||
static RAY::Window window(width, height, title, flags, openNow);
|
||||
if (!RAY::Window::_instance.has_value())
|
||||
throw std::runtime_error("No window has been constructed.");
|
||||
return RAY::Window::_instance.value();
|
||||
}
|
||||
|
||||
return window;
|
||||
RAY::Window &RAY::Window::getInstance(int width, int height, const std::string &title, unsigned flags, bool openNow) noexcept
|
||||
{
|
||||
if (!RAY::Window::_instance.has_value()){
|
||||
RAY::Window window(width, height, title, flags, openNow);
|
||||
RAY::Window::_instance.emplace(std::move(window));
|
||||
}
|
||||
return RAY::Window::_instance.value();
|
||||
}
|
||||
|
||||
RAY::Window::Window(int width, int height, std::string title, unsigned flags, bool openNow):
|
||||
@@ -22,7 +35,7 @@ RAY::Window::Window(int width, int height, std::string title, unsigned flags, bo
|
||||
_title(std::move(title)),
|
||||
_isOpen(openNow),
|
||||
_flags(flags),
|
||||
_drawingState(IDLE), _displayState(NONE)
|
||||
_displayState(NONE)
|
||||
{
|
||||
if (openNow)
|
||||
this->open();
|
||||
@@ -89,25 +102,15 @@ void RAY::Window::setFPS(unsigned int fps)
|
||||
SetTargetFPS(fps);
|
||||
}
|
||||
|
||||
void RAY::Window::clear(const RAY::Color &color)
|
||||
void RAY::Window::clear(RAY::Color color)
|
||||
{
|
||||
ClearBackground(color);
|
||||
}
|
||||
|
||||
void RAY::Window::setDrawingState(enum RAY::Window::drawingState state)
|
||||
void RAY::Window::draw()
|
||||
{
|
||||
if (state == this->_drawingState)
|
||||
return;
|
||||
switch (state)
|
||||
{
|
||||
case DRAWING:
|
||||
BeginDrawing();
|
||||
break;
|
||||
case IDLE:
|
||||
EndDrawing();
|
||||
break;
|
||||
}
|
||||
this->_drawingState = state;
|
||||
EndDrawing();
|
||||
BeginDrawing();
|
||||
}
|
||||
|
||||
void RAY::Window::useCamera(RAY::Camera::Camera2D &camera)
|
||||
@@ -160,12 +163,7 @@ void RAY::Window::draw(const Mesh &mesh, const Material &material, const Matrix
|
||||
DrawMesh(mesh, material, transform);
|
||||
}
|
||||
|
||||
void RAY::Window::draw(const RAY::Model &model, const RAY::Vector3 &position, const RAY::Vector3 &rotationAxis, float rotationAngle, const RAY::Vector3 &scale, const RAY::Color &tint)
|
||||
{
|
||||
DrawModelEx(model, position, rotationAxis, rotationAngle, scale, tint);
|
||||
}
|
||||
|
||||
void RAY::Window::setIcon(RAY::Image &img)
|
||||
{
|
||||
SetWindowIcon(img);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user