main.lua
Code: Select all
love.load()
--under everything else
require("worldstate")
end
Code: Select all
myWorld:setEnter(function(s1,s2,c,i)
if s2:getClass() == "ObjectA" and
(p.player.vx > 0 or p.player.vy > 0)
then
p.player.state = "pushing"
end
end)
myWorld:setExit(function(s1,s2,c,i)
if s2:getClass() == "ObjectA" and
(p.player.vx > 0 or p.player.vy > 0)
then
p.player.state = "walking"
elseif p.player.vx == 0 and p.player.vy == 0 then
p.player.state = "standing"
end
end)
Code: Select all
p.draw = function(self)
local pose = sprites.stand_cycle
if self.player.state == "pushing" then
pose = sprites.player_pushing
elseif self.player.state == "walking" then
pose = sprites.player_walking
elseif self.player.state == "standing" then
pose = sprites.player_standing
end
--the rest of the code draws the pose
end