QUOTE: Life is a journey, not a destination.

feat: Added level background (unstable) - freezo - A retro platform game

freezo

A retro platform game
git clone git@soophie.de:/srv/git/freezo
log | files | refs | readme

commit 4845e8ea4007b452b2b3660902b677cad089d916
parent 57bc5859707882c32f3459e8bd9542cf69c6ea08
Author: Sophie <info@soophie.de>
Date:   Mon, 16 Dec 2024 00:49:35 +0100

feat: Added level background (unstable)

Diffstat:
Aassets/background.png | 0
Minclude/game.h | 1+
Msrc/game.c | 3+++
Msrc/level.c | 3++-
4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/assets/background.png b/assets/background.png Binary files differ. diff --git a/include/game.h b/include/game.h @@ -20,6 +20,7 @@ struct Assets { Texture2D entities; Texture2D font; Texture2D images; + Texture2D background; }; struct Game { diff --git a/src/game.c b/src/game.c @@ -31,6 +31,7 @@ game_t *game_create(void) { .assets.entities = texture_load("assets/entities.png", SCALE), .assets.font = texture_load("assets/font.png", SCALE - 1), .assets.images = texture_load("assets/images.png", SCALE), + .assets.background = texture_load("assets/background.png", SCALE), .camera = (Camera2D) { .offset = (pos_t) { 0.0, 0.0 }, .zoom = 1, @@ -146,6 +147,7 @@ void game_update(game_t *game) { void game_draw(game_t *game) { BeginDrawing(); ClearBackground(BLACK); + DrawTextureRec(game->assets.background, (Rectangle) { 0, 0, WINDOW_WIDTH * TILE_WIDTH, WINDOW_HEIGHT * TILE_HEIGHT }, (pos_t) { 0, 0 }, WHITE); if (game->level != LEVEL_NULL) { BeginMode2D(game->camera); for (int i = 0; i < game->tiles_len; i++) { @@ -204,5 +206,6 @@ void game_free(game_t *game) { UnloadTexture(game->assets.entities); UnloadTexture(game->assets.font); UnloadTexture(game->assets.images); + UnloadTexture(game->assets.background); free(game); } diff --git a/src/level.c b/src/level.c @@ -20,7 +20,7 @@ const char *LEVEL_MAP_1 = { "................e......." "...............--xxxxx.." "....p..................." - "..ggggggggg---xxxxxxxx.." + "..xxxxxxxxx---xxxxxxxx.." "........................" "........................" }; @@ -85,6 +85,7 @@ void level_generate(game_t *game, const char *map, int width, int height) { game->entities_len = 0; game->effects = NULL; game->effects_len = 0; + game->xp = 0; for (int y = 0; y < height; y++) { for (int x = 0; x < width; x++) { int idx = y * width + x;