Compare commits

...

4 Commits

Author SHA1 Message Date
81aff5a03f Add flecs ECS
working copy
2025-05-24 14:10:12 +02:00
9228c9544a Simple SDL game loop 2025-05-24 14:03:04 +02:00
16664312e9 Minimal executable 2025-05-24 14:03:04 +02:00
e960e09796 Add project license 2025-05-24 14:02:49 +02:00
4 changed files with 105 additions and 0 deletions

15
CMakeLists.txt Normal file
View File

@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.24)
project(HansTheGatherer)
# Option to switch real platform vs. SDL implementation...
find_package(SDL3 REQUIRED)
find_package(flecs REQUIRED)
find_package(spdlog REQUIRED)
add_executable(HansTheGatherer main.cpp)
target_link_libraries(HansTheGatherer SDL3::SDL3 flecs::flecs spdlog::spdlog)
set_property(TARGET HansTheGatherer PROPERTY CXX_STANDARD 20)

28
LICENSE Normal file
View File

@@ -0,0 +1,28 @@
BSD 3-Clause License
Copyright (c) 2025, Derek Christ
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

54
main.cpp Normal file
View File

@@ -0,0 +1,54 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_error.h>
#include <SDL3/SDL_render.h>
#include <flecs.h>
#include <spdlog/spdlog.h>
const uint8_t image_data[] = {
#embed "main.cpp"
};
auto main() -> int {
spdlog::info("Initialize SDL...");
bool sdl_success = SDL_Init(SDL_INIT_VIDEO);
if (!sdl_success) {
spdlog::critical("Failed to initialize SDL!\nCause: {}", SDL_GetError());
std::terminate();
}
auto *sdl_window = SDL_CreateWindow("HansTheGatherer", 400, 280, 0);
if (sdl_window == nullptr) {
spdlog::critical("Failed to create SDL window!\nCause: {}", SDL_GetError());
}
auto *sdl_renderer = SDL_CreateRenderer(sdl_window, nullptr);
if (sdl_renderer == nullptr) {
spdlog::critical("Failed to create SDL renderer!\nCause: {}",
SDL_GetError());
}
flecs::world world;
bool exit_gameloop = false;
while (!exit_gameloop) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
switch (event.type) {
case SDL_EVENT_QUIT:
exit_gameloop = true;
break;
case SDL_EVENT_KEY_DOWN:
if (event.key.key == SDLK_ESCAPE) {
exit_gameloop = true;
}
break;
}
}
}
SDL_DestroyRenderer(sdl_renderer);
SDL_DestroyWindow(sdl_window);
SDL_Quit();
return 0;
}

8
vcpkg.json Normal file
View File

@@ -0,0 +1,8 @@
{
"dependencies": [
"spdlog",
"sdl3",
"spdlog",
"flecs"
]
}