diff options
author | quou <quou@disroot.org> | 2023-05-06 12:22:50 +1000 |
---|---|---|
committer | quou <quou@disroot.org> | 2023-05-06 12:22:50 +1000 |
commit | 937edea9599718e959f8ed135e97c68728855975 (patch) | |
tree | ea5d5551b470603d2d907dba4869ff52e742d9de /map.c | |
parent | 91aef268319a77ee8f5a082ca89264bf2671e212 (diff) |
Add solid environment collisions.
Diffstat (limited to 'map.c')
-rw-r--r-- | map.c | 40 |
1 files changed, 39 insertions, 1 deletions
@@ -1,8 +1,9 @@ #include "map.h" #include "sprite.h" #include "standard.h" +#include "solid.h" -void init_map(Map* map) { +void init_map(Map* map, World* world) { const Sprite* floor, * bricks; const Bitmap* fbmp, * bbmp; Bitmap bitmap; @@ -67,6 +68,36 @@ void init_map(Map* map) { ); } + /* Bounds */ + new_solid( + world, + 0, + 0, + (map_width * map_tile_size) << fbits, + map_tile_size << fbits + ); + new_solid( + world, + 0, + ((map_height - 1) * map_tile_size) << fbits, + (map_width * map_tile_size) << fbits, + map_tile_size << fbits + ); + new_solid( + world, + 0, + 0, + map_tile_size << fbits, + (map_height * map_tile_size) << fbits + ); + new_solid( + world, + ((map_width - 1) * map_tile_size) << fbits, + 0, + map_tile_size << fbits, + (map_height * map_tile_size) << fbits + ); + for (i = 0; i < 20; i++) { x = rand_range(0, map_width - 1) * map_tile_size; y = rand_range(0, map_height - 1) * map_tile_size; @@ -77,6 +108,13 @@ void init_map(Map* map) { y, &bricks->rect ); + new_solid( + world, + x << fbits, + y << fbits, + map_tile_size << fbits, + map_tile_size << fbits + ); } } |