1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
| x=0 T,F=0,0 b="" u=0 t=0 aa=math.random(1,10) bb=math.random(1,10) ab=aa+bb ts=0.06 life=10 level="learner" function on.charIn(char) mm=timer.getMilliSecCounter() ch=char if x>130 then u=1 t=t+1 end end
function loop() if x>220 then x=0 t=0 u=0 aa=math.random(1,10) bb=math.random(1,10) ab=aa+bb draw1,draw2=0,0 return loop() end end
draw=class() function draw:paint(gc) gc:setPen("thick","dotted") gc:drawRect(60,150,200,50)
if draw1==1 then gc:setColorRGB(180,180,180) gc:fillRect(60,150,200,50) if mm+90<timer.getMilliSecCounter() then draw1=0 end end if draw2==1 then gc:setColorRGB(20,20,20) gc:fillRect(60,150,200,50) if mm+90<timer.getMilliSecCounter() then draw2=0 end end end
function judge() if x>130 and x<200 and ab>10 and u==1 then if ch=="6" then b="true" elseif ch~="6" and ch~="a" and ch~="b" and ch~="c" and ch~="d" and ch~="p" then b="false" end end if x>130 and x<200 and ab<10 and u==1 then if ch=="4" then b="true" elseif ch~="4" and ch~="a" and ch~="b" and ch~="c" and ch~="d" and ch~="p" then b="false" end end if x>130 and x<200 and ab==10 and u==1 then if ch=="5" then b="true" elseif ch~="5" and ch~="a" and ch~="b" and ch~="c" and ch~="d" and ch~="p" then b="false" end end --if u==0 and t==0 then b="false" t=1 end if b=="true" and t==1 then T=T+1 b="" u=0 draw1=1 end if b=="false" and t==1 then F=F+1 b="" u=0 draw2=1 end end function on.paint(gc) draw:paint(gc) gc:setColorRGB(0,0,0) gc:setFont("sansserif","bi",30) gc:drawString(aa.." + "..bb,110,x,"top") --gc:setColorRGB(100,100,100) --gc:drawString(aa.." + "..bb,110,x-30,"top") gc:setFont("sansserif","bi",10) gc:drawString("T: "..T.." ".."F: "..F,0,15,"top") gc:drawString("u: "..u,0,30,"top") gc:drawString("t: "..t,0,45,"top") gc:drawString("ab: "..ab,0,60,"top") gc:drawString("x: "..x,0,75,"top") gc:drawString("life: "..life,0,90,"top") gc:drawString("level: "..level,0,105,"top") if F>life then highscore() gc:fillRect(0,0,330,250) gc:setColorRGB(255,255,255) gc:setFont("sansserif","bi",30) gc:drawString("You Lost",95,50,"top") gc:setFont("sansserif","bi",15) gc:drawString("your score: "..T,120,110,"top") gc:drawString("highscore: "..var.recall("highscore"),120,130,"top") gc:drawString("Press R to restart",170,180,"top") if ch=="r" then x=300 T=0 F=0 return loop() end end timer.start(ts) if ch=="p" then timer.stop() end if ch=="a" then ts=0.05 life=8 level="easy" end if ch=="b" then ts=0.04 life=6 level="medium"end if ch=="c" then ts=0.03 life=5 level="hard" end if ch=="d" then ts=0.02 life=3 level="extreme" end end function on.enterKey() ch="xx" timer.start(ts) platform.window:invalidate() end function highscore() if var.recall("highscore")==nil or T>var.recall("highscore") then var.store("highscore",T) end var.monitor("highscore") end
--[[function on.varChange(varlist) local highscore=var.recall("highscore") if not highscore then return -3 end if type(highscore)~="number" then return -2 end if highscore<0 then return -1 end end]]
function on.timer() local ss=0.45*T+3 if ss>15 then ss=15 end x=x+(ss) loop() judge() platform.window:invalidate() end |