I’m trying to make waves of enemies and am stuck on drawing a certain amount/certain enemies. I want to loop 10 of certain enemies in a single wave and then wait a certain amount of time before the next wave(s) are drawn.
-- Final Creatures
-- Use this function to perform your initial setup
function setup()
health={5,2,8,10}
wave={"meteor1","meteor2","meteor3","meteor4","meteor5","meteor6","meteor7","meteo8r","meteor9","meteor10"}
rTable={}
timeout=ElapsedTime+1
end
-- This function gets called once every frame
function draw()
background(141, 47, 47, 255)
--floor
strokeWidth(15)
line(0,250,WIDTH,250)
strokeWidth(7)
rect(-5,-5,WIDTH+10,250)
time()
--beast
strokeWidth(0)
for meteor1,meteor10 in pairs(wave) do
for nbr,rock in pairs(rTable) do
ellipse(rock.x,rock.y,30)
rock.x=rock.x+.1
if rock.x>=WIDTH/2-30 then
rock.x=WIDTH/2-30
end
end
end
end
function time()
if (ElapsedTime>timeout) then
table.insert(rTable,vec2(0,300))
timeout=ElapsedTime+1
end
end