-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsrender.c
More file actions
72 lines (59 loc) · 1.44 KB
/
Copy pathsrender.c
File metadata and controls
72 lines (59 loc) · 1.44 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <srender.h>
#include <entity.h>
#include <component.h>
#include <r_main.h>
#include <gmath.h>
#include <transform.h>
static decl_component_storage(
srender,
SRENDER_PUBLIC_FIELDS,
SRENDER_PUBLIC_FIELDS)
static inline void srender_init_private(void) {}
static inline void srender_shutdown_private(void) {}
void srender_start(void) {}
static inline void srender_add_private(Entity ent, EntityIndex index)
{
(void)ent;
(void)index;
}
static inline void srender_rem_private(Entity ent, EntityIndex index)
{
(void)ent;
(void)index;
}
static inline int srender_sprite_impl(EntityIndex id)
{
return srender_data.sprite[id];
}
static inline void srender_set_sprite_impl(EntityIndex id, int new_sprite)
{
srender_data.sprite[id] = new_sprite;
}
static inline Vec3 srender_color_impl(EntityIndex id)
{
return srender_data.color[id];
}
static inline void srender_set_color_impl(EntityIndex id, Vec3 new_color)
{
srender_data.color[id] = new_color;
}
void srender_draw_all(Vec2 camera)
{
for (int i = 1; i <= srender_data.count; i++) {
transform t;
Vec3 color;
Vec2 p, s;
t = transform_get(srender_data.rev_map[i]);
if (t.id == 0) continue;
color = srender_data.color[i];
p = transform_position(t);
s = transform_scale(t);
r_set_draw_color(color.x, color.y ,color.z, 255);
r_fill_rect(&(SDL_FRect){
p.x + GAME_VIEW_WIDTH / 2 -
s.x / 2 - camera.x,
-p.y + GAME_VIEW_HEIGHT / 2 -
s.y / 2 + camera.y,
s.x, s.y});
}
}