1
0
mirror of https://github.com/minetest/minetest_game.git synced 2024-12-22 23:10:17 +01:00

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:
MirceaKitsune 2012-11-25 00:24:33 +02:00 committed by Perttu Ahola
parent 39e4bf0346
commit 91da5d1308
3 changed files with 654 additions and 1776 deletions

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -14,13 +14,12 @@ default_texture = "character.png"
-- Player states
local player_model = {}
local player_anim = {}
local player_sneak = {}
local ANIM_STAND = 0
local ANIM_WALK_FORWARD = 1
local ANIM_WALK_BACKWARD = 2
local ANIM_WALK_LEFT = 3
local ANIM_WALK_RIGHT = 4
local ANIM_MINE = 5
local ANIM_DEATH = 6
local ANIM_WALK = 1
local ANIM_WALK_MINE = 2
local ANIM_MINE = 3
local ANIM_DEATH = 4
-- Frame ranges for each player model
function player_get_animations(model)
@ -28,18 +27,14 @@ function player_get_animations(model)
return {
stand_START = 0,
stand_END = 79,
walk_forward_START = 81,
walk_forward_END = 100,
walk_backward_START = 102,
walk_backward_END = 121,
walk_right_START = 123,
walk_right_END = 142,
walk_left_START = 144,
walk_left_END = 163,
mine_START = 165,
mine_END = 179,
death_START = 181,
death_END = 200
walk_START = 81,
walk_END = 100,
mine_START = 102,
mine_END = 111,
walk_mine_START = 113,
walk_mine_END = 132,
death_START = 134,
death_END = 153
}
end
end
@ -71,34 +66,45 @@ function on_step(dtime)
local anim = player_get_animations(player_model[name])
local controls = pl:get_player_control()
if controls.up then
if player_anim[name] ~= ANIM_WALK_FORWARD then
pl:set_animation({x=anim.walk_forward_START, y=anim.walk_forward_END}, animation_speed, animation_blend)
player_anim[name] = ANIM_WALK_FORWARD
local walking = false
if controls.up or controls.down or controls.left or controls.right then
walking = true
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
elseif controls.down then
if player_anim[name] ~= ANIM_WALK_BACKWARD then
pl:set_animation({x=anim.walk_backward_START, y=anim.walk_backward_END}, animation_speed, animation_blend)
player_anim[name] = ANIM_WALK_BACKWARD
else
-- Refresh player animation below
if player_sneak[name] then
player_anim[name] = -1
player_sneak[name] = false
end
elseif controls.left then
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)
player_anim[name] = ANIM_WALK_LEFT
end
if walking and controls.LMB then
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
elseif controls.right then
if player_anim[name] ~= ANIM_WALK_RIGHT then
pl:set_animation({x=anim.walk_right_START, y=anim.walk_right_END}, animation_speed, animation_blend)
player_anim[name] = ANIM_WALK_RIGHT
elseif walking then
if player_anim[name] ~= ANIM_WALK then
pl:set_animation({x=anim.walk_START, y=anim.walk_END}, animation_speed_modified, animation_blend)
player_anim[name] = ANIM_WALK
end
elseif controls.LMB 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
end
elseif player_anim[name] ~= ANIM_WALK_STAND then
pl:set_animation({x=anim.stand_START, y=anim.stand_END}, animation_speed, animation_blend)
player_anim[name] = ANIM_WALK_STAND
elseif player_anim[name] ~= ANIM_STAND then
pl:set_animation({x=anim.stand_START, y=anim.stand_END}, animation_speed_modified, animation_blend)
player_anim[name] = ANIM_STAND
end
end
end