rendering.c: non-square rotating sprites
This commit is contained in:
parent
8a0f767002
commit
e8ff04b3e6
@ -37,6 +37,11 @@ static void ingame_tick(struct state *state) {
|
|||||||
.path = "/assets/player/baron-walk.png",
|
.path = "/assets/player/baron-walk.png",
|
||||||
.color = (t_color){255, 255, 255, 255}, });
|
.color = (t_color){255, 255, 255, 255}, });
|
||||||
|
|
||||||
|
push_sprite_ex((t_frect){ .x = 128, .y = 32, .w = 128, .h = 64 }, (t_push_sprite_args){
|
||||||
|
.path = "/assets/player/baron-walk.png",
|
||||||
|
.color = (t_color){255, 255, 255, 255},
|
||||||
|
.rotation = (float)M_PI * 2 * (float)(ctx.tick_count % 64) / 64, });
|
||||||
|
|
||||||
unfurl_triangle("/assets/big-violet.png",
|
unfurl_triangle("/assets/big-violet.png",
|
||||||
(t_fvec3){ -1, -1, 0 },
|
(t_fvec3){ -1, -1, 0 },
|
||||||
(t_fvec3){ 1, -1, 0 },
|
(t_fvec3){ 1, -1, 0 },
|
||||||
|
@ -241,7 +241,15 @@ static void render_sprites(const struct primitive_2d primitives[],
|
|||||||
} else {
|
} else {
|
||||||
/* rotated non-square case*/
|
/* rotated non-square case*/
|
||||||
|
|
||||||
CRY("Rotation", "Unimplemented");
|
const t_fvec2 c = frect_center(sprite.rect);
|
||||||
|
const t_fvec2 t = fast_cossine(sprite.rotation);
|
||||||
|
|
||||||
|
const t_fvec2 h = { sprite.rect.w / 2, sprite.rect.h / 2 };
|
||||||
|
|
||||||
|
v0 = (t_fvec2){ c.x + t.x * -h.x - t.y * -h.y, c.y + t.y * -h.x + t.x * -h.y };
|
||||||
|
v1 = (t_fvec2){ c.x + t.x * -h.x - t.y * +h.y, c.y + t.y * -h.x + t.x * +h.y };
|
||||||
|
v2 = (t_fvec2){ c.x + t.x * +h.x - t.y * +h.y, c.y + t.y * +h.x + t.x * +h.y };
|
||||||
|
v3 = (t_fvec2){ c.x + t.x * +h.x - t.y * -h.y, c.y + t.y * +h.x + t.x * -h.y };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!batch.constant_colored)
|
if (!batch.constant_colored)
|
||||||
|
Loading…
Reference in New Issue
Block a user