Mmm ... hello!
The tile tutorial should help you understand what tables & basic loops are, and how to draw quads on the screen.
Once you have understood it, probably it will be easier to get how anim8 (or AnAL, or code done by hand) works.
@Nixola: I don't know, I don't keep track of that stuff, but I'm glad you liked it!
Need help with animation/quads, please help!
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Need help with animation/quads, please help!
When I write def I mean function.
Re: Need help with animation/quads, please help!
Nice tutorials!!!
- Puzzlem00n
- Party member
- Posts: 171
- Joined: Fri Apr 06, 2012 8:49 pm
- Contact:
Re: Need help with animation/quads, please help!
Wow, you miss one day on these forums, you miss everything... sorry I couldn't have helped more, but it looks like you have a solution, so that's good.
I LÖVE, therefore I am.
Re: Need help with animation/quads, please help!
Well, I still don't know how to animate, so you didn't miss everything.
Re: Need help with animation/quads, please help!
Kasperelo wrote:Well, I still don't know how to animate, so you didn't miss everything.
Here's some really terrible code of mine that will animate 4 directional player movement and 4 directional idle animations using anim8.
Code: Select all
player = {}
player.pic = love.graphics.newImage("assets/game/player.png")
player.x = 100
player.y = 100
player.speed = 100
function loadPlayer()
lastMove = "down"
playerAnim = newGrid(64, 64, player.pic:getWidth(), player.pic:getHeight())
player.idledownAnim = newAnimation('loop', playerAnim('1-2,10'), 0.4)
player.idleupAnim = newAnimation('loop', playerAnim('1-2,7'), 0.4)
player.idlerightAnim = newAnimation('loop', playerAnim('1-2,4'), 0.4)
player.idleleftAnim = newAnimation('loop', playerAnim('3-4, 4'), 0.4)
player.upAnim = newAnimation('loop', playerAnim('1-4,6'), 0.2)
player.downAnim = newAnimation('loop', playerAnim('1-4,9'), 0.2)
player.rightAnim = newAnimation('loop', playerAnim('1-4,2'), 0.2)
player.leftAnim = newAnimation('loop', playerAnim('1-4,3'), 0.2)
end
function updatePlayer(dt)
function love.keypressed(key)
if key == "a" then
lastMove = "left"
elseif key == "w" then
lastMove = "up"
elseif key == "d" then
lastMove = "right"
elseif key == "s" then
lastMove = "down"
end
end
player.idledownAnim:update(dt)
player.idleleftAnim:update(dt)
player.idleupAnim:update(dt)
player.idlerightAnim:update(dt)
player.upAnim:update(dt)
player.downAnim:update(dt)
player.rightAnim:update(dt)
player.leftAnim:update(dt)
-- Movement
if love.keyboard.isDown("w") then
player.y = math.floor(player.y - (player.speed * dt))
end
if love.keyboard.isDown("s") then
player.y = math.ceil(player.y + (player.speed * dt))
end
if love.keyboard.isDown("a") then
player.x = math.floor(player.x - (player.speed * dt))
end
if love.keyboard.isDown("d") then
player.x = math.ceil(player.x + (player.speed * dt))
end
end
function drawPlayer()
playerIdle = love.keyboard.isDown("w", "a", "s", "d")
if love.keyboard.isDown("w") then
player.upAnim:draw(player.pic, player.x, player.y)
elseif love.keyboard.isDown("s") then
player.downAnim:draw(player.pic, player.x, player.y)
elseif love.keyboard.isDown("a") then
player.leftAnim:draw(player.pic, player.x, player.y)
elseif love.keyboard.isDown("d") then
player.rightAnim:draw(player.pic, player.x, player.y)
elseif playerIdle == false then
if lastMove == "down" then
player.idledownAnim:draw(player.pic, player.x, player.y)
elseif lastMove == "right" then
player.idlerightAnim:draw(player.pic, player.x, player.y)
elseif lastMove == "up" then
player.idleupAnim:draw(player.pic, player.x, player.y)
elseif lastMove == "left" then
player.idleleftAnim:draw(player.pic, player.x, player.y)
end
end
end
Re: Need help with animation/quads, please help!
Thanks! I'm gonna check if it works!
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Need help with animation/quads, please help!
You said you already had the frames drawn. If you have them together in a image, and distributed into equal rectangles, I can tell you how to animate them via anim8, if you want.
When I write def I mean function.
Re: Need help with animation/quads, please help!
Yes, please! Thank you, kikito!
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Need help with animation/quads, please help!
Ok. Where is the image, then?
When I write def I mean function.
Re: Need help with animation/quads, please help!
Here's the whole game. It's not impressive.
- Attachments
-
- helpme.love
- (18.35 KiB) Downloaded 103 times
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest