mirror of
https://github.com/zoriya/Bomberman.git
synced 2025-12-21 13:55:10 +00:00
sources and include in the same folder
This commit is contained in:
129
lib/Ray/sources/Window.cpp
Normal file
129
lib/Ray/sources/Window.cpp
Normal file
@@ -0,0 +1,129 @@
|
||||
/*
|
||||
** EPITECH PROJECT, 2021
|
||||
** Bomberman
|
||||
** File description:
|
||||
** Window
|
||||
*/
|
||||
|
||||
#include "Window.hpp"
|
||||
#include "Controllers/Mouse.hpp"
|
||||
|
||||
RAY::Window::Window(int width, int height, const std::string title, bool openNow):
|
||||
_dimensions({(float)width, (float)height}), _title(title), _isOpen(openNow)
|
||||
{
|
||||
if (openNow)
|
||||
this->open();
|
||||
}
|
||||
|
||||
bool RAY::Window::open(void)
|
||||
{
|
||||
InitWindow(this->_dimensions.x, this->_dimensions.y, this->_title.c_str());
|
||||
this->_isOpen = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool RAY::Window::shouldClose(void) const
|
||||
{
|
||||
return WindowShouldClose();
|
||||
}
|
||||
|
||||
void RAY::Window::close(void)
|
||||
{
|
||||
CloseWindow();
|
||||
}
|
||||
|
||||
bool RAY::Window::isFocused(void) const
|
||||
{
|
||||
return IsWindowFocused();
|
||||
}
|
||||
|
||||
const RAY::Vector2 &RAY::Window::getDimensions(void) const
|
||||
{
|
||||
return this->_dimensions;
|
||||
}
|
||||
|
||||
void RAY::Window::setVisibleCursor(bool visible)
|
||||
{
|
||||
if (visible)
|
||||
ShowCursor();
|
||||
else
|
||||
HideCursor();
|
||||
}
|
||||
|
||||
void RAY::Window::enableCursor(bool enable)
|
||||
{
|
||||
if (enable)
|
||||
EnableCursor();
|
||||
else
|
||||
DisableCursor();
|
||||
}
|
||||
|
||||
bool RAY::Window::cursorIsVisible(void) const
|
||||
{
|
||||
return !IsCursorHidden();
|
||||
}
|
||||
|
||||
Vector2 RAY::Window::getCursorPosition(void) const
|
||||
{
|
||||
return RAY::Controller::Mouse::getCursorPosition();
|
||||
}
|
||||
|
||||
void RAY::Window::setFPS(unsigned int fps)
|
||||
{
|
||||
SetTargetFPS(fps);
|
||||
}
|
||||
|
||||
void RAY::Window::clear(const RAY::Color &color)
|
||||
{
|
||||
ClearBackground(color.getColor());
|
||||
}
|
||||
|
||||
void RAY::Window::beginDrawing(void)
|
||||
{
|
||||
::BeginDrawing();
|
||||
}
|
||||
|
||||
void RAY::Window::endDrawing(void)
|
||||
{
|
||||
::EndDrawing();
|
||||
}
|
||||
|
||||
void RAY::Window::beginMode2D(Camera::Camera2D &camera)
|
||||
{
|
||||
BeginMode2D(camera.getCamera());
|
||||
}
|
||||
|
||||
void RAY::Window::beginMode3D(Camera::Camera3D &camera)
|
||||
{
|
||||
BeginMode3D(camera.getCamera());
|
||||
}
|
||||
|
||||
void RAY::Window::endMode2D(void)
|
||||
{
|
||||
EndMode2D();
|
||||
}
|
||||
|
||||
void RAY::Window::endMode3D(void)
|
||||
{
|
||||
EndMode3D();
|
||||
}
|
||||
|
||||
void RAY::Window::setTitle(const std::string &title)
|
||||
{
|
||||
this->_title = title;
|
||||
}
|
||||
|
||||
void RAY::Window::draw(RAY::Drawables::IDrawable &drawable)
|
||||
{
|
||||
drawable.drawOn(*this);
|
||||
}
|
||||
|
||||
void RAY::Window::draw(const RAY::Texture &texture, const Vector2 &position, const Color &tint)
|
||||
{
|
||||
DrawTexture(texture.getTexture(), position.x, position.y, tint.getColor());
|
||||
}
|
||||
|
||||
void RAY::Window::draw(const Mesh &mesh, const Material &material, const Matrix &transform)
|
||||
{
|
||||
DrawMesh(mesh, material, transform);
|
||||
}
|
||||
Reference in New Issue
Block a user