Help out a beginner (spawning objects)

General discussion about LÖVE, Lua, game development, puns, and unicorns.
User avatar
DaedalusYoung
Party member
Posts: 413
Joined: Sun Jul 14, 2013 8:04 pm

Re: Help out a beginner (spawning objects)

Post by DaedalusYoung »

Also, enemyImage is not declared.
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: Help out a beginner (spawning objects)

Post by Jasoco »

Davidobot wrote:
ThatTreeOverThere wrote:In Love 0.9.0, you can use love.math.random to generate a random number.
In other versions, you'll have to use something like this: http://stackoverflow.com/questions/1868 ... -generator
You can just use math.random?
I think love.math.random allows you to have more than one set of random seeds for different purposes. Much like how Minecraft uses one seed for world generation, but a different one for placement of enemies and other randomness. They have to be kept separate for obvious reasons. The world seed must remain constant, but if the rest of the random stuff used the same seed then all the stuff happening inside the world would always be the same, which wouldn't be what you want.

At least that's what I think love.math.random is for.
User avatar
slime
Solid Snayke
Posts: 3162
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Help out a beginner (spawning objects)

Post by slime »

Jasoco wrote:I think love.math.random allows you to have more than one set of random seeds for different purposes. Much like how Minecraft uses one seed for world generation, but a different one for placement of enemies and other randomness. They have to be kept separate for obvious reasons. The world seed must remain constant, but if the rest of the random stuff used the same seed then all the stuff happening inside the world would always be the same, which wouldn't be what you want.

At least that's what I think love.math.random is for.
The love.math.random function exists partly because math.random's implementation is different on different operating systems. love.math.random will give the same results regardless of OS, given the same inputs (if the random seed/state is the same), but math.random will not.

love.math also has RandomGenerator objects for having multiple concurrent random states.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests