YO:
I'm having a problem with my code in math.random where it keeps giving me the same integer value every single time, i know it has to be seeded but i don't know how in these circumstances
If you post your .love we you can help us help you.
First the error, Are you sure the enemyX, enemyY etc. variables aren't inside the enemy table? If not you don't really need that table.
As far as the math.random problem,Since 0.8.0 the randomseed is randomized right before love.load() is called, So i'm not sure what the problem is. If you post your code, I can look through it and test it myself to try and figure out what's wrong.
Okay: here's the deal: you have a function called enemy_spawn(), but you should really call it enemy_draw, because that's what it does: it draws an enemy. Your code as-is creates a single enemy at the start of the game, and that's it. Here's a suggestion that you can start from:
enemies = {}
function spawn_enemy()
local e = {}
e.x = math.random(0, 300)
e.y = math.random(0, 500)
e.width = math.random(32, 50)
e.height = math.random(32, 50)
table.insert(enemies, e)
end
function draw_enemies()
love.graphics.setColor(255,0,0)
for i, enemy in ipairs(enemies) do
love.graphics.rectangle("fill", enemy.x, enemy.y, enemy.width, enemy.height)
end
end
Can you take it from here or do you want more explanation?
Fix the typo. You can criticise his coding methods later.
As to the seeding part, LOVE should do that automatically in love.run. Since 0.9.0 is also out, you can use this for a little bit more consistency.
"I view Python for game usage about the same as going fishing with a stick of dynamite. It will do the job but it's big, noisy, you'll probably get soaking wet and you've still got to get the damn fish out of the water." -taylor
Thanks for the responses, also thank you for finding the typo, i guess i should have looked it over more first... I've also found that I have an older LOVE version, because when installing the newest version and trying to run my games, LOVE just stops responding, i think that's why it didn't automatically seed it. So far though it seems that if i just put
Wait, stops responding as in it actually crashes, or do you just get some kind of blue error screen?
If it's the latter, you can just update a bunch of functions to fix that up. (I'd assume some love.graphics functions got renamed to love.window functions in that, but eh) If it's the former, uh
"I view Python for game usage about the same as going fishing with a stick of dynamite. It will do the job but it's big, noisy, you'll probably get soaking wet and you've still got to get the damn fish out of the water." -taylor