How do I use a Sprite Map in Love?

General discussion about LÖVE, Lua, game development, puns, and unicorns.
enderspike
Prole
Posts: 10
Joined: Tue Oct 11, 2011 6:37 pm

How do I use a Sprite Map in Love?

Post 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.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How do I use a Sprite Map in Love?

Post by Robin »

You probably want Quads, not SpriteBatches. Quads are like viewports on an image, so useful for animations and sprite maps.
Help us help you: attach a .love.
enderspike
Prole
Posts: 10
Joined: Tue Oct 11, 2011 6:37 pm

Re: How do I use a Sprite Map in Love?

Post by enderspike »

Excellent! Any pointers on using those?
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: How do I use a Sprite Map in Love?

Post by Robin »

I'll leave that one to someone else with more experience in this area.
Help us help you: attach a .love.
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: How do I use a Sprite Map in Love?

Post 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.
enderspike
Prole
Posts: 10
Joined: Tue Oct 11, 2011 6:37 pm

Re: How do I use a Sprite Map in Love?

Post 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?
enderspike
Prole
Posts: 10
Joined: Tue Oct 11, 2011 6:37 pm

Re: How do I use a Sprite Map in Love?

Post by enderspike »

Sub-question: do I have to cut out every single image I want to use as a quad?
User avatar
kraftman
Party member
Posts: 277
Joined: Sat May 14, 2011 10:18 am

Re: How do I use a Sprite Map in Love?

Post 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.
enderspike
Prole
Posts: 10
Joined: Tue Oct 11, 2011 6:37 pm

Re: How do I use a Sprite Map in Love?

Post 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
User avatar
Taehl
Dreaming in associative arrays
Posts: 1025
Joined: Mon Jan 11, 2010 5:07 am
Location: CA, USA
Contact:

Re: How do I use a Sprite Map in Love?

Post 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...
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 6 guests