From 937edea9599718e959f8ed135e97c68728855975 Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 6 May 2023 12:22:50 +1000 Subject: Add solid environment collisions. --- map.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) (limited to 'map.c') diff --git a/map.c b/map.c index 2b10abd..d8b6e1c 100644 --- a/map.c +++ b/map.c @@ -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 + ); } } -- cgit v1.2.3-54-g00ecf