-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Move engine into its own project
- The engine is now located in the `engine` folder - Header files are now in `engine/include` and source files are in `engine/src`
- Loading branch information
1 parent
3cd6592
commit 01c15be
Showing
29 changed files
with
148 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
cmake_minimum_required(VERSION 3.5) | ||
project(Engine) | ||
|
||
set(CMAKE_CXX_STANDARD 17) | ||
|
||
# Add source files | ||
file(GLOB_RECURSE ENGINE_SOURCES src/*) | ||
add_library(Engine ${ENGINE_SOURCES}) | ||
|
||
# Set include directory | ||
target_include_directories(Engine PUBLIC include) |
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/engine/components/gravityComponent.h → ...lude/engine/components/gravityComponent.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
src/engine/components/scriptComponent.h → ...clude/engine/components/scriptComponent.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
src/engine/components/spriteComponent.h → ...clude/engine/components/spriteComponent.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/engine/components/transformComponent.h → ...de/engine/components/transformComponent.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
src/engine/systems/_system.h → engine/include/engine/systems/_system.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,5 @@ | ||
#pragma once | ||
|
||
#include "../entities/_entity.h" | ||
|
||
|
||
/** | ||
* @brief Base class for all systems | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma once | ||
|
||
#include <engine/systems/_system.h> | ||
#include <unordered_map> | ||
|
||
enum Key { | ||
LEFT = 0, | ||
RIGHT, | ||
QUIT | ||
}; | ||
|
||
class Input : public System { | ||
enum KeyState {UP, PRESSED, HELD}; | ||
static std::unordered_map<Key, KeyState> keys; | ||
public: | ||
/** | ||
* @brief Loops over all the keys and tracks their state | ||
* @note This function should be called once per frame | ||
* to update the key states for the current frame | ||
*/ | ||
void Update() override; | ||
|
||
/** | ||
* @brief Check if a key is held down | ||
* @param key The key to check | ||
* @return bool True if the key is held | ||
*/ | ||
static bool GetKeyDown(Key key); | ||
|
||
/** | ||
* @brief Check if a key is pressed | ||
* @param key The key to check | ||
* @return bool True if the key is pressed | ||
*/ | ||
static bool GetKeyPressed(Key key); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#pragma once | ||
|
||
#include <engine/systems/_system.h> | ||
#include <engine/components/spriteComponent.h> | ||
#include <string> | ||
#include <windows.h> | ||
#include <algorithm> | ||
#include <iostream> | ||
|
||
class RenderSystem : public System { | ||
// Handle to the console | ||
HANDLE hStdOut = GetStdHandle(STD_OUTPUT_HANDLE); | ||
CONSOLE_SCREEN_BUFFER_INFO consoleInfo{}; | ||
|
||
// Buffer to store the console | ||
std::vector<std::pair<char, Color>> consoleBuffer; | ||
int charCount = 0; | ||
|
||
// Queue screen clear | ||
bool clearScreen = false; | ||
|
||
/** | ||
* @brief Determines the alpha and color of a point | ||
* @details The alpha is calculated using the barycentric coordinates method | ||
* @param SpriteComponent The points of the triangle strip | ||
* @param x The x-coordinate of the point | ||
* @param y The y-coordinate of the point | ||
* @return A character representing the luminance of the point | ||
*/ | ||
static std::pair<char, Color> AlphaColorOfPoint(SpriteComponent &sprite, int x, int y); | ||
|
||
/** | ||
* @brief Sets a character at a position in the console | ||
* @param x The x-coordinate of the character | ||
* @param y The y-coordinate of the character | ||
* @param character The character to set | ||
*/ | ||
void SetConsoleCharacter(int x, int y, std::pair<char, Color> character); | ||
|
||
/** | ||
* @brief Draws a triangle to the console | ||
* @param triangleList The points of the triangle strip | ||
* @param index The index of the first point in the triangle strip | ||
*/ | ||
void DrawTriangle(SpriteComponent &sprite, int index); | ||
public: | ||
RenderSystem(); | ||
void Update() override; | ||
}; |
4 changes: 2 additions & 2 deletions
4
src/engine/systems/spriteSystem.h → engine/include/engine/systems/spriteSystem.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/engine/systems/timeSystem.h → engine/include/engine/systems/timeSystem.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
#pragma once | ||
|
||
#include "_system.h" | ||
#include <engine/systems/_system.h> | ||
|
||
#include <chrono> | ||
|
||
|
8 changes: 4 additions & 4 deletions
8
src/engine/systems/transformSystem.h → .../include/engine/systems/transformSystem.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/engine/components/gravityComponent.cpp → ...rc/engine/components/gravityComponent.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/engine/components/scriptComponent.cpp → ...src/engine/components/scriptComponent.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/engine/components/spriteComponent.cpp → ...src/engine/components/spriteComponent.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 1 addition & 3 deletions
4
src/engine/entities/_entity.cpp → engine/src/engine/entity.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,9 @@ | ||
#include "_entity.h" | ||
#include <engine/entity.h> | ||
|
||
// Orders the entity inside of sets | ||
bool Entity::operator<(const Entity &other) const { | ||
return executionPriority < other.executionPriority; | ||
} | ||
|
||
// Check if the entity is destroyed | ||
bool Entity::gotDestroyed() const { | ||
return destroyed; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.