0
0
mirror of https://github.com/Nimac0/SDL_Minigame synced 2026-01-12 15:53:42 +00:00

Compare commits

..

No commits in common. "84cee5e307925fef4f5b13c150a1cf0d5206b9ab" and "5e48f4e34ff4fd963880c08fda5f4540d96b4fdb" have entirely different histories.

8 changed files with 16 additions and 22 deletions

View File

@ -24,7 +24,7 @@ add_subdirectory(extern/SDL_image EXCLUDE_FROM_ALL)
add_subdirectory(extern/SDL_mixer EXCLUDE_FROM_ALL)
add_subdirectory(extern/SDL_ttf EXCLUDE_FROM_ALL)
add_subdirectory(extern/tmxlite/tmxlite EXCLUDE_FROM_ALL)
include_directories(extern/nlohmann_json/include)
add_subdirectory(extern/nlohmann_json EXCLUDE_FROM_ALL)
file(GLOB_RECURSE SOURCES ${ENGINE_SOURCE_DIR}/src/*.cpp)
@ -40,6 +40,7 @@ target_link_libraries(${PROJECT_NAME} PUBLIC # should be private when all SDL fu
SDL3_mixer::SDL3_mixer-static
SDL3_ttf::SDL3_ttf-static
tmxlite
nlohmann_json::nlohmann_json
)
if(CMAKE_BUILD_TYPE MATCHES "Debug")

View File

@ -1,7 +1,3 @@
{
"fullscreen": false,
"title": "VGG (Very Good Game)",
"height": 100,
"width": 100,
"icon": "./engine/internalAssets/iconImage.bmp"
"fullscreen": false
}

View File

@ -11,6 +11,9 @@ constexpr std::size_t MAX_GROUPS = 32;
constexpr std::size_t MAX_STATS = 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 TILE_SIZE = 32;

View File

@ -27,7 +27,7 @@ public:
GameInternal();
~GameInternal();
SDL_AppResult init();
SDL_AppResult init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen);
void handleEvents();
void update(Uint64 frameTime);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -3,9 +3,7 @@
#include <fstream>
ConfigLoader::ConfigLoader() {
//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");
baseConfig = loadConfigFromJSON("config.json");
}
ConfigLoader::~ConfigLoader() {}
@ -32,9 +30,7 @@ json ConfigLoader::loadConfigFromJSON(const std::string& path) {
void ConfigLoader::setCustomConfig(const std::optional<std::string>& path) {
if (path.has_value()) {
customConfig = loadConfigFromJSON(path.value());
}
customConfig = path;
}
json ConfigLoader::mergeConfigs(json baseConfig, json customConfig) {

View File

@ -29,15 +29,13 @@ GameInternal::GameInternal() :
GameInternal::~GameInternal() = default;
SDL_AppResult GameInternal::init()
SDL_AppResult GameInternal::init(const char* title, int xpos, int ypos, int width, int height, bool fullscreen)
{
ConfigLoader* loader = new ConfigLoader();
this->gameInstance = GameFactory::instance().create(this);
loader->setCustomConfig(this->gameInstance->getConfigFilePath());
loader->init();
ConfigLoader().setCustomConfig(this->gameInstance->getConfigFilePath());
ConfigLoader().init();
json config = loader->getFinalConfig();
json config = ConfigLoader().getFinalConfig();
GameInternal::assets = new AssetManager(&manager);
GameInternal::textureManager = new TextureManager(&manager);
@ -62,7 +60,7 @@ SDL_AppResult GameInternal::init()
return SDL_APP_FAILURE;
}
window = SDL_CreateWindow(config.at("title").get<std::string>().c_str(), config.at("width"), config.at("height"), flags);
window = SDL_CreateWindow(title, width, height, flags);
if (!window)
{
std::cout << "ERROR: Window couldnt be created! " << SDL_GetError() << std::endl;
@ -72,7 +70,7 @@ SDL_AppResult GameInternal::init()
// bad
SDL_Surface* icon;
if((icon = SDL_LoadBMP(config.at("icon").get<std::string>().c_str())))
if((icon = SDL_LoadBMP("assets/iconImage.bmp")))
{
SDL_SetWindowIcon(window, icon);
}

View File

@ -19,7 +19,7 @@ SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
*appstate = vego::game = new GameInternal();
return vego::game->init();
return vego::game->init("No_Name_Chicken_Game", SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, SCREEN_SIZE_WIDTH, SCREEN_SIZE_HEIGHT, false);
}
SDL_AppResult SDL_AppIterate(void *appstate) {