3D only
This commit is contained in:
+19
-3
@@ -66,10 +66,10 @@ make_player :: proc(gfx: ^GraphicsAssetStore) -> Entity {
|
||||
0 = GfxCircle{pos = {}, radius = 14, color = {80, 220, 100, 255}},
|
||||
1 = GfxAnimatedSprite {
|
||||
pos = {},
|
||||
rect = {0, 0, 64, 64},
|
||||
tex = gfx_get(gfx, .IDLE),
|
||||
atlas = player_atlas_get(gfx, .IDLE),
|
||||
frame = 0,
|
||||
speed = 1,
|
||||
speed = 0.5,
|
||||
update = update_player_sprite,
|
||||
},
|
||||
}
|
||||
p.hp = p.base_max_hp
|
||||
@@ -78,6 +78,15 @@ make_player :: proc(gfx: ^GraphicsAssetStore) -> Entity {
|
||||
return Entity{v = p}
|
||||
}
|
||||
|
||||
update_player_sprite :: proc(g: ^GfxAnimatedSprite, dt: f32) {
|
||||
g.current_time += dt
|
||||
if g.current_time > g.speed {
|
||||
g.current_time = g.current_time - g.speed
|
||||
g.frame += 1
|
||||
if g.frame > 3 do g.frame = 0
|
||||
}
|
||||
}
|
||||
|
||||
// ─── Итоговые статы из экипировки ───
|
||||
|
||||
player_total_dmg :: proc(p: ^Player) -> i32 {
|
||||
@@ -233,4 +242,11 @@ player_update :: proc(state: ^GameState, p: ^Player, h: Handle, dt: f32) {
|
||||
for &s in p.skills {
|
||||
if s.timer > 0 do s.timer -= dt
|
||||
}
|
||||
|
||||
for &gfx in p.gfx {
|
||||
#partial switch &v in gfx {
|
||||
case GfxAnimatedSprite:
|
||||
v->update(dt)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user