Page 1 of 1

"walk cycle"

Posted: Sun Dec 02, 2012 12:27 am
by lolsasory
I want to have a "walk cycle" for a game I'm making, I have a ship... well here is the code

Code: Select all

ship01 = love.graphics.newImage("images/ship01.png")
ship02 = love.graphics.newImage("images/ship02.png")
function player_draw()
		if love.keyboard.isDown("w") or
			love.keyboard.isDown("up") then
			player.image = ship02 
		else
			player.image = ship01
		end
So when you go forward fire comes out of back. I wanted to have the fire move more which I have done in ship03, 04, and 05 so how can I have when you're going forward it cycles from 02 -05 and back again. I've tried Google and here with no help.



tl;dr I need a walk cycle, I cant find any tutorials.

Re: "walk cycle"

Posted: Sun Dec 02, 2012 12:54 am
by Puzzlem00n
The reason you aren't finding a tutorial is that generally, people don't code this kind of thing from scratch. A few libraries out there can do the job. Personally, I prefer anim8: https://github.com/kikito/anim8

Also, this:

Code: Select all

if love.keyboard.isDown("w") or
love.keyboard.isDown("up") then
Is sort of ugly... generally you'd want to be doing this:

Code: Select all

if love.keyboard.isDown("w") or love.keyboard.isDown("up") then
all in one line. :)

Re: "walk cycle"

Posted: Sun Dec 02, 2012 1:47 am
by lolsasory
thanks man your a life saver

Re: "walk cycle"

Posted: Sun Dec 02, 2012 11:26 am
by Robin
Puzzlem00n wrote:generally you'd want to be doing this:

Code: Select all

if love.keyboard.isDown("w") or love.keyboard.isDown("up") then
all in one line. :)
Or even better:

Code: Select all

if love.keyboard.isDown("w", "up") then

Re: "walk cycle"

Posted: Sun Dec 02, 2012 8:25 pm
by Puzzlem00n
Holy cow, Robin, I've never even thought to do that! Agh, so obvious... Thanks!