Create objects
I want to draw 10 sprite in the screen with random position so i create this:
createObject = object
Update = function()
local objects = []
for i=1 to 10
local myObject = object
sprite = "myObject"
x = random.nextInt(400) - 200
y = random.nextInt(200) - 100
end
objects.push(myObject)
end
return objects
end
Draw = function()
local objects = createObject.Update()
for o in objects
screen.drawSprite(o.sprite, o.x, o.y, 20)
end
end
end
And in main i write:
init = function()
createObject = 0
end
update = function()
if createObject == 0 then
createObject.Update()
createObject = 1
end
end
draw = function()
createObject.Draw()
end
But the sprite still changing their position... I am doing something wrong or there is another way to do this?