diff --git a/CMakeLists.txt b/CMakeLists.txt index 31860cd..1dfe136 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,10 +9,9 @@ include_directories(${SFML_INCLUDE_DIR}) # Set up your project's source files set(SOURCES - src/main.cpp -# src/game.cpp -# include/game.h -) + src/main.cpp + src/game/renderer.h + src/game/renderer.cpp src/game/game_object.cpp src/game/game_object.h src/game/game.cpp src/game/game.h src/util/logger.cpp src/util/logger.h) # Add an executable target add_executable(Holesome ${SOURCES}) diff --git a/README.md b/README.md index b8d3233..94d85d5 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ PADI 2023, Maximilian Giller, 5000149 -## What is this game about? +## What is this Game about? Holesome is about holes! But not the kind you have seen before ... @@ -25,7 +25,7 @@ Style: ## What is the goal? -The player controls a hole and has to consume as many objects as possible to grow. There are a variaty of game modes that could be fun: +The player controls a hole and has to consume as many objects as possible to grow. There are a variaty of Game modes that could be fun: - Eat as many objects as possible in a given time - Eat as many objects as possible, as well as all of your enemies and be the only one left @@ -37,7 +37,7 @@ The player controls a hole and has to consume as many objects as possible to gro - **Controller Support**: Use a controller to control the hole - **Local Multiplayer**: Play with up to 4 players on one device using split screen - **Level Files**: Levels are stored using a simple file format -- **Procedural Generation**: Generate the levels procedurally to give the game more variety +- **Procedural Generation**: Generate the levels procedurally to give the Game more variety - **Menu**: Because, duh Potential expansions: diff --git a/include/game.h b/include/game.h deleted file mode 100644 index d259662..0000000 --- a/include/game.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef SFML_SAMPLE_GAME_GAME_H -#define SFML_SAMPLE_GAME_GAME_H - - -class Game { - -}; - - -#endif //SFML_SAMPLE_GAME_GAME_H diff --git a/src/game.cpp b/src/game.cpp deleted file mode 100644 index 2a081b9..0000000 --- a/src/game.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "../include/game.h" diff --git a/src/game/game.cpp b/src/game/game.cpp new file mode 100644 index 0000000..6fa28cd --- /dev/null +++ b/src/game/game.cpp @@ -0,0 +1,26 @@ +// +// Created by max on 26.04.23. +// + +#include + +#include "game.h" + +Game::Game(std::shared_ptr renderer) : renderer(std::move(renderer)) { +} + +void Game::run() { + if (isRunning) { + Logger::debug("Game is already running", "Game::run"); + return; + } + + isRunning = true; + while (isRunning) { + + } +} + +void Game::stop() { + isRunning = false; +} diff --git a/src/game/game.h b/src/game/game.h new file mode 100644 index 0000000..55ef213 --- /dev/null +++ b/src/game/game.h @@ -0,0 +1,29 @@ +// +// Created by max on 26.04.23. +// + +#ifndef HOLESOME_GAME_H +#define HOLESOME_GAME_H + + +#include +#include "renderer.h" +#include "../util/logger.h" + +class Game { +private: + std::shared_ptr renderer; + bool isRunning = false; + +public: + explicit Game(std::shared_ptr renderer); + void run(); + + /*** + * Stops the game and sets isRunning to false. + */ + void stop(); +}; + + +#endif //HOLESOME_GAME_H diff --git a/src/game/game_object.cpp b/src/game/game_object.cpp new file mode 100644 index 0000000..5cc4b9d --- /dev/null +++ b/src/game/game_object.cpp @@ -0,0 +1 @@ +#include "game_object.h" diff --git a/src/game/game_object.h b/src/game/game_object.h new file mode 100644 index 0000000..f7d5e89 --- /dev/null +++ b/src/game/game_object.h @@ -0,0 +1,10 @@ +#ifndef HOLESOME_GAME_OBJECT_H +#define HOLESOME_GAME_OBJECT_H + + +class game_object { + +}; + + +#endif //HOLESOME_GAME_OBJECT_H diff --git a/src/game/renderer.cpp b/src/game/renderer.cpp new file mode 100644 index 0000000..16d9d57 --- /dev/null +++ b/src/game/renderer.cpp @@ -0,0 +1 @@ +#include "renderer.h" diff --git a/src/game/renderer.h b/src/game/renderer.h new file mode 100644 index 0000000..adc7cf0 --- /dev/null +++ b/src/game/renderer.h @@ -0,0 +1,13 @@ +#ifndef HOLESOME_RENDERER_H +#define HOLESOME_RENDERER_H + +class Renderer { +public: + static Renderer *createWindow(std::string title, int width, int height); + static Renderer *createFullscreen(std::string title); + + void draw(); +}; + + +#endif //HOLESOME_RENDERER_H diff --git a/src/util/logger.cpp b/src/util/logger.cpp new file mode 100644 index 0000000..6abb6b6 --- /dev/null +++ b/src/util/logger.cpp @@ -0,0 +1,13 @@ +// +// Created by max on 26.04.23. +// + +#include "logger.h" + +void Logger::debug(const std::string& msg, const std::string& source) { + log(msg, source, "DBG"); +} + +void Logger::log(const std::string& msg, const std::string& source, const std::string& level) { + std::cout << level << " [" << source << "] " << msg << std::endl; +} diff --git a/src/util/logger.h b/src/util/logger.h new file mode 100644 index 0000000..f217e19 --- /dev/null +++ b/src/util/logger.h @@ -0,0 +1,18 @@ +// +// Created by max on 26.04.23. +// + +#ifndef HOLESOME_LOGGER_H +#define HOLESOME_LOGGER_H + +#include +#include + +class Logger { +public: + static void debug(const std::string& msg, const std::string& source); + static void log(const std::string& msg, const std::string& source, const std::string& level); +}; + + +#endif //HOLESOME_LOGGER_H