summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2021-03-30 01:01:06 (EDT)
committer P. J. McDermott <pj@pehjota.net>2021-03-30 01:01:06 (EDT)
commitf691e5f266a42aac8a14eb6c71e59111cc9fa16f (patch)
tree01fc1955f08a18b6be19934701fb34d0781231a2
parent84e1e9caa44a5e5c25901ca03efead7ba15ca8dc (diff)
downloaddodge-balls-f691e5f266a42aac8a14eb6c71e59111cc9fa16f.zip
dodge-balls-f691e5f266a42aac8a14eb6c71e59111cc9fa16f.tar.gz
dodge-balls-f691e5f266a42aac8a14eb6c71e59111cc9fa16f.tar.bz2
Revert "[WIP] map: Merge wall tiles into hor/vert lines"
-rw-r--r--src/map.c41
1 files changed, 4 insertions, 37 deletions
diff --git a/src/map.c b/src/map.c
index 0a093ee..f33782f 100644
--- a/src/map.c
+++ b/src/map.c
@@ -32,11 +32,6 @@
#include "output.h"
#include "xml.h"
-struct db_wall {
- SDL_Rect rect;
- struct db_wall *next;
-};
-
struct db_map_layer {
Uint32 *tiles;
char *encoding;
@@ -79,8 +74,7 @@ struct db_map {
struct db_ball *ball_head;
struct db_ball *ball_tail;
Uint8 *p_col;
- struct db_wall *wall_head;
- struct db_wall *wall_tail;
+ Uint8 *b_col;
};
static char *
@@ -777,9 +771,6 @@ _db_map_set_collision_tiles(struct db_map *map)
struct db_map_layer *layer;
int i;
int gid;
- Uint8 *b_col;
- int x;
- int y;
db_dbg("Allocating %d bit field elements", (map->w * map->h + 7) / 8);
map->p_col = calloc((map->w * map->h + 7) / 8, sizeof(*map->p_col));
@@ -787,8 +778,8 @@ _db_map_set_collision_tiles(struct db_map *map)
db_err("Failed to allocate memory");
return;
}
- b_col = calloc((map->w * map->h + 7) / 8, sizeof(*map->p_col));
- if (b_col == NULL) {
+ map->b_col = calloc((map->w * map->h + 7) / 8, sizeof(*map->p_col));
+ if (map->b_col == NULL) {
db_err("Failed to allocate memory");
free(map->p_col);
return;
@@ -807,31 +798,7 @@ _db_map_set_collision_tiles(struct db_map *map)
map->p_col[i / 8] |= 1 << (i % 8);
}
if (db_tile_ball_collides(map->tileset_head, gid)) {
- b_col[i / 8] |= 1 << (i % 8);
- }
- }
- }
-
- for (y = 0; y < map->h; ++y) {
- for (x = 0; x < map->w; ++x) {
- i = y * map->w + x;
- if ((b_col[i / 8] & (1 << (i % 8))) != 0) {
- if (x > 0 && map->walls[i] != NULL) {
- ++map->walls[i - 1].rect.w;
- map->walls[i] = map->walls[i - 1];
- continue;
- }
- map->wall_tail = calloc(1,
- sizeof(*map->wall_tail));
- if (map->wall_tail == NULL) {
- db_err("Failed to allocate memory");
- free(map->p_col);
- free(b_col);
- return;
- }
- if (map->wall_head == NULL) {
- map->wall_head = map->wall_tail;
- }
+ map->b_col[i / 8] |= 1 << (i % 8);
}
}
}