Gotchas

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
Santos
Party member
Posts: 384
Joined: Sat Oct 22, 2011 7:37 am

Gotchas

Post by Santos »

There seems to be some common problems people run into when using LOVE, and I was thinking maybe it would be cool to kind of collect them all in one place so people could read through them early in their LOVE-learning journey. I dunno. What do you think?

Here are some things I thought of:


Images are drawn an unexpected color?

With the default blend mode, images are affected by the current color, so putting love.graphics.setColor(255, 255, 255) before drawing the image should draw it with its original colors.

Canvases with transparency don't look right?

Screenshots don't look right/are transparent in places?

1 pixel lines/"line" mode rectangles/points look blurry?

Images look blurry?

Are they drawn at whole number coordinates, including the offset? math.floor can be used to remove the fractional part of a number.

The outside edges of Quads bleed into it?

Try creating a 1 pixel border around the Quad area with the same colour of the pixels inwardly adjacent to it.

Sources don't play again?

To play a Source which is already playing again: stop it, then play it again.

Code: Select all

love.audio.stop(source)
love.audio.play(source)
or

Code: Select all

source:stop()
source:play()
Also, Ogg Vorbis files are recommended over WAV files. You can convert to Ogg using Audacity.

.love file doesn't work?
  • Is main.lua in the "top level" of the zip file, rather than in a folder in the zip file?
  • Is the file a renamed .zip file, rather than a .rar file?
  • Are the file paths in the correct case? For example, is "example.png" not refered to as something like "Example.PNG"?
Changing the love.physics world in the love.physics callbacks is not recommended.

Some graphics cards can't handle large images/canvases. [citation needed]

Removing a table entry from a numerically indexed table while looping through it?
User avatar
pakoskyfrog
Citizen
Posts: 62
Joined: Mon Feb 04, 2013 12:54 pm
Location: France

Re: Gotchas

Post by pakoskyfrog »

Nicely done !
And i learned useful tips ^^

Thanks
User avatar
slime
Solid Snayke
Posts: 3170
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Gotchas

Post by slime »

Good idea! Maybe a Wiki page could eventually be created for this.
Santos wrote:Some graphics cards can't handle large images/canvases. [citation needed]
Here's a collection of the maximum image/canvas size on various systems. http://feedback.wildfiregames.com/repor ... XTURE_SIZE
A value of 2048 means the maximum dimensions are 2048x2048.
Last edited by slime on Mon Feb 25, 2013 2:38 pm, edited 1 time in total.
spectralcanine
Citizen
Posts: 65
Joined: Sat Dec 22, 2012 8:17 am

Re: Gotchas

Post by spectralcanine »

It's not as much as "not recommended" as it is "never, ever, do it".
Changing Box2D's state in collision callbacks results in undefined behavior, or in other words, crashes.
Santos wrote:Some graphics cards can't handle large images/canvases. [citation needed]
You mean something like this?

Edit: them ninjas :huh:
User avatar
markgo
Party member
Posts: 190
Joined: Sat Jan 05, 2013 12:21 am
Location: USA

Re: Gotchas

Post by markgo »

love.physics.setMeter

Box2d works in meters and not pixels! setMeter does not apply retroactively to created objects! When you create something, the coordinates are converted to meters based on the scale factor. If you have a box that is 10 meters x 10 meters and you change the scale to a smaller value, the box would appear smaller, but it is still 10 meters x 10 meters in box2d world. Just something I noticed.
spectralcanine
Citizen
Posts: 65
Joined: Sat Dec 22, 2012 8:17 am

Re: Gotchas

Post by spectralcanine »

markgo wrote:love.physics.setMeter

Box2d works in meters and not pixels! setMeter does not apply retroactively to created objects! When you create something, the coordinates are converted to meters based on the scale factor. If you have a box that is 10 meters x 10 meters and you change the scale to a smaller value, the box would appear smaller, but it is still 10 meters x 10 meters in box2d world. Just something I noticed.
Yet another (and indeed there are others) reason to never use pixels as the size of objects.

It is much easier to define your own space, and later on do one love.graphics.scale call when rendering.

Try putting 1x1 as your base tile size in a tiled game, and you'll see how easy code suddenly becomes.
User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Gotchas

Post by Inny »

Can you copy this information to the Wiki? Or, if there's an existing page, update the information?
User avatar
Jasoco
Inner party member
Posts: 3727
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Gotchas

Post by Jasoco »

There should be a sticky announcement FAQ for this information. Especially the max image size, blurry images, leaky quads, and stupid pink pig won't show me any games complaints we get most of the time.
Post Reply

Who is online

Users browsing this forum: Amazon [Bot], varpeti and 5 guests