diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-03-25 19:17:36 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-03-25 19:17:36 (EDT) |
commit | 02c5d26d0d65ef0f861df18a5c00d720ac405012 (patch) | |
tree | ee7a1750cc1acdbdc2bb65bcb53a8cd4954762c1 /src | |
parent | 81de78c6de8adf57bb713ea396a94bcfdd8ad035 (diff) | |
download | dodge-balls-02c5d26d0d65ef0f861df18a5c00d720ac405012.zip dodge-balls-02c5d26d0d65ef0f861df18a5c00d720ac405012.tar.gz dodge-balls-02c5d26d0d65ef0f861df18a5c00d720ac405012.tar.bz2 |
map: Save player and target GIDs
Diffstat (limited to 'src')
-rw-r--r-- | src/level.c | 6 | ||||
-rw-r--r-- | src/map.c | 34 | ||||
-rw-r--r-- | src/map.h | 4 |
3 files changed, 26 insertions, 18 deletions
diff --git a/src/level.c b/src/level.c index 9de9182..73f12a6 100644 --- a/src/level.c +++ b/src/level.c @@ -34,9 +34,11 @@ struct db_level { int player_r; int player_a; int player_s; + int player_gid; int target_x; int target_y; int target_r; + int target_gid; struct db_ball *balls; }; @@ -88,9 +90,9 @@ db_level_play(SDL_Renderer *renderer, struct db_level *level) map_texture = db_map_render(map, renderer); level->tilesets = db_map_get_tilesets(map); db_map_get_player(map, &level->player_x, &level->player_y, - &level->player_r); + &level->player_r, &level->player_gid); db_map_get_target(map, &level->target_x, &level->target_y, - &level->target_r); + &level->target_r, &level->target_gid); level->balls = db_map_get_balls(map); if (SDL_RenderClear(renderer) != 0) { @@ -66,9 +66,11 @@ struct db_map { int player_x; int player_y; int player_r; + int player_gid; int target_x; int target_y; int target_r; + int target_gid; struct db_ball *ball_head; struct db_ball *ball_tail; }; @@ -530,13 +532,15 @@ _db_tmx_object_end(void *pv, const char *name) if (db_xml_check_tag(name, "object")) { if (strcmp(map->obj_type, "player") == 0) { - map->player_x = map->obj_x; - map->player_y = map->obj_y; - map->player_r = map->obj_r; + map->player_x = map->obj_x; + map->player_y = map->obj_y; + map->player_r = map->obj_r; + map->player_gid = map->obj_gid; } else if (strcmp(map->obj_type, "target") == 0) { - map->target_x = map->obj_x; - map->target_y = map->obj_y; - map->target_r = map->obj_r; + map->target_x = map->obj_x; + map->target_y = map->obj_y; + map->target_r = map->obj_r; + map->target_gid = map->obj_gid; } else if (strcmp(map->obj_type, "ball") == 0) { map->ball_tail = db_ball_new(map->obj_x, map->obj_y, map->obj_r, map->obj_a, map->obj_d, @@ -899,19 +903,21 @@ db_map_get_tilesets(struct db_map *map) } void -db_map_get_player(struct db_map *map, int *x, int *y, int *r) +db_map_get_player(struct db_map *map, int *x, int *y, int *r, int *gid) { - *x = map->player_x; - *y = map->player_y; - *r = map->player_r; + *x = map->player_x; + *y = map->player_y; + *r = map->player_r; + *gid = map->player_gid; } void -db_map_get_target(struct db_map *map, int *x, int *y, int *r) +db_map_get_target(struct db_map *map, int *x, int *y, int *r, int *gid) { - *x = map->target_x; - *y = map->target_y; - *r = map->target_r; + *x = map->target_x; + *y = map->target_y; + *r = map->target_r; + *gid = map->target_gid; } struct db_ball *db_map_get_balls(struct db_map *map) @@ -29,8 +29,8 @@ struct db_map *db_map_new(const char *game_id, const char *level_id); SDL_Texture *db_map_render(struct db_map *map, SDL_Renderer *renderer); struct db_tileset *db_map_get_tilesets(struct db_map *map) __attribute__((__pure__)); -void db_map_get_player(struct db_map *map, int *x, int *y, int *r); -void db_map_get_target(struct db_map *map, int *x, int *y, int *r); +void db_map_get_player(struct db_map *map, int *x, int *y, int *r, int *gid); +void db_map_get_target(struct db_map *map, int *x, int *y, int *r, int *gid); struct db_ball *db_map_get_balls(struct db_map *map) __attribute__((__pure__)); |