mirror of
https://github.com/Nimac0/SDL_Minigame
synced 2026-01-12 13:43:41 +00:00
Compare commits
5 Commits
5e48f4e34f
...
84cee5e307
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
84cee5e307 | ||
|
|
55b60624c4 | ||
|
|
1f3cf01419 | ||
|
|
691ea06eb0 | ||
|
|
acdbf29896 |
@ -24,7 +24,7 @@ add_subdirectory(extern/SDL_image EXCLUDE_FROM_ALL)
|
|||||||
add_subdirectory(extern/SDL_mixer EXCLUDE_FROM_ALL)
|
add_subdirectory(extern/SDL_mixer EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(extern/SDL_ttf EXCLUDE_FROM_ALL)
|
add_subdirectory(extern/SDL_ttf EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(extern/tmxlite/tmxlite EXCLUDE_FROM_ALL)
|
add_subdirectory(extern/tmxlite/tmxlite EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(extern/nlohmann_json EXCLUDE_FROM_ALL)
|
include_directories(extern/nlohmann_json/include)
|
||||||
|
|
||||||
|
|
||||||
file(GLOB_RECURSE SOURCES ${ENGINE_SOURCE_DIR}/src/*.cpp)
|
file(GLOB_RECURSE SOURCES ${ENGINE_SOURCE_DIR}/src/*.cpp)
|
||||||
@ -40,7 +40,6 @@ target_link_libraries(${PROJECT_NAME} PUBLIC # should be private when all SDL fu
|
|||||||
SDL3_mixer::SDL3_mixer-static
|
SDL3_mixer::SDL3_mixer-static
|
||||||
SDL3_ttf::SDL3_ttf-static
|
SDL3_ttf::SDL3_ttf-static
|
||||||
tmxlite
|
tmxlite
|
||||||
nlohmann_json::nlohmann_json
|
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
if(CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||||
|
|||||||
@ -1,3 +1,7 @@
|
|||||||
{
|
{
|
||||||
"fullscreen": false
|
"fullscreen": false,
|
||||||
|
"title": "VGG (Very Good Game)",
|
||||||
|
"height": 100,
|
||||||
|
"width": 100,
|
||||||
|
"icon": "./engine/internalAssets/iconImage.bmp"
|
||||||
}
|
}
|
||||||
@ -11,9 +11,6 @@ constexpr std::size_t MAX_GROUPS = 32;
|
|||||||
constexpr std::size_t MAX_STATS = 8;
|
constexpr std::size_t MAX_STATS = 8;
|
||||||
constexpr std::size_t MAX_TEAMS = 8;
|
constexpr std::size_t MAX_TEAMS = 8;
|
||||||
|
|
||||||
constexpr int SCREEN_SIZE_HEIGHT = 640;
|
|
||||||
constexpr int SCREEN_SIZE_WIDTH = 800;
|
|
||||||
|
|
||||||
constexpr int FPS = 60;
|
constexpr int FPS = 60;
|
||||||
|
|
||||||
constexpr int TILE_SIZE = 32;
|
constexpr int TILE_SIZE = 32;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ public:
|
|||||||
GameInternal();
|
GameInternal();
|
||||||
~GameInternal();
|
~GameInternal();
|
||||||
|
|
||||||
SDL_AppResult init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen);
|
SDL_AppResult init();
|
||||||
|
|
||||||
void handleEvents();
|
void handleEvents();
|
||||||
void update(Uint64 frameTime);
|
void update(Uint64 frameTime);
|
||||||
|
|||||||
BIN
internalAssets/iconImage.bmp
Normal file
BIN
internalAssets/iconImage.bmp
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
@ -3,7 +3,9 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
ConfigLoader::ConfigLoader() {
|
ConfigLoader::ConfigLoader() {
|
||||||
baseConfig = loadConfigFromJSON("config.json");
|
//TODO: look into adaptive paths for better handling as this requires the implemented game
|
||||||
|
// to have ./engine in the root folder
|
||||||
|
baseConfig = loadConfigFromJSON("./engine/config.json");
|
||||||
}
|
}
|
||||||
|
|
||||||
ConfigLoader::~ConfigLoader() {}
|
ConfigLoader::~ConfigLoader() {}
|
||||||
@ -30,7 +32,9 @@ json ConfigLoader::loadConfigFromJSON(const std::string& path) {
|
|||||||
|
|
||||||
|
|
||||||
void ConfigLoader::setCustomConfig(const std::optional<std::string>& path) {
|
void ConfigLoader::setCustomConfig(const std::optional<std::string>& path) {
|
||||||
customConfig = path;
|
if (path.has_value()) {
|
||||||
|
customConfig = loadConfigFromJSON(path.value());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
json ConfigLoader::mergeConfigs(json baseConfig, json customConfig) {
|
json ConfigLoader::mergeConfigs(json baseConfig, json customConfig) {
|
||||||
|
|||||||
@ -29,13 +29,15 @@ GameInternal::GameInternal() :
|
|||||||
|
|
||||||
GameInternal::~GameInternal() = default;
|
GameInternal::~GameInternal() = default;
|
||||||
|
|
||||||
SDL_AppResult GameInternal::init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen)
|
SDL_AppResult GameInternal::init()
|
||||||
{
|
{
|
||||||
this->gameInstance = GameFactory::instance().create(this);
|
ConfigLoader* loader = new ConfigLoader();
|
||||||
ConfigLoader().setCustomConfig(this->gameInstance->getConfigFilePath());
|
|
||||||
ConfigLoader().init();
|
|
||||||
|
|
||||||
json config = ConfigLoader().getFinalConfig();
|
this->gameInstance = GameFactory::instance().create(this);
|
||||||
|
loader->setCustomConfig(this->gameInstance->getConfigFilePath());
|
||||||
|
loader->init();
|
||||||
|
|
||||||
|
json config = loader->getFinalConfig();
|
||||||
|
|
||||||
GameInternal::assets = new AssetManager(&manager);
|
GameInternal::assets = new AssetManager(&manager);
|
||||||
GameInternal::textureManager = new TextureManager(&manager);
|
GameInternal::textureManager = new TextureManager(&manager);
|
||||||
@ -60,7 +62,7 @@ SDL_AppResult GameInternal::init(const char* title, int xpos, int ypos, int widt
|
|||||||
return SDL_APP_FAILURE;
|
return SDL_APP_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
window = SDL_CreateWindow(title, width, height, flags);
|
window = SDL_CreateWindow(config.at("title").get<std::string>().c_str(), config.at("width"), config.at("height"), flags);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
std::cout << "ERROR: Window couldnt be created! " << SDL_GetError() << std::endl;
|
std::cout << "ERROR: Window couldnt be created! " << SDL_GetError() << std::endl;
|
||||||
@ -70,7 +72,7 @@ SDL_AppResult GameInternal::init(const char* title, int xpos, int ypos, int widt
|
|||||||
|
|
||||||
// bad
|
// bad
|
||||||
SDL_Surface* icon;
|
SDL_Surface* icon;
|
||||||
if((icon = SDL_LoadBMP("assets/iconImage.bmp")))
|
if((icon = SDL_LoadBMP(config.at("icon").get<std::string>().c_str())))
|
||||||
{
|
{
|
||||||
SDL_SetWindowIcon(window, icon);
|
SDL_SetWindowIcon(window, icon);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
|
|||||||
|
|
||||||
*appstate = vego::game = new GameInternal();
|
*appstate = vego::game = new GameInternal();
|
||||||
|
|
||||||
return vego::game->init("No_Name_Chicken_Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_SIZE_WIDTH, SCREEN_SIZE_HEIGHT, false);
|
return vego::game->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AppResult SDL_AppIterate(void *appstate) {
|
SDL_AppResult SDL_AppIterate(void *appstate) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user