implemented angles in sprite rendering, knifes has proper rotation based from direction of player
parent
3a9196d19a
commit
c21cb39140
|
@ -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;
|
||||||
|
|
|
@ -29,6 +29,10 @@ void WeaponKnifeMechanic(ecs_iter_t *it) {
|
||||||
.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,
|
||||||
.y=input[i].hy*WEAPON_PROJECTILE_SPEED*-1
|
.y=input[i].hy*WEAPON_PROJECTILE_SPEED*-1
|
||||||
|
|
Loading…
Reference in New Issue