Haya i'm a noob to these forums so soz if i get something wrong but
so i just want to know if anyone could show me an example of animated sprite that can jump and walk with the code so i can test around with it and learn how it's done to use in any games i want to make
ty ☺
starting to development a game [solved]
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- bobbymcbobface
- Citizen
- Posts: 78
- Joined: Tue Jun 04, 2019 8:31 pm
starting to development a game [solved]
Last edited by bobbymcbobface on Fri Jun 28, 2019 5:14 pm, edited 1 time in total.
I make games that run on potatoes :P
Re: starting to development a game
I don't have any of my own on hand, but I can point you to two tutorials with examples :
https://love2d.org/wiki/Tutorial:Animation
https://www.gamefromscratch.com/post/20 ... orial.aspx
https://love2d.org/wiki/Tutorial:Animation
https://www.gamefromscratch.com/post/20 ... orial.aspx
-
- Party member
- Posts: 510
- Joined: Wed Oct 05, 2016 11:53 am
Re: starting to development a game
Sheepolution's tutorial covers animated sprites and then some.
- bobbymcbobface
- Citizen
- Posts: 78
- Joined: Tue Jun 04, 2019 8:31 pm
Re: starting to development a game
Thanks guys this is Really helpfull!
I make games that run on potatoes :P
- bobbymcbobface
- Citizen
- Posts: 78
- Joined: Tue Jun 04, 2019 8:31 pm
Re: starting to development a game
Sorry to be be a pain in the A** but the problem i'm having is although i know how to do animations how do i turn that into a moving sprite?
(sorry about the double post btw)
(sorry about the double post btw)
I make games that run on potatoes :P
Re: starting to development a game
No problem. In the tutorials love.graphics.draw is called to render the sprite. https://love2d.org/wiki/love.graphics.draw , As you can see in the documentation, the second and third arguments (after the drawable) are the x and y position at which to draw. So to move the sprite you just change the numbers you provide there. You can store the position of your object and just provide that position to the function.
quick example :
quick example :
Code: Select all
love.load()
anobj = {x=100, y=100, sprite=<your-sprite-here>, speed=10}
end
function love.draw()
love.graphics.draw(anobj.sprite, anobj.x, anobj.y)
end
function love.update(dt)
if love.keyboard.isDown('up') then
anobj.y = anobj.y - (speed * dt)
end
-- ... and so on
end
- bobbymcbobface
- Citizen
- Posts: 78
- Joined: Tue Jun 04, 2019 8:31 pm
Re: starting to development a game
Thank you so much you've all been a massive help!
I make games that run on potatoes :P
Who is online
Users browsing this forum: Google [Bot] and 45 guests