"walk cycle"

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
lolsasory
Prole
Posts: 21
Joined: Mon Nov 19, 2012 5:27 am

"walk cycle"

Post 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.
User avatar
Puzzlem00n
Party member
Posts: 171
Joined: Fri Apr 06, 2012 8:49 pm
Contact:

Re: "walk cycle"

Post 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. :)
I LÖVE, therefore I am.
lolsasory
Prole
Posts: 21
Joined: Mon Nov 19, 2012 5:27 am

Re: "walk cycle"

Post by lolsasory »

thanks man your a life saver
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: "walk cycle"

Post 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
Help us help you: attach a .love.
User avatar
Puzzlem00n
Party member
Posts: 171
Joined: Fri Apr 06, 2012 8:49 pm
Contact:

Re: "walk cycle"

Post by Puzzlem00n »

Holy cow, Robin, I've never even thought to do that! Agh, so obvious... Thanks!
I LÖVE, therefore I am.
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests