Pausing
This commit is contained in:
parent
6f73eac596
commit
70d186d22a
62
main.lua
62
main.lua
@ -99,37 +99,41 @@ function love.quit( )
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
function love.update(dt)
|
function love.update(dt)
|
||||||
physics.gravity()
|
if pause ~= true then
|
||||||
move(dt)
|
physics.gravity()
|
||||||
physics.player_x_apply(dt)
|
move(dt)
|
||||||
|
physics.player_x_apply(dt)
|
||||||
|
|
||||||
pause_game()
|
pause_game()
|
||||||
|
|
||||||
|
maplib.load_chunks()
|
||||||
|
fpsGraph:update(dt)
|
||||||
|
memGraph:update(dt)
|
||||||
|
-- Update our custom graph
|
||||||
|
dtGraph:update(dt, math.floor(dt * 1000))
|
||||||
|
dtGraph.label = 'DT: ' .. dt
|
||||||
|
|
||||||
|
menu.animate()
|
||||||
|
mine(key,dt)
|
||||||
|
player.move_camera(dt)
|
||||||
|
maplib.liquid_flow(dt)
|
||||||
|
--debug
|
||||||
|
if love.keyboard.isDown("space") then
|
||||||
|
print("clear")
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
entity.gravity()
|
||||||
|
entity.physics_apply(dt)
|
||||||
|
|
||||||
|
particle.gravity()
|
||||||
|
particle.physics_apply(dt)
|
||||||
|
crafting.move_items()
|
||||||
|
|
||||||
|
maplib.new_block(player.playerx,player.playery)
|
||||||
|
else
|
||||||
|
|
||||||
maplib.load_chunks()
|
|
||||||
fpsGraph:update(dt)
|
|
||||||
memGraph:update(dt)
|
|
||||||
-- Update our custom graph
|
|
||||||
dtGraph:update(dt, math.floor(dt * 1000))
|
|
||||||
dtGraph.label = 'DT: ' .. dt
|
|
||||||
|
|
||||||
menu.animate()
|
|
||||||
mine(key,dt)
|
|
||||||
player.move_camera(dt)
|
|
||||||
maplib.liquid_flow(dt)
|
|
||||||
--debug
|
|
||||||
if love.keyboard.isDown("space") then
|
|
||||||
print("clear")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
entity.gravity()
|
|
||||||
entity.physics_apply(dt)
|
|
||||||
|
|
||||||
particle.gravity()
|
|
||||||
particle.physics_apply(dt)
|
|
||||||
crafting.move_items()
|
|
||||||
|
|
||||||
maplib.new_block(player.playerx,player.playery)
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -3,9 +3,13 @@
|
|||||||
pause = false
|
pause = false
|
||||||
|
|
||||||
function pause_game()
|
function pause_game()
|
||||||
while pause == true do
|
if pause == true then
|
||||||
|
|
||||||
love.graphics.rectangle( "line", 10, 1, 53,53 )
|
love.graphics.rectangle( "line", 10, 1, 53,53 )
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function render_pause_menu()
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
205
player.lua
205
player.lua
@ -101,13 +101,13 @@ function love.keypressed( key, scancode, isrepeat )
|
|||||||
|
|
||||||
--quit
|
--quit
|
||||||
if key == "escape" then
|
if key == "escape" then
|
||||||
maplib.save_chunks()
|
--maplib.save_chunks()
|
||||||
love.filesystem.write( "/map/player.txt", TSerial.pack({inventory,chunkx,chunky,player.playerx,player.playery}))
|
--love.filesystem.write( "/map/player.txt", TSerial.pack({inventory,chunkx,chunky,player.playerx,player.playery}))
|
||||||
|
|
||||||
love.timer.sleep(3)
|
--love.timer.sleep(3)
|
||||||
|
|
||||||
love.event.push('quit')
|
--love.event.push('quit')
|
||||||
--pause = true
|
pause = not pause
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -352,110 +352,111 @@ function player.draw()
|
|||||||
]]--
|
]]--
|
||||||
|
|
||||||
--leg animation
|
--leg animation
|
||||||
if player.inertiax ~= 0 then
|
if pause ~= true then
|
||||||
if leg_animation_up == true then
|
if player.inertiax ~= 0 then
|
||||||
leg_animation = leg_animation + math.abs(player.inertiax)
|
if leg_animation_up == true then
|
||||||
|
leg_animation = leg_animation + math.abs(player.inertiax)
|
||||||
|
|
||||||
if leg_animation >= 1 then
|
if leg_animation >= 1 then
|
||||||
leg_animation_up = false
|
leg_animation_up = false
|
||||||
|
end
|
||||||
|
elseif leg_animation_up == false then
|
||||||
|
leg_animation = leg_animation - math.abs(player.inertiax)
|
||||||
|
|
||||||
|
if leg_animation <= -1 then
|
||||||
|
leg_animation_up = true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
elseif leg_animation_up == false then
|
else --return animation to normal
|
||||||
leg_animation = leg_animation - math.abs(player.inertiax)
|
--return to 0
|
||||||
|
if leg_animation > -0.05 and leg_animation < 0.05 then
|
||||||
if leg_animation <= -1 then
|
leg_animation = 0
|
||||||
leg_animation_up = true
|
end
|
||||||
|
|
||||||
|
--push back
|
||||||
|
if leg_animation > 0 then
|
||||||
|
--print("animation down")
|
||||||
|
leg_animation = leg_animation - 0.05
|
||||||
|
elseif leg_animation < 0 then
|
||||||
|
--print("animation up")
|
||||||
|
leg_animation = leg_animation + 0.05
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else --return animation to normal
|
|
||||||
--return to 0
|
if (leg_animation > -0.1 and leg_animation < 0.1) and not (old_leg_animation > -0.1 and old_leg_animation < 0.1) then
|
||||||
if leg_animation > -0.05 and leg_animation < 0.05 then
|
stepsound:setPitch(love.math.random(80,100)/100)
|
||||||
leg_animation = 0
|
stepsound:stop()
|
||||||
|
stepsound:play()
|
||||||
end
|
end
|
||||||
|
|
||||||
--push back
|
old_leg_animation = leg_animation
|
||||||
if leg_animation > 0 then
|
|
||||||
--print("animation down")
|
--arm animation
|
||||||
leg_animation = leg_animation - 0.05
|
if player.inertiax ~= 0 then
|
||||||
elseif leg_animation < 0 then
|
if arm_animation_up == true then
|
||||||
--print("animation up")
|
arm_animation = arm_animation + math.abs(player.inertiax)
|
||||||
leg_animation = leg_animation + 0.05
|
|
||||||
|
if arm_animation >= 1 then
|
||||||
|
arm_animation_up = false
|
||||||
|
end
|
||||||
|
elseif arm_animation_up == false then
|
||||||
|
arm_animation = arm_animation - math.abs(player.inertiax)
|
||||||
|
|
||||||
|
if arm_animation <= -1 then
|
||||||
|
arm_animation_up = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else --return animation to normal
|
||||||
|
--return to 0
|
||||||
|
if arm_animation > -0.05 and arm_animation < 0.05 then
|
||||||
|
arm_animation = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
--push back
|
||||||
|
if arm_animation > 0 then
|
||||||
|
--print("animation down")
|
||||||
|
arm_animation = arm_animation - 0.05
|
||||||
|
elseif leg_animation < 0 then
|
||||||
|
--print("animation up")
|
||||||
|
arm_animation = arm_animation + 0.05
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
--mining animation
|
||||||
|
--get to -1.5
|
||||||
|
|
||||||
|
if mine_process ~= 0 then
|
||||||
|
if mining_animation_up == true then
|
||||||
|
mining_animation = mining_animation + 0.4
|
||||||
|
|
||||||
|
if mining_animation >= -0.8 then
|
||||||
|
mining_animation_up = false
|
||||||
|
end
|
||||||
|
elseif mining_animation_up == false then
|
||||||
|
mining_animation = mining_animation - 0.4
|
||||||
|
|
||||||
|
if mining_animation <= -2.2 then
|
||||||
|
mining_animation_up = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else --return animation to normal
|
||||||
|
--print("return to normal "..mining_animation)
|
||||||
|
--return to 0
|
||||||
|
if mining_animation > -0.05 and mining_animation < 0.05 then
|
||||||
|
mining_animation = 0
|
||||||
|
end
|
||||||
|
|
||||||
|
--push back
|
||||||
|
if mining_animation > 0 then
|
||||||
|
--print("animation down")
|
||||||
|
mining_animation = mining_animation - 0.05
|
||||||
|
elseif mining_animation < 0 then
|
||||||
|
--print("animation up")
|
||||||
|
mining_animation = mining_animation + 0.05
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if (leg_animation > -0.1 and leg_animation < 0.1) and not (old_leg_animation > -0.1 and old_leg_animation < 0.1) then
|
|
||||||
stepsound:setPitch(love.math.random(80,100)/100)
|
|
||||||
stepsound:stop()
|
|
||||||
stepsound:play()
|
|
||||||
end
|
|
||||||
|
|
||||||
old_leg_animation = leg_animation
|
|
||||||
|
|
||||||
--arm animation
|
|
||||||
if player.inertiax ~= 0 then
|
|
||||||
if arm_animation_up == true then
|
|
||||||
arm_animation = arm_animation + math.abs(player.inertiax)
|
|
||||||
|
|
||||||
if arm_animation >= 1 then
|
|
||||||
arm_animation_up = false
|
|
||||||
end
|
|
||||||
elseif arm_animation_up == false then
|
|
||||||
arm_animation = arm_animation - math.abs(player.inertiax)
|
|
||||||
|
|
||||||
if arm_animation <= -1 then
|
|
||||||
arm_animation_up = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else --return animation to normal
|
|
||||||
--return to 0
|
|
||||||
if arm_animation > -0.05 and arm_animation < 0.05 then
|
|
||||||
arm_animation = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
--push back
|
|
||||||
if arm_animation > 0 then
|
|
||||||
--print("animation down")
|
|
||||||
arm_animation = arm_animation - 0.05
|
|
||||||
elseif leg_animation < 0 then
|
|
||||||
--print("animation up")
|
|
||||||
arm_animation = arm_animation + 0.05
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--mining animation
|
|
||||||
--get to -1.5
|
|
||||||
|
|
||||||
if mine_process ~= 0 then
|
|
||||||
if mining_animation_up == true then
|
|
||||||
mining_animation = mining_animation + 0.4
|
|
||||||
|
|
||||||
if mining_animation >= -0.8 then
|
|
||||||
mining_animation_up = false
|
|
||||||
end
|
|
||||||
elseif mining_animation_up == false then
|
|
||||||
mining_animation = mining_animation - 0.4
|
|
||||||
|
|
||||||
if mining_animation <= -2.2 then
|
|
||||||
mining_animation_up = true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
else --return animation to normal
|
|
||||||
--print("return to normal "..mining_animation)
|
|
||||||
--return to 0
|
|
||||||
if mining_animation > -0.05 and mining_animation < 0.05 then
|
|
||||||
mining_animation = 0
|
|
||||||
end
|
|
||||||
|
|
||||||
--push back
|
|
||||||
if mining_animation > 0 then
|
|
||||||
--print("animation down")
|
|
||||||
mining_animation = mining_animation - 0.05
|
|
||||||
elseif mining_animation < 0 then
|
|
||||||
--print("animation up")
|
|
||||||
mining_animation = mining_animation + 0.05
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--left leg
|
--left leg
|
||||||
love.graphics.draw(player_leg, player_drawnx, player_drawny+((scale/17.7)*2),leg_animation, scale/17.7, scale/17.7,2,0)
|
love.graphics.draw(player_leg, player_drawnx, player_drawny+((scale/17.7)*2),leg_animation, scale/17.7, scale/17.7,2,0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user