aboutsummaryrefslogtreecommitdiff
path: root/map.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-06 12:22:50 +1000
committerquou <quou@disroot.org>2023-05-06 12:22:50 +1000
commit937edea9599718e959f8ed135e97c68728855975 (patch)
treeea5d5551b470603d2d907dba4869ff52e742d9de /map.c
parent91aef268319a77ee8f5a082ca89264bf2671e212 (diff)
Add solid environment collisions.
Diffstat (limited to 'map.c')
-rw-r--r--map.c40
1 files changed, 39 insertions, 1 deletions
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
+ );
}
}