From 91aef268319a77ee8f5a082ca89264bf2671e212 Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 6 May 2023 10:39:19 +1000 Subject: Map rendering and camera movement. --- sprite_system.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'sprite_system.c') 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); } } } -- cgit v1.2.3-54-g00ecf