Ah, it's very simple. When you draw the player, you use:
screen.drawSprite("player", player.x, player.y 15,15)
You must do the same for the stone; it's just a stone, so every time the player approaches, the stone will change its coordinates, as indicated in this function:
randomizeStonePos = function()
// "randRange" needed to be defined
soulstones.x = randRange(-150, 150)
soulstones.y = randRange(-80, 80)
end
Then, after drawing the player, you must draw the stone using its coordinates (Although the order doesn't matter, it can be before or after) :
//draw the player
screen.drawSprite("player", player.x, player.y 15,15)
//draw the soulstone
screen.drawSprite("soulstones",soulstones.x,soulstones.y,15,15)
and sorry, I made a mistake somewhere. I entered the distance function incorrectly; it should be like this:
distance = function(x1,y1,x2,y2)
local dx = x1-x2
local dy = y1-y2
return sqrt(dx*dx+dy*dy)
end
Even so, I've already corrected the errors, I think it should be working correctly now, and another problem I saw at the beginning was that you had to enter InitCoin with the parentheses, but I've already fixed that:
init = function()
//object virables
player = object end
enemy = object end
soulstones = object end
initCoin() // <- The parentheses were missing
// ...