Page 1 of 2
How do I use a Sprite Map in Love?
Posted: Tue Oct 11, 2011 6:47 pm
by enderspike
Hello,
I am new to both Love and programming in general, and I am trying to learn the basics of game programming. Today's project is sprites. How does one make a sprite do what it is supposed to in Love? I know there is a thing called a "spritemap" (I have one for good ol' Crono) and I know there is a Love object called a SpriteBatch. I am also vaguely aware that there are external programs that somehow manipulate Sprite Maps. How can I combine these things is such a way that I can make Crono walk in place, etc? My plan is just to make a program with dude at the center of the screen, doing what I tell him in place. Any and all help is appreciated.
Re: How do I use a Sprite Map in Love?
Posted: Tue Oct 11, 2011 7:00 pm
by Robin
You probably want
Quads, not SpriteBatches. Quads are like viewports on an image, so useful for animations and sprite maps.
Re: How do I use a Sprite Map in Love?
Posted: Tue Oct 11, 2011 7:25 pm
by enderspike
Excellent! Any pointers on using those?
Re: How do I use a Sprite Map in Love?
Posted: Tue Oct 11, 2011 7:29 pm
by Robin
I'll leave that one to someone else with more experience in this area.
Re: How do I use a Sprite Map in Love?
Posted: Tue Oct 11, 2011 7:49 pm
by kraftman
enderspike wrote:Excellent! Any pointers on using those?
The wiki explains it fairly well, just make sure you are using
love.graphics.newQuad and not
love.graphics.quad. Then use
love.graphics.drawq to draw the quad.
Re: How do I use a Sprite Map in Love?
Posted: Tue Oct 11, 2011 8:35 pm
by enderspike
Bad ass. Progress is being made! Now, how do I know which co-ordinate is what in the image? Like, how do I figure out what numbers to put in to get the part of the map I want?
Re: How do I use a Sprite Map in Love?
Posted: Tue Oct 11, 2011 8:43 pm
by enderspike
Sub-question: do I have to cut out every single image I want to use as a quad?
Re: How do I use a Sprite Map in Love?
Posted: Tue Oct 11, 2011 8:45 pm
by kraftman
enderspike wrote:Bad ass. Progress is being made! Now, how do I know which co-ordinate is what in the image? Like, how do I figure out what numbers to put in to get the part of the map I want?
What I did was to modify the function so that coordinates are relative, so that 0 is left, 1.0 is right, etc, regardless of the image size. The only problem with this is you'd need to know which image the quad is being applied to.
Re: How do I use a Sprite Map in Love?
Posted: Tue Oct 11, 2011 8:50 pm
by enderspike
How do I do that?
This is the image: (couldn't upload it):
http://www.google.com/imgres?um=1&hl=en ... 29,r:1,s:0
Re: How do I use a Sprite Map in Love?
Posted: Tue Oct 11, 2011 9:44 pm
by Taehl
Well... To be honest, that sprite sheet would be a pain in the butt to work with, since the sprites aren't evenly sized or spaced...