Anim init

This commit is contained in:
2026-08-04 01:25:34 +05:00
parent a6d9a9f25d
commit 2ac0413d78
13 changed files with 128 additions and 45 deletions
+32 -20
View File
@@ -43,13 +43,13 @@ Player :: struct {
dash_timer: f32,
}
make_player :: proc() -> Entity {
make_player :: proc(gfx: ^GraphicsAssetStore) -> Entity {
p := Player {
level = 1,
xp = 0,
xp_next = 50,
base_dmg = 10,
base_crit = 0.1,
level = 1,
xp = 0,
xp_next = 50,
base_dmg = 10,
base_crit = 0.1,
base_atk_cd = 0.35,
base_max_hp = 100,
attack_range = 90,
@@ -62,7 +62,16 @@ make_player :: proc() -> Entity {
}
p.base.pos = {0, 0}
p.base.col_size = 16
p.base.gfx = {0 = GfxCircle{pos = {}, radius = 14, color = {80, 220, 100, 255}}}
p.base.gfx = {
0 = GfxCircle{pos = {}, radius = 14, color = {80, 220, 100, 255}},
1 = GfxAnimatedSprite {
pos = {},
rect = {0, 0, 64, 64},
tex = gfx_get(gfx, .IDLE),
frame = 0,
speed = 1,
},
}
p.hp = p.base_max_hp
p.max_hp = p.base_max_hp
p.speed = 220
@@ -164,9 +173,9 @@ sys_input :: proc(state: ^GameState, dt: f32) {
// движение (45° поворот под изометрию)
move: rl.Vector2
if rl.IsKeyDown(.W) || rl.IsKeyDown(.UP) do move += {-1, -1}
if rl.IsKeyDown(.S) || rl.IsKeyDown(.DOWN) do move += {1, 1}
if rl.IsKeyDown(.A) || rl.IsKeyDown(.LEFT) do move += {-1, 1}
if rl.IsKeyDown(.W) || rl.IsKeyDown(.UP) do move += {-1, -1}
if rl.IsKeyDown(.S) || rl.IsKeyDown(.DOWN) do move += {1, 1}
if rl.IsKeyDown(.A) || rl.IsKeyDown(.LEFT) do move += {-1, 1}
if rl.IsKeyDown(.D) || rl.IsKeyDown(.RIGHT) do move += {1, -1}
if p.dash_timer > 0 {
@@ -195,16 +204,19 @@ sys_input :: proc(state: ^GameState, dt: f32) {
if p.attack_timer > 0 do p.attack_timer -= dt
if rl.IsMouseButtonPressed(.LEFT) && p.attack_timer <= 0 {
p.attack_timer = player_atk_cd(p)
init_attack(state, Attack{
parent = state.player,
dir = p.aim,
dmg = player_total_dmg(p),
crit = player_crit(p),
radius = p.attack_range,
arc = 1.3,
lifetime = player_atk_cd(p),
color = {255, 255, 255, 60},
})
init_attack(
state,
Attack {
parent = state.player,
dir = p.aim,
dmg = player_total_dmg(p),
crit = player_crit(p),
radius = p.attack_range,
arc = 1.3,
lifetime = player_atk_cd(p),
color = {255, 255, 255, 60},
},
)
}
// навыки