aboutsummaryrefslogtreecommitdiff
path: root/sprite_system.c
diff options
context:
space:
mode:
authorquou <quou@disroot.org>2023-05-06 10:39:19 +1000
committerquou <quou@disroot.org>2023-05-06 10:39:19 +1000
commit91aef268319a77ee8f5a082ca89264bf2671e212 (patch)
tree7deb9a4a9e928d4b78f7c3398e7d9c97a4649140 /sprite_system.c
parent2ab411c4b8855d11d48454a93262e8eae3ba7fc7 (diff)
Map rendering and camera movement.
Diffstat (limited to 'sprite_system.c')
-rw-r--r--sprite_system.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sprite_system.c b/sprite_system.c
index 526c097..b94886e 100644
--- a/sprite_system.c
+++ b/sprite_system.c
@@ -5,7 +5,7 @@
#include "world.h"
void sprite_system(const World* world) {
- int i;
+ int i, x, y;
unsigned bits;
const CSprite* sprite;
const CPosition* pos;
@@ -17,8 +17,11 @@ void sprite_system(const World* world) {
pos = &world->positions[i];
sprite = &world->sprites[i];
+ x = pos->x - world->cam_x;
+ y = pos->y - world->cam_y;
+
b = get_bitmap(sprite->id);
- render_bitmap(b, pos->x >> fbits, pos->y >> fbits, &sprite->rect);
+ render_bitmap(b, x >> fbits, y >> fbits, &sprite->rect);
}
}
}