
How come do you create a dount spawner?, i used some code about random tiling but im not sure how to make it like clear the tiles and change it every 10 seocnds or so, here's my code, thanks in advance:
--dount generation--
function place_dounts()
for x=0,15 do
for y=0,15 do
--random tiles picking)
local sp = rnd(6)
if rnd(1)<.1 then
mset(x,y,sp)
end
end--yaxis
end--xais
end--function



Imagine shuffling a set of 256 cards, including one joker among the ace of spades, then drawing cards one by one and rearranging them in a 16*16 order.
nexttime=0 function _update() if time()>nexttime then place_dounts() nexttime=time()+10 end end function _draw() map() ?nexttime-time() end --dount generation-- function place_dounts() local empty=1 --spr-id:1 local dount=2 --spr-id:2 local places={} for x=0,15 do for y=0,15 do add(places,empty) --stack [place]-pieces end end places[1]=dount --replace a dount in first index for x=0,15 do for y=0,15 do local sp=rnd(places) --shuffle and pick mset(x,y,del(places,sp)) end--yaxis end--xais end--function |



You have the code to randomly add donuts, so just create a function that goes through the map grid the same way to remove the donuts (instead of mset(x,y,sp)
, it'll be mset(x,y,0)
, then run the place_donuts function again to spawn new ones.
To make it happen every N seconds, you can create a timer variable in an _init()
function, then have it count up/down in the _update()
function. Then when it reaches some number, it calls the above functions and resets.
[Please log in to post a comment]