aboutsummaryrefslogtreecommitdiff
path: root/sprite_system.c
blob: b94886ee5f01867e71515508ec1463fd624026d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include "asset.h"
#include "components.h"
#include "render.h"
#include "standard.h"
#include "world.h"

void sprite_system(const World* world) {
	int i, x, y;
	unsigned bits;
	const CSprite* sprite;
	const CPosition* pos;
	const Bitmap* b;

	for (i = 0; i < world->entity_count; i++) {
		bits = world->bitmask[i];
		if ((bits & ctype_position) && (bits & ctype_sprite)) {
			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, x >> fbits, y >> fbits, &sprite->rect);
		}
	}
}