I think I know how to do this and I’ve done it in a project before but I forget which is which, mi making it so every time you get +1 score something falls in the background (sprite), but make it random, because if it were to spawn every point then it would lag a lot, how would I make it so it spawns sort of like in the online game cookie clicker, which doesn’t spawn one every click but has it maintained
Here you go!
-- spawn entitie
function setup()
--The table for the entities
ent = {}
end
function draw()
background(40, 40, 50)
--Draw all the sprites or "entities" in the table
for i=1, #ent do
sprite("Tyrian Remastered:Blades", ent[i].x, ent[i].y)
end
end
function touched(call)
--Insert the entitie(s) to the table.
table.insert(ent, vec2(math.random(WIDTH), math.random(HEIGHT)))
end
If you need anymore help, let me know :).
thats perfect but could you make them start at the top then fall down slowly so they disappear
Yes, I will post the code when I finish walking my dog.
(I think you might be a bit rusty in your programming skills, if so here is an excellent tutorial made by Ignazts: http://coolcodea.wordpress.com/2013/03/10/starting-with-codea/ )
Here is the code:
-- spawn entity
function setup()
--The table for the entities
ent = {}
end
function draw()
background(40, 40, 50)
for i=1, #ent do
--Make the entities go down the screen, change the "0.3" to whatever you like if its --to fast/slow.
if ent[i] ~= nil then
ent[i].y = ent[i].y - 0.3
--Draw all the sprites or "entities" in the table
sprite("Tyrian Remastered:Blades", ent[i].x, ent[i].y)
--If a entity is under the screen, then remove it from the table.
if ent[i].y < 0 then
table.remove(ent, i)
end
end
end
end
function touched(t)
--Insert the entities(s) to the table.
table.insert(ent, vec2(math.random(WIDTH), math.random(HEIGHT)))
end
Thanks so much,would it be possible to move the falling sprites to the back?
And I notice there are no if statements? Could I make a variable called ‘score’ and every time it goes up the sprites fall?
There is a if statement, its right below the “sprite” function.
Yes you could make a variable called score, your imagination is the limit!