Code: Select all
--set apple
if apple.spawned == false then
--is apple.x on player?
local x = 0
while x == 0 do
apple.x = love.math.random(0, (wWidth - apple.size))
if (apple.x + apple.size) < player.x or apple.x > (player.x + player.size) then
x = 1
end
end
--is apple.y on player?
local y = 0
while y == 0 do
apple.y = love.math.random(0, (wHeight - apple.size))
if (apple.y + apple.size) < player.y or apple.y > (player.y + player.size) then
y = 1
end
end
--apple has spawned
apple.spawned = true
end
This is my first time posting on theses forums so my apologies if I haven't added something necessary for you to assist me, simply tell me and I will do my best to fill you in on the missing details.
Thanks in advance.