Added Scene Loading and Program Settings
This commit is contained in:
parent
881e6c70f2
commit
1bad863c5b
13 changed files with 91 additions and 43 deletions
18
README.md
18
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
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
BIN
asloengine/builtin/assets/textures/texture_default_button.png
Executable file → Normal file
BIN
asloengine/builtin/assets/textures/texture_default_button.png
Executable file → Normal file
Binary file not shown.
|
Before Width: | Height: | Size: 6.6 KiB After Width: | Height: | Size: 2 KiB |
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
{
|
||||
|
||||
|
|
|
|||
|
|
@ -1,14 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
#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();
|
||||
|
||||
}
|
||||
|
|
@ -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
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include "define.hpp"
|
||||
#include "../../define.hpp"
|
||||
|
||||
#ifdef DEBUG
|
||||
#define LOG(message) asloengine::log((std::string)"LOG: ", message)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ namespace asloengine
|
|||
|
||||
void SceneManager::unload_scene()
|
||||
{
|
||||
LOG("UNLOAD");
|
||||
|
||||
if (scene)
|
||||
{
|
||||
scene->destroy();
|
||||
|
|
|
|||
6
define.hpp
Normal file
6
define.hpp
Normal file
|
|
@ -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
|
||||
12
program.cpp
12
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();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,2 @@
|
|||
Loading Scenes
|
||||
Window Parameters
|
||||
Color
|
||||
Animations
|
||||
Animations
|
||||
Loading…
Add table
Add a link
Reference in a new issue