diff --git a/README.md b/README.md index f1f401a..6b30e69 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,18 @@ # AsloEngine -My WiP 2D Game Engine made using SFML +WiP 2D Game Engine made using C++ and SFML +Third-Party Libraries are not Included in the Repository -Version 0.9.0 +Version 0.9.1 + + +## How To Compile this Example + +### Linux: +Dependecies: libsfml-dev libfmt-dev g++ make +Compilation: Open folder in terminal and type make. If linking fails after editing files try to recompile everything with make all. You can clear temporary files with make clear + +### Windows: +Coming Soon... + +### Mac OS: +Not Available \ No newline at end of file diff --git a/asloengine/asloengine.hpp b/asloengine/asloengine.hpp index 6632a50..8e2ed21 100755 --- a/asloengine/asloengine.hpp +++ b/asloengine/asloengine.hpp @@ -1,10 +1,11 @@ #pragma once +#include "../define.hpp" + #include "builtin/builtin.hpp" #include "headers/clickable.hpp" #include "headers/core.hpp" -#include "headers/define.hpp" #include "headers/gameobject.hpp" #include "headers/helpers.hpp" #include "headers/keyboard.hpp" diff --git a/asloengine/builtin/assets/textures/texture_default_button.png b/asloengine/builtin/assets/textures/texture_default_button.png old mode 100755 new mode 100644 index 17efeb5..04c1072 Binary files a/asloengine/builtin/assets/textures/texture_default_button.png and b/asloengine/builtin/assets/textures/texture_default_button.png differ diff --git a/asloengine/builtin/grid_container.cpp b/asloengine/builtin/grid_container.cpp index d99bd1d..02b9ffa 100755 --- a/asloengine/builtin/grid_container.cpp +++ b/asloengine/builtin/grid_container.cpp @@ -13,14 +13,6 @@ namespace asloengine sf::Vector2f grid_anchor_position = get_position() - (get_origin() * to_vector2f(grid_size) * cell_size); - for (int x = 0; x < grid_size.x; x++) - { - for (int y = 0; y < grid_size.y; y++) - { - - } - } - unsigned int x = 0; unsigned int y = 0; diff --git a/asloengine/builtin/scene_default.cpp b/asloengine/builtin/scene_default.cpp index e5d33e2..3829182 100755 --- a/asloengine/builtin/scene_default.cpp +++ b/asloengine/builtin/scene_default.cpp @@ -1,3 +1,6 @@ +// This is only an Engine Testing Scene +// Please don't use this for your Game + #include "headers/scene_default.hpp" namespace asloengine @@ -24,7 +27,7 @@ namespace asloengine TextOnlyButton *tbtn1 = new TextOnlyButton("Exit Button", "Exit Game", button_font); //tbtn1->set_position(100, 125); - TextObject *to1 = new TextObject("Info Text", "Aslo Engine v0.9.0 by Aslan2142", button_font); + TextObject *to1 = new TextObject("Info Text", "Aslo Engine Test", button_font); //to1->set_position(630, 0); //to1->set_origin(1, 0); btn1->signal_on_clicked.connect_member(to1, &TextObject::set_text, sf::String("lulz")); @@ -61,8 +64,8 @@ namespace asloengine gui_layer.emplace_back(toif); gui_layer.emplace_back(sc1);*/ - GridContainer *container = new GridContainer("cont1", sf::Vector2u(2, 2), sf::Vector2f(200, 150)); - container->set_position(100, 200); + GridContainer *container = new GridContainer("cont1", sf::Vector2u(2, 2), sf::Vector2f(300, 150)); + container->set_position(30, 200); container->add_object(to1); container->add_object(if2); container->add_object(btn1); @@ -79,7 +82,7 @@ namespace asloengine void SceneDefault::on_update(float delta_time) { - move_camera(sf::Vector2f(1, 2)); + //move_camera(sf::Vector2f(1, 2)); } diff --git a/asloengine/core.cpp b/asloengine/core.cpp index bd18adb..c72e815 100755 --- a/asloengine/core.cpp +++ b/asloengine/core.cpp @@ -4,17 +4,16 @@ namespace asloengine { static sf::RenderWindow *main_window; + static Settings active_settings; - void init(Scene *starting_scene) + void init(Scene *starting_scene, Settings _settings) { LOG("START Init"); - main_window = new sf::RenderWindow(sf::VideoMode(RESOLUTION_X, RESOLUTION_Y, BIT_DEPTH), - PROGRAM_INFO, sf::Style::Fullscreen); - - main_window->setVerticalSyncEnabled(VSYNC_ENABLED); - main_window->setFramerateLimit(MAX_FRAMERATE); + main_window = new sf::RenderWindow(); + + apply_settings(_settings); SceneManager::load_scene(starting_scene); @@ -22,6 +21,32 @@ namespace asloengine } + Settings get_active_settings() + { + + return active_settings; + + } + + void apply_settings(Settings _settings) + { + + active_settings = _settings; + + if (active_settings.fullscreen_enabled) + { + main_window->create(sf::VideoMode(active_settings.resolution_x, active_settings.resolution_y, active_settings.bit_depth), + PROGRAM_INFO, sf::Style::Fullscreen); + } else { + main_window->create(sf::VideoMode(active_settings.resolution_x, active_settings.resolution_y, active_settings.bit_depth), + PROGRAM_INFO, sf::Style::Close); + } + + main_window->setVerticalSyncEnabled(active_settings.vsync_enabled); + main_window->setFramerateLimit(active_settings.max_framerate); + + } + void start_main_game_loop() { diff --git a/asloengine/headers/core.hpp b/asloengine/headers/core.hpp index adeeb35..6104bc8 100755 --- a/asloengine/headers/core.hpp +++ b/asloengine/headers/core.hpp @@ -1,14 +1,27 @@ #pragma once #include +#include "../../define.hpp" #include "scenemanager.hpp" #include "keyboard.hpp" #include "mouse.hpp" namespace asloengine { - - void init(Scene *starting_scene); + + struct Settings + { + uint resolution_x = 640; + uint resolution_y = 480; + uint bit_depth = 24; + uint max_framerate = 60; + bool vsync_enabled = true; + bool fullscreen_enabled = false; + }; + + void init(Scene *starting_scene, Settings _settings); + Settings get_active_settings(); + void apply_settings(Settings _settings); void start_main_game_loop(); } \ No newline at end of file diff --git a/asloengine/headers/define.hpp b/asloengine/headers/define.hpp deleted file mode 100644 index 7c1846b..0000000 --- a/asloengine/headers/define.hpp +++ /dev/null @@ -1,14 +0,0 @@ -#pragma once - -#define PROGRAM_NAME "Space Strategy" -#define PROGRAM_VERSION "0.1.0" -#define PROGRAM_INFO (std::string)PROGRAM_NAME + " v" + PROGRAM_VERSION -#define PROGRAM_BUILD 0 -#define PROGRAM_CREATOR "Aslan2142" -#define COPYRIGHT "Copyright 2019" -#define RESOLUTION_X 1920 -#define RESOLUTION_Y 1080 -#define BIT_DEPTH 24 -#define MAX_FRAMERATE 60 -#define VSYNC_ENABLED true -#define DEBUG \ No newline at end of file diff --git a/asloengine/headers/helpers.hpp b/asloengine/headers/helpers.hpp index cc2ea90..90bd781 100755 --- a/asloengine/headers/helpers.hpp +++ b/asloengine/headers/helpers.hpp @@ -3,7 +3,7 @@ #include #include #include -#include "define.hpp" +#include "../../define.hpp" #ifdef DEBUG #define LOG(message) asloengine::log((std::string)"LOG: ", message) diff --git a/asloengine/scenemanager.cpp b/asloengine/scenemanager.cpp index a3e4a30..e010f15 100755 --- a/asloengine/scenemanager.cpp +++ b/asloengine/scenemanager.cpp @@ -38,7 +38,7 @@ namespace asloengine void SceneManager::unload_scene() { - LOG("UNLOAD"); + if (scene) { scene->destroy(); diff --git a/define.hpp b/define.hpp new file mode 100644 index 0000000..315da2f --- /dev/null +++ b/define.hpp @@ -0,0 +1,6 @@ +#define PROGRAM_NAME "AsloEngine Test" +#define PROGRAM_VERSION "0.9.1" +#define PROGRAM_INFO (std::string)PROGRAM_NAME + " v" + PROGRAM_VERSION +#define PROGRAM_BUILD 0 +#define PROGRAM_CREATOR "Unknown" +#define DEBUG // Comment this out to disable Engine Debug Mode \ No newline at end of file diff --git a/program.cpp b/program.cpp index 98c549b..d44cb54 100755 --- a/program.cpp +++ b/program.cpp @@ -3,7 +3,17 @@ int main() { - asloengine::init(new asloengine::SceneDefault()); + asloengine::Settings settings + { + 640, // Resolution X + 480, // Resolution Y + 24, // Bit Depth + 60, // Max Framerate + true, // Vsync Enabled + false // Fullscreen Enabled + }; + + asloengine::init(new asloengine::SceneDefault(), settings); asloengine::start_main_game_loop(); diff --git a/roadmap.txt b/roadmap.txt index a9fafe9..9a7077c 100644 --- a/roadmap.txt +++ b/roadmap.txt @@ -1,4 +1,2 @@ -Loading Scenes -Window Parameters Color -Animations +Animations \ No newline at end of file