Compare commits

...

3 Commits

Author SHA1 Message Date
266b86fb30 Render background image 2025-05-24 15:02:40 +02:00
6a81b1989f Add jungle asset 2025-05-24 14:27:16 +02:00
e7501573cd Add sprite asset 2025-05-24 14:20:42 +02:00
7 changed files with 35 additions and 6 deletions

View File

@@ -4,12 +4,13 @@ project(HansTheGatherer)
# Option to switch real platform vs. SDL implementation...
find_package(SDL3 REQUIRED)
find_package(flecs REQUIRED)
find_package(spdlog REQUIRED)
find_package(SDL3 CONFIG REQUIRED)
find_package(SDL3_image CONFIG REQUIRED)
find_package(flecs CONFIG REQUIRED)
find_package(spdlog CONFIG REQUIRED)
add_executable(HansTheGatherer main.cpp)
target_link_libraries(HansTheGatherer SDL3::SDL3 flecs::flecs spdlog::spdlog)
target_link_libraries(HansTheGatherer SDL3::SDL3 SDL3_image::SDL3_image flecs::flecs spdlog::spdlog)
set_property(TARGET HansTheGatherer PROPERTY CXX_STANDARD 20)

BIN
Fruit+.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

7
NOTICE Normal file
View File

@@ -0,0 +1,7 @@
Assets used by this project:
- "Fruit+" by SciGho — https://ninjikin.itch.io/fruit
License: https://creativecommons.org/licenses/by/4.0/
- "Jungle Background (Parallax)" by TrashBoat93
URL: https://trashboat93.itch.io/jungle-background-parallax

BIN
jungle.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 165 KiB

BIN
jungle.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 KiB

View File

@@ -1,13 +1,19 @@
#include <SDL3/SDL.h>
#include <SDL3/SDL_error.h>
#include <SDL3/SDL_iostream.h>
#include <SDL3/SDL_render.h>
#include <SDL3/SDL_video.h>
#include <SDL3_image/SDL_image.h>
#include <flecs.h>
#include <spdlog/spdlog.h>
const uint8_t image_data[] = {
#embed "main.cpp"
#embed "jungle.jpg"
};
static constexpr int WINDOW_WIDTH = 400;
static constexpr int WINDOW_HEIGHT = 280;
auto main() -> int {
spdlog::info("Initialize SDL...");
bool sdl_success = SDL_Init(SDL_INIT_VIDEO);
@@ -16,7 +22,8 @@ auto main() -> int {
std::terminate();
}
auto *sdl_window = SDL_CreateWindow("HansTheGatherer", 400, 280, 0);
auto *sdl_window =
SDL_CreateWindow("HansTheGatherer", WINDOW_WIDTH, WINDOW_HEIGHT, 0);
if (sdl_window == nullptr) {
spdlog::critical("Failed to create SDL window!\nCause: {}", SDL_GetError());
}
@@ -29,6 +36,12 @@ auto main() -> int {
flecs::world world;
auto *image_iostream = SDL_IOFromConstMem(image_data, sizeof(image_data));
SDL_Texture *img = IMG_LoadTexture_IO(sdl_renderer, image_iostream, false);
if (img == nullptr) {
spdlog::error("Failed to load SDL texture!\nCause: {}", SDL_GetError());
}
bool exit_gameloop = false;
while (!exit_gameloop) {
SDL_Event event;
@@ -44,6 +57,10 @@ auto main() -> int {
break;
}
}
SDL_RenderClear(sdl_renderer);
SDL_RenderTexture(sdl_renderer, img, nullptr, nullptr);
SDL_RenderPresent(sdl_renderer);
}
SDL_DestroyRenderer(sdl_renderer);

View File

@@ -2,6 +2,10 @@
"dependencies": [
"spdlog",
"sdl3",
{
"name": "sdl3-image",
"features": ["jpeg"]
},
"spdlog",
"flecs"
]