Model - Get rid of the 4 walk animations and only leave one, which looks good for all directions. Also add a Walk + Mine animation, since Irrlicht doesn't support blending the two animations otherwise
Update player script to match the animations in the previous commit Shorten the still mine animation so the hand matches the speed of the walk-mine animation Reduce animation speed to half when sneaking
This commit is contained in:
parent
39e4bf0346
commit
91da5d1308
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -14,13 +14,12 @@ default_texture = "character.png"
|
||||||
-- Player states
|
-- Player states
|
||||||
local player_model = {}
|
local player_model = {}
|
||||||
local player_anim = {}
|
local player_anim = {}
|
||||||
|
local player_sneak = {}
|
||||||
local ANIM_STAND = 0
|
local ANIM_STAND = 0
|
||||||
local ANIM_WALK_FORWARD = 1
|
local ANIM_WALK = 1
|
||||||
local ANIM_WALK_BACKWARD = 2
|
local ANIM_WALK_MINE = 2
|
||||||
local ANIM_WALK_LEFT = 3
|
local ANIM_MINE = 3
|
||||||
local ANIM_WALK_RIGHT = 4
|
local ANIM_DEATH = 4
|
||||||
local ANIM_MINE = 5
|
|
||||||
local ANIM_DEATH = 6
|
|
||||||
|
|
||||||
-- Frame ranges for each player model
|
-- Frame ranges for each player model
|
||||||
function player_get_animations(model)
|
function player_get_animations(model)
|
||||||
|
@ -28,18 +27,14 @@ function player_get_animations(model)
|
||||||
return {
|
return {
|
||||||
stand_START = 0,
|
stand_START = 0,
|
||||||
stand_END = 79,
|
stand_END = 79,
|
||||||
walk_forward_START = 81,
|
walk_START = 81,
|
||||||
walk_forward_END = 100,
|
walk_END = 100,
|
||||||
walk_backward_START = 102,
|
mine_START = 102,
|
||||||
walk_backward_END = 121,
|
mine_END = 111,
|
||||||
walk_right_START = 123,
|
walk_mine_START = 113,
|
||||||
walk_right_END = 142,
|
walk_mine_END = 132,
|
||||||
walk_left_START = 144,
|
death_START = 134,
|
||||||
walk_left_END = 163,
|
death_END = 153
|
||||||
mine_START = 165,
|
|
||||||
mine_END = 179,
|
|
||||||
death_START = 181,
|
|
||||||
death_END = 200
|
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -71,34 +66,45 @@ function on_step(dtime)
|
||||||
local anim = player_get_animations(player_model[name])
|
local anim = player_get_animations(player_model[name])
|
||||||
local controls = pl:get_player_control()
|
local controls = pl:get_player_control()
|
||||||
|
|
||||||
if controls.up then
|
local walking = false
|
||||||
if player_anim[name] ~= ANIM_WALK_FORWARD then
|
if controls.up or controls.down or controls.left or controls.right then
|
||||||
pl:set_animation({x=anim.walk_forward_START, y=anim.walk_forward_END}, animation_speed, animation_blend)
|
walking = true
|
||||||
player_anim[name] = ANIM_WALK_FORWARD
|
end
|
||||||
|
|
||||||
|
local animation_speed_modified = animation_speed
|
||||||
|
if controls.sneak and (walking or controls.LMB) then
|
||||||
|
animation_speed_modified = animation_speed_modified / 2
|
||||||
|
-- Refresh player animation below
|
||||||
|
if not player_sneak[name] then
|
||||||
|
player_anim[name] = -1
|
||||||
|
player_sneak[name] = true
|
||||||
end
|
end
|
||||||
elseif controls.down then
|
else
|
||||||
if player_anim[name] ~= ANIM_WALK_BACKWARD then
|
-- Refresh player animation below
|
||||||
pl:set_animation({x=anim.walk_backward_START, y=anim.walk_backward_END}, animation_speed, animation_blend)
|
if player_sneak[name] then
|
||||||
player_anim[name] = ANIM_WALK_BACKWARD
|
player_anim[name] = -1
|
||||||
|
player_sneak[name] = false
|
||||||
end
|
end
|
||||||
elseif controls.left then
|
end
|
||||||
if player_anim[name] ~= ANIM_WALK_LEFT then
|
|
||||||
pl:set_animation({x=anim.walk_left_START, y=anim.walk_left_END}, animation_speed, animation_blend)
|
if walking and controls.LMB then
|
||||||
player_anim[name] = ANIM_WALK_LEFT
|
if player_anim[name] ~= ANIM_WALK_MINE then
|
||||||
|
pl:set_animation({x=anim.walk_mine_START, y=anim.walk_mine_END}, animation_speed_modified, animation_blend)
|
||||||
|
player_anim[name] = ANIM_WALK_MINE
|
||||||
end
|
end
|
||||||
elseif controls.right then
|
elseif walking then
|
||||||
if player_anim[name] ~= ANIM_WALK_RIGHT then
|
if player_anim[name] ~= ANIM_WALK then
|
||||||
pl:set_animation({x=anim.walk_right_START, y=anim.walk_right_END}, animation_speed, animation_blend)
|
pl:set_animation({x=anim.walk_START, y=anim.walk_END}, animation_speed_modified, animation_blend)
|
||||||
player_anim[name] = ANIM_WALK_RIGHT
|
player_anim[name] = ANIM_WALK
|
||||||
end
|
end
|
||||||
elseif controls.LMB then
|
elseif controls.LMB then
|
||||||
if player_anim[name] ~= ANIM_MINE then
|
if player_anim[name] ~= ANIM_MINE then
|
||||||
pl:set_animation({x=anim.mine_START, y=anim.mine_END}, animation_speed, animation_blend)
|
pl:set_animation({x=anim.mine_START, y=anim.mine_END}, animation_speed_modified, animation_blend)
|
||||||
player_anim[name] = ANIM_MINE
|
player_anim[name] = ANIM_MINE
|
||||||
end
|
end
|
||||||
elseif player_anim[name] ~= ANIM_WALK_STAND then
|
elseif player_anim[name] ~= ANIM_STAND then
|
||||||
pl:set_animation({x=anim.stand_START, y=anim.stand_END}, animation_speed, animation_blend)
|
pl:set_animation({x=anim.stand_START, y=anim.stand_END}, animation_speed_modified, animation_blend)
|
||||||
player_anim[name] = ANIM_WALK_STAND
|
player_anim[name] = ANIM_STAND
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue