if you remove luck the game will boring like hell. by your comment, I can conclude that your random variables have a bigger range than they should.
Do you have levels? for example: randomObj=math.rand(lvl*1, lvl*10) it will show more objects harder the level. if its time-based game…the longer the game the more objects you can create with the same approach. if it’s both you can join both formulas.
if you want to remove lucky, maybe a multi-dimension table with the quantities/time is a way to go. that way when you hit X seconds you will get Y objects…you can have a random number with a lower ranger to the return value so you can have a controlled random number.
local showObjects={{5, 3, 7, 10}, {10, 7, 13, 5}, {4, 2, 6, 3}} -- {objects, random range\_min, random\_range\_max, time passed} local rand=math.random local round=math.round local myListener = function( event ) local timer=round(event.time\*0.001) for i=#showObjects, 1, -1 do if showObjects[i][4]==timer then print ("timed passed: "..timer..", creating "..showObjects[i][1].." objects - fixed approach") print ("timed passed: "..timer..", creating "..rand(showObjects[i][2], showObjects[i][3]).." controled random objects approach") showObjects[#showObjects]=nil break end end end Runtime:addEventListener( "enterFrame", myListener )
this will provide fixed and controlled random objects at specific time, but you can also add some controlled random time with little changes.
I doubt this is a good approach because the larger the array the slower the game will be, it surelly needs some more thought how to make it in a real game scenario. But i hope you get the idea. Please note, I never made a runner game, just made this in my lunchtime 