QUOTE: Never too old to chase dreams.

feat: Updated struct inits - freezo - A retro platform game

freezo

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

commit a19857eb6d1b1249122d227d518a56b12383136f
parent e118d43a767c387eafb5ac13579b5a248756ae26
Author: Sophie <info@soophie.de>
Date:   Sun, 15 Dec 2024 17:42:38 +0100

feat: Updated struct inits

Diffstat:
Msrc/enemy.c | 26++++++++++++++------------
Msrc/game.c | 46++++++++++++++++++++++++----------------------
Msrc/player.c | 34++++++++++++++++++----------------
Dtodo.md | 17-----------------
Atodo.txt | 17+++++++++++++++++
5 files changed, 73 insertions(+), 67 deletions(-)

diff --git a/src/enemy.c b/src/enemy.c @@ -8,18 +8,20 @@ enemy_t *enemy_create(pos_t pos, enemy_e type) { enemy_t *enemy = malloc(sizeof(enemy_t)); - enemy->pos = pos; - enemy->type = type; - enemy->on_ground = false; - enemy->velocity = 0.0; - enemy->gravity = 0.0; - enemy->dir = 1; - enemy->stunned = false; - enemy->frozen = false; - enemy->frozen_timer = 0; - enemy->fall_height = 0.0; - enemy->timer_walking = timer_create(9, 8); - enemy->timer_sneaking = timer_create(9, 16); + *enemy = (enemy_t) { + .pos = pos, + .type = type, + .on_ground = false, + .velocity = 0.0, + .gravity = 0.0, + .dir = 1, + .stunned = false, + .frozen = false, + .frozen_timer = 0, + .fall_height = 0.0, + .timer_walking = timer_create(9, 8), + .timer_sneaking = timer_create(9, 16), + }; return enemy; } diff --git a/src/game.c b/src/game.c @@ -13,29 +13,31 @@ game_t *game_create(void) { game_t *game = malloc(sizeof(game_t)); - game->state = STATE_GAME; - game->level = NULL, - game->quit = false; - game->defeat = false; - game->victory = false; - game->menu = menu_create(); - game->player = NULL; - game->tiles = NULL; - game->tiles_len = 0; - game->entities = NULL; - game->entities_len = 0; - game->effects = NULL; - game->effects_len = 0; - game->assets.tiles = texture_load("assets/tiles.png", SCALE); - game->assets.entities = texture_load("assets/entities.png", SCALE); - game->assets.font = texture_load("assets/font.png", SCALE - 1); - game->assets.images = texture_load("assets/images.png", SCALE); - game->camera = (Camera2D) { - .offset = (pos_t) { 0.0, 0.0 }, - .zoom = 1, + *game = (game_t) { + .state = STATE_GAME, + .level = NULL, + .quit = false, + .defeat = false, + .victory = false, + .menu = menu_create(), + .player = NULL, + .tiles = NULL, + .tiles_len = 0, + .entities = NULL, + .entities_len = 0, + .effects = NULL, + .effects_len = 0, + .assets.tiles = texture_load("assets/tiles.png", SCALE), + .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), + .camera = (Camera2D) { + .offset = (pos_t) { 0.0, 0.0 }, + .zoom = 1, + }, + .xp = 0, + .sceen_timer = 0, }; - game->xp = 0; - game->sceen_timer = 0; level_load(game, LEVEL_1); return game; } diff --git a/src/player.c b/src/player.c @@ -10,22 +10,24 @@ player_t *player_create(pos_t pos) { player_t *player = malloc(sizeof(player_t)); - player->pos = pos; - player->health = 6; - player->on_ground = false; - player->velocity = 0.0; - player->gravity = 0.0; - player->dir = 1; - player->sneaking = false; - player->shooting = false; - player->damage_timer = 0; - player->fall_height = 0.0; - player->held_enemy = NULL; - player->moving = false; - player->timer_walking = timer_create(9, 4); - player->timer_sneaking = timer_create(9, 8); - player->target_entity = NULL; - player->shooting_distance = PLAYER_SHOOTING_RANGE; + *player = (player_t) { + .pos = pos, + .health = 6, + .on_ground = false, + .velocity = 0.0, + .gravity = 0.0, + .dir = 1, + .sneaking = false, + .shooting = false, + .damage_timer = 0, + .fall_height = 0.0, + .held_enemy = NULL, + .moving = false, + .timer_walking = timer_create(9, 4), + .timer_sneaking = timer_create(9, 8), + .target_entity = NULL, + .shooting_distance = PLAYER_SHOOTING_RANGE, + }; return player; } diff --git a/todo.md b/todo.md @@ -1,17 +0,0 @@ -Todos -===== - -- [x] Improve freeze target detection -- [x] Adjust win conditions (check if all gates are frozen) -- [x] Add ceiling collision -- [x] Victory/Defeat screen (delay) -- [x] Add title screen -- [ ] Create a file format for designing levels (also entity/tile state) -- [ ] Add wall collision -- [ ] Add move velocity (for damage and maybe icy surfaces) -- [x] Stop enemy movement on walls -- [ ] Stop freeze laser on walls -- [ ] Add hitboxes (make them visible in debug mode) -- [ ] Add countdown -- [ ] Add new enemies -- [ ] Add boss diff --git a/todo.txt b/todo.txt @@ -0,0 +1,17 @@ +Todos +===== + +- [x] Improve freeze target detection +- [x] Adjust win conditions (check if all gates are frozen) +- [x] Add ceiling collision +- [x] Victory/Defeat screen (delay) +- [x] Add title screen +- [ ] Create a file format for designing levels (also entity/tile state) +- [x] Add wall collision +- [ ] Add move velocity (for damage and maybe icy surfaces) +- [x] Stop enemy movement on walls +- [ ] Stop freeze laser on walls +- [ ] Add hitboxes (make them visible in debug mode) +- [ ] Add countdown +- [ ] Add new enemies +- [ ] Add boss