Skip to content

Commit

Permalink
Rewrite and restructure
Browse files Browse the repository at this point in the history
  • Loading branch information
SirBob01 committed Sep 23, 2024
1 parent 8eb32c4 commit 4cae629
Show file tree
Hide file tree
Showing 146 changed files with 1,398 additions and 7,639 deletions.
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ project(.)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED on)

set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED on)

add_compile_options(-Wall -g -O3 -fPIC)
Expand Down
4 changes: 1 addition & 3 deletions demos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,9 @@ project(.)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED on)

set(CMAKE_C_STANDARD 17)
set(CMAKE_C_STANDARD_REQUIRED on)

add_compile_options(-Wall -g -O3)
add_compile_options(-Wall -g -O3 -fPIC)

add_subdirectory("../" "./Dynamo")

Expand Down
14 changes: 7 additions & 7 deletions demos/init.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include <Dynamo.hpp>

int main() {
Dynamo::ApplicationConfiguration config;
config.title = "Hello, world!";
config.width = 640;
config.height = 480;
config.asset_directory = "../assets/";
Dynamo::ApplicationSettings settings;
settings.title = "Hello, world!";
settings.window_width = 640;
settings.window_height = 480;
settings.root_asset_directory = "../assets/";

Dynamo::Application app(config);
Dynamo::Application app(settings);
while (app.is_running()) {
app.run();
app.update();
}
return 0;
}
28 changes: 28 additions & 0 deletions src/Application.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include "Application.hpp"

namespace Dynamo {
Application::Application(const ApplicationSettings &settings) {
_display = std::make_unique<Display>(settings.title,
settings.window_width,
settings.window_height);
_jukebox = std::make_unique<Sound::Jukebox>();
}

bool Application::is_running() const { return _display->is_open(); }

Display &Application::get_display() { return *_display; }

Input &Application::get_input() { return _display->get_input(); }

Clock &Application::get_clock() { return _clock; }

Sound::Jukebox &Application::get_jukebox() { return *_jukebox; }

void Application::update() {
// Update subsystems
_display->get_input().poll();

// Tick
_clock.tick();
}
} // namespace Dynamo
107 changes: 107 additions & 0 deletions src/Application.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
#pragma once

#include <functional>
#include <string>

#include "./Sound/Jukebox.hpp"
#include "Clock.hpp"
#include "Display.hpp"

namespace Dynamo {
/**
* @brief Application setup options.
*
*/
struct ApplicationSettings {
/**
* @brief Application title.
*
*/
std::string title;

/**
* @brief Width of the display window.
*
*/
unsigned window_width;

/**
* @brief Height of the display window.
*
*/
unsigned window_height;

/**
* @brief Root asset directory.
*
*/
std::string root_asset_directory;
};

/**
* @brief Dynamo Application.
*
*/
class Application {
std::unique_ptr<Display> _display;
std::unique_ptr<Sound::Jukebox> _jukebox;

Clock _clock;

public:
/**
* @brief Initialize a new Application.
*
* @param settings
*/
Application(const ApplicationSettings &settings);

/**
* @brief Check if the application is running.
*
* @return true
* @return false
*/
bool is_running() const;

/**
* @brief Get the display.
*
* @return Display&
*/
Display &get_display();

/**
* @brief Get the input handler.
*
* @return Input&
*/
Input &get_input();

/**
* @brief Get the clock.
*
* @return Clock&
*/
Clock &get_clock();

/**
* @brief Get the audio engine.
*
* @return Sound::Jukebox&
*/
Sound::Jukebox &get_jukebox();

/**
* @brief Update the application state.
*
*/
void update();
};

/**
* @brief Application reference.
*
*/
using ApplicationRef = std::reference_wrapper<Application>;
} // namespace Dynamo
54 changes: 0 additions & 54 deletions src/Application/Application.cpp

This file was deleted.

129 changes: 0 additions & 129 deletions src/Application/Application.hpp

This file was deleted.

Loading

0 comments on commit 4cae629

Please sign in to comment.