Cleanup
This commit is contained in:
@@ -2,6 +2,6 @@
|
|||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class Camera : public Entity {
|
class Camera : public Engine::Entity {
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@@ -2,7 +2,11 @@
|
|||||||
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
#include <J3ML/LinearAlgebra/Vector2.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
class Entity {
|
namespace Engine {
|
||||||
|
class Entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Engine::Entity {
|
||||||
protected:
|
protected:
|
||||||
std::vector<Entity*> children{};
|
std::vector<Entity*> children{};
|
||||||
Vector2 position = {0, 0};
|
Vector2 position = {0, 0};
|
||||||
|
@@ -1,7 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Renderable.h"
|
#include <Engine/Entity/Renderable.h>
|
||||||
|
|
||||||
class Hud : public Renderable {
|
namespace Engine {
|
||||||
|
class Hud;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Engine::Hud : public Engine::Renderable {
|
||||||
public:
|
public:
|
||||||
Hud() : Renderable({0, 0}, 0) {};
|
Hud() : Renderable({0, 0}, 0) {};
|
||||||
};
|
};
|
||||||
|
@@ -3,7 +3,11 @@
|
|||||||
#include <Engine/Entity/Entity.h>
|
#include <Engine/Entity/Entity.h>
|
||||||
#include <JGL/JGL.h>
|
#include <JGL/JGL.h>
|
||||||
|
|
||||||
class Renderable : public Entity {
|
namespace Engine {
|
||||||
|
class Renderable;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Engine::Renderable : public Entity {
|
||||||
public:
|
public:
|
||||||
virtual void Render() {}
|
virtual void Render() {}
|
||||||
public:
|
public:
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
#include <rewindow/types/window.h>
|
#include <rewindow/types/window.h>
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
class Camera;
|
namespace Engine {
|
||||||
class DemoGameWindow : public ReWindow::RWindow {
|
class DemoGameWindow;
|
||||||
|
}
|
||||||
|
class Engine::DemoGameWindow : public ReWindow::RWindow {
|
||||||
public:
|
public:
|
||||||
void InitGL();
|
void InitGL();
|
||||||
void Display();
|
void Display();
|
||||||
|
@@ -4,6 +4,8 @@
|
|||||||
#include <Engine/GameWindow.h>
|
#include <Engine/GameWindow.h>
|
||||||
|
|
||||||
namespace Globals {
|
namespace Globals {
|
||||||
|
using namespace Engine;
|
||||||
|
|
||||||
inline std::vector<Scene*> SceneList{};
|
inline std::vector<Scene*> SceneList{};
|
||||||
inline Scene* CurrentScene = nullptr;
|
inline Scene* CurrentScene = nullptr;
|
||||||
inline DemoGameWindow* Window = nullptr;
|
inline DemoGameWindow* Window = nullptr;
|
||||||
|
@@ -7,9 +7,13 @@
|
|||||||
using J3ML::LinearAlgebra::Vector2i;
|
using J3ML::LinearAlgebra::Vector2i;
|
||||||
using JGL::Texture;
|
using JGL::Texture;
|
||||||
|
|
||||||
|
namespace Engine {
|
||||||
|
class Fixed;
|
||||||
|
}
|
||||||
|
|
||||||
// Things that are considered non-movable parts of the level.
|
// Things that are considered non-movable parts of the level.
|
||||||
// TODO instanced textures.
|
// TODO instanced textures.
|
||||||
class Fixed {
|
class Engine::Fixed {
|
||||||
private:
|
private:
|
||||||
void GenerateCollision();
|
void GenerateCollision();
|
||||||
protected:
|
protected:
|
||||||
|
@@ -5,7 +5,11 @@
|
|||||||
#include <Engine/Entity/Hud.h>
|
#include <Engine/Entity/Hud.h>
|
||||||
#include <Engine/Level/Fixed.h>
|
#include <Engine/Level/Fixed.h>
|
||||||
|
|
||||||
class Scene {
|
namespace Engine {
|
||||||
|
class Scene;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Engine::Scene {
|
||||||
protected:
|
protected:
|
||||||
std::string name;
|
std::string name;
|
||||||
Hud* HeadsUpDisplay = nullptr;
|
Hud* HeadsUpDisplay = nullptr;
|
||||||
|
@@ -1,8 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <Engine/Entity/Renderable.h>
|
#include <Engine/Entity/Renderable.h>
|
||||||
#include "Engine/Globals.h"
|
#include <Engine/Globals.h>
|
||||||
class Box final : public Renderable {
|
|
||||||
|
namespace Game {
|
||||||
|
class Box;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Game::Box final : public Engine::Renderable {
|
||||||
public:
|
public:
|
||||||
void Render() final;
|
void Render() final;
|
||||||
void Update() final;
|
void Update() final;
|
||||||
|
@@ -1,6 +1,10 @@
|
|||||||
#include <Engine/Entity/Hud.h>
|
#include <Engine/Entity/Hud.h>
|
||||||
|
|
||||||
class DemoGameHud : public Hud {
|
namespace Game {
|
||||||
|
class DemoGameHud;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Game::DemoGameHud : public Engine::Hud {
|
||||||
public:
|
public:
|
||||||
void Render() override;
|
void Render() override;
|
||||||
public:
|
public:
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Engine/Level/Scene.h>
|
#include <Engine/Level/Scene.h>
|
||||||
|
|
||||||
class ControllableBox final : public Scene {
|
class ControllableBox final : public Engine::Scene {
|
||||||
public:
|
public:
|
||||||
void Init() final;
|
void Init() final;
|
||||||
public:
|
public:
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <Engine/Level/Scene.h>
|
#include <Engine/Level/Scene.h>
|
||||||
|
|
||||||
class LoadingScreen final : public Scene {
|
class LoadingScreen final : public Engine::Scene {
|
||||||
protected:
|
protected:
|
||||||
float elapsed = 0.0f;
|
float elapsed = 0.0f;
|
||||||
float angle = 0.0f;
|
float angle = 0.0f;
|
||||||
|
9
main.cpp
9
main.cpp
@@ -14,15 +14,16 @@ void CreateScenes() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
Globals::Window = new DemoGameWindow("Demo Game", 1024, 896);
|
ReWindow::Logger::Error.EnableConsole(false);
|
||||||
|
ReWindow::Logger::Warning.EnableConsole(false);
|
||||||
|
ReWindow::Logger::Debug.EnableConsole(false);
|
||||||
|
|
||||||
|
Globals::Window = new Engine::DemoGameWindow("Demo Game", 1024, 896);
|
||||||
Globals::Window->SetRenderer(RenderingAPI::OPENGL);
|
Globals::Window->SetRenderer(RenderingAPI::OPENGL);
|
||||||
Globals::Window->Open();
|
Globals::Window->Open();
|
||||||
Globals::Window->InitGL();
|
Globals::Window->InitGL();
|
||||||
Globals::Window->SetResizable(false);
|
Globals::Window->SetResizable(false);
|
||||||
Globals::Window->SetVsyncEnabled(false);
|
Globals::Window->SetVsyncEnabled(false);
|
||||||
ReWindow::Logger::Error.EnableConsole(false);
|
|
||||||
ReWindow::Logger::Warning.EnableConsole(false);
|
|
||||||
ReWindow::Logger::Debug.EnableConsole(false);
|
|
||||||
|
|
||||||
CreateScenes();
|
CreateScenes();
|
||||||
Globals::ChangeScene("LoadingScreen");
|
Globals::ChangeScene("LoadingScreen");
|
||||||
|
@@ -1,38 +1,38 @@
|
|||||||
#include "J3ML/J3ML.hpp"
|
#include <J3ML/J3ML.hpp>
|
||||||
#include "Engine/Entity/Entity.h"
|
#include <Engine/Entity/Entity.h>
|
||||||
#include "Engine/Globals.h"
|
#include <Engine/Globals.h>
|
||||||
|
|
||||||
using namespace J3ML;
|
using namespace J3ML;
|
||||||
void Entity::MoveX(float speed) {
|
void Engine::Entity::MoveX(float speed) {
|
||||||
position.x = position.x + (speed * Globals::Window->GetDeltaTime());
|
position.x = position.x + (speed * Globals::Window->GetDeltaTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::MoveY(float speed) {
|
void Engine::Entity::MoveY(float speed) {
|
||||||
position.y = position.y + (speed * Globals::DeltaTime());
|
position.y = position.y + (speed * Globals::DeltaTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::MoveForward(float speed) {
|
void Engine::Entity::MoveForward(float speed) {
|
||||||
position.x = position.x + (speed * Globals::DeltaTime()) * Math::Cos(face_angle);
|
position.x = position.x + (speed * Globals::DeltaTime()) * Math::Cos(face_angle);
|
||||||
position.y = position.y + (speed * Globals::DeltaTime()) * Math::Sin(face_angle);
|
position.y = position.y + (speed * Globals::DeltaTime()) * Math::Sin(face_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::MoveBackward(float speed) {
|
void Engine::Entity::MoveBackward(float speed) {
|
||||||
speed = -speed;
|
speed = -speed;
|
||||||
position.x = position.x + (speed * Globals::DeltaTime()) * Math::Cos(face_angle);
|
position.x = position.x + (speed * Globals::DeltaTime()) * Math::Cos(face_angle);
|
||||||
position.y = position.y + (speed * Globals::DeltaTime()) * Math::Sin(face_angle);
|
position.y = position.y + (speed * Globals::DeltaTime()) * Math::Sin(face_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::MoveLeft(float speed) {
|
void Engine::Entity::MoveLeft(float speed) {
|
||||||
position.x = position.x + (speed * Globals::DeltaTime()) * -Math::Sin(face_angle);
|
position.x = position.x + (speed * Globals::DeltaTime()) * -Math::Sin(face_angle);
|
||||||
position.y = position.y + (speed * Globals::DeltaTime()) * Math::Cos(face_angle);
|
position.y = position.y + (speed * Globals::DeltaTime()) * Math::Cos(face_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::MoveRight(float speed) {
|
void Engine::Entity::MoveRight(float speed) {
|
||||||
position.x = position.x + (speed * Globals::DeltaTime()) * Math::Sin(face_angle);
|
position.x = position.x + (speed * Globals::DeltaTime()) * Math::Sin(face_angle);
|
||||||
position.y = position.y + (speed * Globals::DeltaTime()) * -Math::Cos(face_angle);
|
position.y = position.y + (speed * Globals::DeltaTime()) * -Math::Cos(face_angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::SetRotation(float new_face_angle) {
|
void Engine::Entity::SetRotation(float new_face_angle) {
|
||||||
face_angle = new_face_angle;
|
face_angle = new_face_angle;
|
||||||
|
|
||||||
if (face_angle < 0)
|
if (face_angle < 0)
|
||||||
@@ -41,33 +41,33 @@ void Entity::SetRotation(float new_face_angle) {
|
|||||||
face_angle = fmod(face_angle, Math::Pi * 2);
|
face_angle = fmod(face_angle, Math::Pi * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::Rotate(float speed) {
|
void Engine::Entity::Rotate(float speed) {
|
||||||
SetRotation(face_angle + speed * Globals::DeltaTime());
|
SetRotation(face_angle + speed * Globals::DeltaTime());
|
||||||
}
|
}
|
||||||
|
|
||||||
float Entity::GetRotation() const {
|
float Engine::Entity::GetRotation() const {
|
||||||
return face_angle;
|
return face_angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 Entity::GetPosition() const {
|
Vector2 Engine::Entity::GetPosition() const {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Entity::AppendChild(Entity* entity) {
|
bool Engine::Entity::AppendChild(Entity* entity) {
|
||||||
bool success = false;
|
bool success = false;
|
||||||
if (!Globals::CurrentScene->EntityListContains(entity))
|
if (!Globals::CurrentScene->EntityListContains(entity))
|
||||||
children.push_back(entity), success = true;
|
children.push_back(entity), success = true;
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity::~Entity() {
|
Engine::Entity::~Entity() {
|
||||||
for (auto* e : children)
|
for (auto* e : children)
|
||||||
delete e;
|
delete e;
|
||||||
|
|
||||||
children = {};
|
children = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::UpdateChildren() {
|
void Engine::Entity::UpdateChildren() {
|
||||||
for (auto& e : children) {
|
for (auto& e : children) {
|
||||||
e->Update();
|
e->Update();
|
||||||
if (!e->children.empty())
|
if (!e->children.empty())
|
||||||
@@ -75,13 +75,13 @@ void Entity::UpdateChildren() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::DestroyChild(Entity* entity) {
|
void Engine::Entity::DestroyChild(Entity* entity) {
|
||||||
auto it = std::find(children.begin(), children.end(), entity);
|
auto it = std::find(children.begin(), children.end(), entity);
|
||||||
if (it != children.end())
|
if (it != children.end())
|
||||||
delete *it, children.erase(it);
|
delete *it, children.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Entity::RemoveChild(Entity* entity) {
|
void Engine::Entity::RemoveChild(Entity* entity) {
|
||||||
auto it = std::find(children.begin(), children.end(), entity);
|
auto it = std::find(children.begin(), children.end(), entity);
|
||||||
if (it != children.end())
|
if (it != children.end())
|
||||||
children.erase(it);
|
children.erase(it);
|
||||||
|
@@ -1,17 +1,17 @@
|
|||||||
#include "Engine/GameWindow.h"
|
#include <Engine/GameWindow.h>
|
||||||
#include "Engine/Globals.h"
|
#include <Engine/Globals.h>
|
||||||
#include "Engine/Entity/Camera.h"
|
#include <Engine/Entity/Camera.h>
|
||||||
#include "JGL/JGL.h"
|
#include <JGL/JGL.h>
|
||||||
|
|
||||||
|
|
||||||
void DemoGameWindow::InitGL() {
|
void Engine::DemoGameWindow::InitGL() {
|
||||||
if (!JGL::Init(GetSize(), 0, 0))
|
if (!JGL::Init(GetSize(), 0, 0))
|
||||||
exit(-1);
|
exit(-1);
|
||||||
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemoGameWindow::Display() {
|
void Engine::DemoGameWindow::Display() {
|
||||||
JGL::Update(GetSize());
|
JGL::Update(GetSize());
|
||||||
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||||
@@ -24,9 +24,9 @@ void DemoGameWindow::Display() {
|
|||||||
if (Globals::CurrentScene)
|
if (Globals::CurrentScene)
|
||||||
Globals::CurrentScene->Render();
|
Globals::CurrentScene->Render();
|
||||||
|
|
||||||
DemoGameWindow::GLSwapBuffers();
|
Engine::DemoGameWindow::GLSwapBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DemoGameWindow::OnRefresh(float elapsed) {
|
void Engine::DemoGameWindow::OnRefresh(float elapsed) {
|
||||||
Display();
|
Display();
|
||||||
}
|
}
|
||||||
|
@@ -1,35 +1,35 @@
|
|||||||
#include "Engine/Level/Fixed.h"
|
#include <Engine/Level/Fixed.h>
|
||||||
|
|
||||||
bool Fixed::Collidable() const {
|
bool Engine::Fixed::Collidable() const {
|
||||||
return collidable;
|
return collidable;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2i Fixed::GetPosition() const {
|
Vector2i Engine::Fixed::GetPosition() const {
|
||||||
return position;
|
return position;
|
||||||
}
|
}
|
||||||
|
|
||||||
AABB2D Fixed::GetBounds() const {
|
AABB2D Engine::Fixed::GetBounds() const {
|
||||||
auto maximum = Vector2(position.x + texture->GetDimensions().x, position.y + texture->GetDimensions().y);
|
auto maximum = Vector2(position.x + texture->GetDimensions().x, position.y + texture->GetDimensions().y);
|
||||||
return { Vector2(position), maximum };
|
return { Vector2(position), maximum };
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Fixed::Enabled() const {
|
bool Engine::Fixed::Enabled() const {
|
||||||
return enabled;
|
return enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fixed::Enable() {
|
void Engine::Fixed::Enable() {
|
||||||
enabled = true;
|
enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fixed::Disable() {
|
void Engine::Fixed::Disable() {
|
||||||
enabled = false;
|
enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Fixed::~Fixed() {
|
Engine::Fixed::~Fixed() {
|
||||||
delete texture;
|
delete texture;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Fixed::GenerateCollision() {
|
void Engine::Fixed::GenerateCollision() {
|
||||||
if (!Collidable() || !Enabled() || !texture)
|
if (!Collidable() || !Enabled() || !texture)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@@ -43,10 +43,10 @@ void Fixed::GenerateCollision() {
|
|||||||
collision = result;
|
collision = result;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<Vector2i> Fixed::GetCollision() {
|
std::vector<Vector2i> Engine::Fixed::GetCollision() {
|
||||||
return collision;
|
return collision;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Texture* Fixed::GetTexture() {
|
const Texture* Engine::Fixed::GetTexture() {
|
||||||
return texture;
|
return texture;
|
||||||
}
|
}
|
||||||
|
@@ -1,33 +1,33 @@
|
|||||||
#include <Engine/Level/Scene.h>
|
#include <Engine/Level/Scene.h>
|
||||||
|
|
||||||
bool Scene::EntityListContains(const Entity* entity) const {
|
bool Engine::Scene::EntityListContains(const Entity* entity) const {
|
||||||
for (auto* e : EntityList)
|
for (auto* e : EntityList)
|
||||||
if (e == entity)
|
if (e == entity)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Scene::FixedListContains(const Fixed* fixed) const {
|
bool Engine::Scene::FixedListContains(const Fixed* fixed) const {
|
||||||
for (auto* f : FixedList)
|
for (auto* f : FixedList)
|
||||||
if (f == fixed)
|
if (f == fixed)
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Scene::FixedCount() const {
|
size_t Engine::Scene::FixedCount() const {
|
||||||
return FixedList.size();
|
return FixedList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t Scene::EntityCount() const {
|
size_t Engine::Scene::EntityCount() const {
|
||||||
return EntityList.size();
|
return EntityList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::Update() {
|
void Engine::Scene::Update() {
|
||||||
for (auto& e : EntityList)
|
for (auto& e : EntityList)
|
||||||
e->Update();
|
e->Update();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::Render() {
|
void Engine::Scene::Render() {
|
||||||
for (auto& f : FixedList)
|
for (auto& f : FixedList)
|
||||||
if (f->Enabled())
|
if (f->Enabled())
|
||||||
f->Render();
|
f->Render();
|
||||||
@@ -41,7 +41,7 @@ void Scene::Render() {
|
|||||||
HeadsUpDisplay->Render();
|
HeadsUpDisplay->Render();
|
||||||
}
|
}
|
||||||
|
|
||||||
Scene::~Scene() {
|
Engine::Scene::~Scene() {
|
||||||
for (auto* f : FixedList)
|
for (auto* f : FixedList)
|
||||||
delete f;
|
delete f;
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ Scene::~Scene() {
|
|||||||
delete HeadsUpDisplay;
|
delete HeadsUpDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::Unload() {
|
void Engine::Scene::Unload() {
|
||||||
for (auto* f : FixedList)
|
for (auto* f : FixedList)
|
||||||
delete f;
|
delete f;
|
||||||
|
|
||||||
@@ -61,42 +61,42 @@ void Scene::Unload() {
|
|||||||
delete HeadsUpDisplay;
|
delete HeadsUpDisplay;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::AppendEntity(Entity* entity) {
|
void Engine::Scene::AppendEntity(Entity* entity) {
|
||||||
if (!EntityListContains(entity))
|
if (!EntityListContains(entity))
|
||||||
EntityList.push_back(entity);
|
EntityList.push_back(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::AppendFixed(Fixed* fixed) {
|
void Engine::Scene::AppendFixed(Fixed* fixed) {
|
||||||
if (!FixedListContains(fixed))
|
if (!FixedListContains(fixed))
|
||||||
FixedList.push_back(fixed);
|
FixedList.push_back(fixed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::DestroyEntity(Entity *entity) {
|
void Engine::Scene::DestroyEntity(Entity *entity) {
|
||||||
auto it = std::find(EntityList.begin(), EntityList.end(), entity);
|
auto it = std::find(EntityList.begin(), EntityList.end(), entity);
|
||||||
if (it != EntityList.end())
|
if (it != EntityList.end())
|
||||||
delete *it, EntityList.erase(it);
|
delete *it, EntityList.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::DestroyFixed(Fixed* fixed) {
|
void Engine::Scene::DestroyFixed(Fixed* fixed) {
|
||||||
auto it = std::find(FixedList.begin(), FixedList.end(), fixed);
|
auto it = std::find(FixedList.begin(), FixedList.end(), fixed);
|
||||||
if (it != FixedList.end())
|
if (it != FixedList.end())
|
||||||
delete *it, FixedList.erase(it);
|
delete *it, FixedList.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Scene::RemoveEntity(Entity* entity) {
|
void Engine::Scene::RemoveEntity(Entity* entity) {
|
||||||
auto it = std::find(EntityList.begin(), EntityList.end(), entity);
|
auto it = std::find(EntityList.begin(), EntityList.end(), entity);
|
||||||
if (it != EntityList.end())
|
if (it != EntityList.end())
|
||||||
EntityList.erase(it);
|
EntityList.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Scene::RemoveFixed(Fixed* fixed) {
|
void Engine::Scene::RemoveFixed(Fixed* fixed) {
|
||||||
auto it = std::find(FixedList.begin(), FixedList.end(), fixed);
|
auto it = std::find(FixedList.begin(), FixedList.end(), fixed);
|
||||||
if (it != FixedList.end())
|
if (it != FixedList.end())
|
||||||
FixedList.erase(it);
|
FixedList.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Scene::GetName() const {
|
std::string Engine::Scene::GetName() const {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,12 +1,12 @@
|
|||||||
#include <Game/Entity/Box.h>
|
#include <Game/Entity/Box.h>
|
||||||
|
|
||||||
void Box::Render() {
|
void Game::Box::Render() {
|
||||||
J2D::Begin(nullptr, true);
|
J2D::Begin(nullptr, true);
|
||||||
J2D::FillRect(Colors::Red, Vector2(position), {20, 20});
|
J2D::FillRect(Colors::Red, Vector2(position), {20, 20});
|
||||||
J2D::End();
|
J2D::End();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Box::Update() {
|
void Game::Box::Update() {
|
||||||
if (Globals::Window->IsKeyDown(Keys::W))
|
if (Globals::Window->IsKeyDown(Keys::W))
|
||||||
MoveY(-500);
|
MoveY(-500);
|
||||||
if (Globals::Window->IsKeyDown(Keys::S))
|
if (Globals::Window->IsKeyDown(Keys::S))
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#include <Game/Entity/DemoGameHud.h>
|
#include <Game/Entity/DemoGameHud.h>
|
||||||
#include <Engine/Globals.h>
|
#include <Engine/Globals.h>
|
||||||
|
|
||||||
void DemoGameHud::Render() {
|
void Game::DemoGameHud::Render() {
|
||||||
float framerate = Globals::Window->GetRefreshRate();
|
float framerate = Globals::Window->GetRefreshRate();
|
||||||
J2D::Begin(nullptr, true);
|
J2D::Begin(nullptr, true);
|
||||||
J2D::DrawString(Colors::Whites::Ivory, "Framerate: " + std::to_string((int) framerate), 0, 0, 1, 16);
|
J2D::DrawString(Colors::Whites::Ivory, "Framerate: " + std::to_string((int) framerate), 0, 0, 1, 16);
|
||||||
|
@@ -3,8 +3,8 @@
|
|||||||
#include <Game/Entity/Box.h>
|
#include <Game/Entity/Box.h>
|
||||||
|
|
||||||
void ControllableBox::Init() {
|
void ControllableBox::Init() {
|
||||||
auto* hud = new DemoGameHud();
|
auto* hud = new Game::DemoGameHud();
|
||||||
auto* b = new Box({0, 0});
|
auto* b = new Game::Box({0, 0});
|
||||||
HeadsUpDisplay = hud;
|
HeadsUpDisplay = hud;
|
||||||
AppendEntity(b);
|
AppendEntity(b);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user