--Baddie Class
--All functions will be written as r + whatever the function is. R stands for RED
function rLoad()
--rImgN = love.graphics.newImage("textures/rNeutral.png")
rImgH = love.graphics.newImage("textures/rHostile.png")
rspAm = math.random(17,25)
rspX = math.random(0,love.window.getWidth()-32)
rspY = math.random(0,love.window.getHeight()-32)
counter = 0
end
function rSpawn()
spawning = true
while spawning == true do
counter = counter + 1
if counter > rspAm then
break
end
love.graphics.draw(rImgH,r.spX,r.spY)
rspX = math.random(0,love.window.getWidth()-32)
rspY = math.random(0,love.window.getHeight()-32)
end
end
Im trying to get it to repetitively spawn the blocks in random spots. Why isnt it working? Help is much appreciated.
One thing I can see right now is that rSpawn doesn't work. It tries to draw something, but I assume rSpawn is not called inside love.draw, so it won't even be shown. If it were shown, depending on if you reset counter, these baddies will teleport all over the screen, creating a flickering mess.
You'll want to keep a table to store the baddie coordinates, fill it up in rSpawn and loop over the table to draw it in love.draw.
When Robin and substitute541 asked for a .love, they wanted one that produces the error, so they can help you. The love you just uploaded does not error, so i guess you solved your problem already?
If not you should also post the steps necessary to reproduce the error.