Some progress on basic structures

This commit is contained in:
Maximilian Giller 2023-04-26 22:48:15 +02:00
parent c3c845798f
commit 5d645e5d70
12 changed files with 117 additions and 18 deletions

View file

@ -10,9 +10,8 @@ include_directories(${SFML_INCLUDE_DIR})
# Set up your project's source files # Set up your project's source files
set(SOURCES set(SOURCES
src/main.cpp src/main.cpp
# src/game.cpp src/game/renderer.h
# include/game.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 an executable target
add_executable(Holesome ${SOURCES}) add_executable(Holesome ${SOURCES})

View file

@ -6,7 +6,7 @@ PADI 2023,
Maximilian Giller, Maximilian Giller,
5000149 5000149
## What is this game about? ## What is this Game about?
Holesome is about holes! But not the kind you have seen before ... Holesome is about holes! But not the kind you have seen before ...
@ -25,7 +25,7 @@ Style:
## What is the goal? ## 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 in a given time
- Eat as many objects as possible, as well as all of your enemies and be the only one left - 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 - **Controller Support**: Use a controller to control the hole
- **Local Multiplayer**: Play with up to 4 players on one device using split screen - **Local Multiplayer**: Play with up to 4 players on one device using split screen
- **Level Files**: Levels are stored using a simple file format - **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 - **Menu**: Because, duh
Potential expansions: Potential expansions:

View file

@ -1,10 +0,0 @@
#ifndef SFML_SAMPLE_GAME_GAME_H
#define SFML_SAMPLE_GAME_GAME_H
class Game {
};
#endif //SFML_SAMPLE_GAME_GAME_H

View file

@ -1 +0,0 @@
#include "../include/game.h"

26
src/game/game.cpp Normal file
View file

@ -0,0 +1,26 @@
//
// Created by max on 26.04.23.
//
#include <utility>
#include "game.h"
Game::Game(std::shared_ptr<Renderer> 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;
}

29
src/game/game.h Normal file
View file

@ -0,0 +1,29 @@
//
// Created by max on 26.04.23.
//
#ifndef HOLESOME_GAME_H
#define HOLESOME_GAME_H
#include <memory>
#include "renderer.h"
#include "../util/logger.h"
class Game {
private:
std::shared_ptr<Renderer> renderer;
bool isRunning = false;
public:
explicit Game(std::shared_ptr<Renderer> renderer);
void run();
/***
* Stops the game and sets isRunning to false.
*/
void stop();
};
#endif //HOLESOME_GAME_H

1
src/game/game_object.cpp Normal file
View file

@ -0,0 +1 @@
#include "game_object.h"

10
src/game/game_object.h Normal file
View file

@ -0,0 +1,10 @@
#ifndef HOLESOME_GAME_OBJECT_H
#define HOLESOME_GAME_OBJECT_H
class game_object {
};
#endif //HOLESOME_GAME_OBJECT_H

1
src/game/renderer.cpp Normal file
View file

@ -0,0 +1 @@
#include "renderer.h"

13
src/game/renderer.h Normal file
View file

@ -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

13
src/util/logger.cpp Normal file
View file

@ -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;
}

18
src/util/logger.h Normal file
View file

@ -0,0 +1,18 @@
//
// Created by max on 26.04.23.
//
#ifndef HOLESOME_LOGGER_H
#define HOLESOME_LOGGER_H
#include <string>
#include <iostream>
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