implemented angles in sprite rendering, knifes has proper rotation based from direction of player
parent
3a9196d19a
commit
c21cb39140
|
@ -48,7 +48,7 @@ entity_view* world_build_entity_view(int64_t e) {
|
||||||
view.vx = vel->x;
|
view.vx = vel->x;
|
||||||
view.vy = vel->y;
|
view.vy = vel->y;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Rotation* rot = ecs_get(world_ecs(), e, Rotation);
|
const Rotation* rot = ecs_get(world_ecs(), e, Rotation);
|
||||||
if (rot) {
|
if (rot) {
|
||||||
view.angle = rot->angle;
|
view.angle = rot->angle;
|
||||||
|
|
|
@ -61,7 +61,7 @@ void renderer_draw_entry(uint64_t key, entity_view *data, game_world_render_entr
|
||||||
case EKIND_WEAPON: {
|
case EKIND_WEAPON: {
|
||||||
float x = data->x;
|
float x = data->x;
|
||||||
float y = data->y;
|
float y = data->y;
|
||||||
DrawSpriteEco(&main_sprite_sheet, data->frame, x, y, 0.0f, 2.0f, WHITE);
|
DrawSpriteEco(&main_sprite_sheet, data->frame, x, y, data->angle, 2.0f, WHITE);
|
||||||
} break;
|
} break;
|
||||||
case EKIND_DEVICE:{
|
case EKIND_DEVICE:{
|
||||||
float x = data->x - 32.f;
|
float x = data->x - 32.f;
|
||||||
|
|
|
@ -28,6 +28,10 @@ void WeaponKnifeMechanic(ecs_iter_t *it) {
|
||||||
.origin_x=pos[i].x,
|
.origin_x=pos[i].x,
|
||||||
.origin_y=pos[i].y
|
.origin_y=pos[i].y
|
||||||
});
|
});
|
||||||
|
|
||||||
|
ecs_set(it->world, e, Rotation, {
|
||||||
|
.angle=zpl_to_degrees(zpl_arctan2(input[i].hx, input[i].hy))
|
||||||
|
});
|
||||||
|
|
||||||
ecs_set(it->world, e, Velocity, {
|
ecs_set(it->world, e, Velocity, {
|
||||||
.x=input[i].hx*WEAPON_PROJECTILE_SPEED,
|
.x=input[i].hx*WEAPON_PROJECTILE_SPEED,
|
||||||
|
|
Loading…
Reference in New Issue