noplay=1 function on.enterKey() tunnel={} math.randomseed(timer.getMilliSecCounter()*math.random()*100) lose=false; width=100; wchange=500; tunpos=100;currpos=platform.window:width()/2;score=0 for x=1,platform.window:height() do tunnel[x]=tunpos end platform.window:invalidate(); end on.enterKey() function genvalue() change=math.random() if change<0.5 and tunpos>0 then tunpos=tunpos-1 elseif tunpos=tunnel[5]+width then lose=true end score=score+1 platform.window:invalidate() end function on.paint(gc) if noplay==1 then on.enterKey() end noplay=2 if lose then string1="You Crashed!" string2="Score: "..tostring(score) string3="Press ENTER to play again!" gc:drawString(string1,(platform.window:width()-gc:getStringWidth(string1))/2,platform.window:height()/2,"middle") gc:drawString(string2,(platform.window:width()-gc:getStringWidth(string2))/2,platform.window:height()-gc:getStringHeight(string2),"bottom") gc:drawString(string3,(platform.window:width()-gc:getStringWidth(string3))/2,platform.window:height(),"bottom") else gc:setColorRGB(255*math.random(),255*math.random(),255*math.random()) for x=platform.window:height(),1,-1 do gc:drawLine(0,platform.window:height()-x,tunnel[x],platform.window:height()-x) gc:drawLine(tunnel[x]+width,platform.window:height()-x,platform.window:width(),platform.window:height()-x) end gc:fillRect(currpos,platform.window:height()-5,2,2) timer.start(0.01) end end function on.timer() timer.stop() for x=1,12 do play() end end function on.arrowKey(key) if key=="left" and currpos>0 then currpos=currpos-2 elseif key=="right" and currpos