Okay, so i'm trying to make some pretty basic code to spawn some planets (also known as circles), I don't know what I'm doing that makes the drawing function not work. here is the code:
math.randomseed(os.time())
planet = {}
numPlanetsMax = math.random(3, 5)
numPlanets = 0
function planet_generate(dt)
for i=1, numPlanetsMax do
if numPlanets < numPlanetsMax then
planet_load(12, 32, 54)
numPlanets = numPlanets + 1
end
end
end
function planet_load(x, y, size)
table.insert(planet, {x = x, y = y, size = size})
end
function planet_draw()
for i,v in ipairs(planet) do
love.graphics.setColor(255,255,255)
love.graphics.circle("fill", planet.x, planet.y, planet.size, planet.size)
end
end
It MAY be because you're making the 4th argument of love.graphics.circle as the same value as the 3rd.
In LÖVE, circles don't have different widths and heights: it's all a single variable (the 3rd argument). The 4th argument is for number of sizes of the circle (since it's not a circle properly, but a polygon with a bunch of sides - I often set it to 32).
So you'd maybe do this:
love.graphics.circle("fill", planet.x, planet.y, planet.size, 32)
Thanks for the reply, tried your solution and it didn't work. I believe the problem is with argument 2 of the circle drawing. However thank you for that information, I hadn\t properly researched love.graphics.circle before hand, and i kinda understood it, thanks for the clarification
One cannot simply code love.. Oh wait with LÖVE you can..
I downloaded it, took a look at your code again and realized:
You're doing a for loop through each item in the planet table: for i, v in pairs(planet) do
But you're drawing it as planet.something, even though the planet table contains all the planets. So, in the drawing function, replace all "planet" by "v" and it should work
Thanks for all the replies, however I ran into another problem that ive been trying to solve all night. The problem here is that im trying to spawn forests, really for no reason other than for future uses, im trying to spawn them individually onto planets, however i will work on that later, as of now however im trying to just focus on variety in the forests, different colors etc. Run the .love and you will find out the new problem. Please feel free to clean up my code and judge it as much as you want, im still pretty new to this.