port of of shoot.py for casio
from kandinsky import draw_string as D,fill_rect as F from math import* from ion import keydown as K from time import* def Kd(): while K(4)|K(52):0 while (K(4)|K(52))^1:0 while K(4)|K(52):0 def C():F(0,0,320,222,"w") class Game_over(Exception):0 C();D("SHOOT THE TARGET",82,10) D("PRESS [OK] TO START",70,100) Kd();C() targets=1;tick=0 try:diff=int(input("Difficulty ? (1 to 10, default 5)\n")) except:diff=5 if diff>10:diff=10 if diff<1:diff=1 try:lvl=int(input("Level ? (1 to 40, default 1)\n")) except:lvl=1 if lvl>40:lvl=40 if lvl<1:lvl=1 def displvl(lv):C();D("LEVEL "+str(lv),150,100) def loadlv(): global xsqu,ysqu,xcross,ycross,totalmiss,motion1,motion2;totalmiss=0;xsqu=50;ysqu=50;xcross=102;ycross=75 if lvl==1:motion1=1;motion2=0 if lvl==2:motion1=2;motion2=1 if lvl==3:motion1=1;motion2=2 if lvl==4:motion1=1;motion2=3 if lvl==5:ysqu=10;motion1=3;motion2=3 if lvl==6:motion1=4;motion2=4 if lvl==7:motion1=4;motion2=4 if lvl==8:motion1=5;motion2=5 if lvl==9:motion1=1;motion2=5 if lvl==10:motion1=3;motion2=5 if lvl==11:motion1=4;motion2=6 if lvl==12:motion1=3;motion2=6 if lvl==13:motion1=5;motion2=6 if lvl==14:motion1=4;motion2=5 if lvl==15:motion1=6;motion2=5 if lvl==16:motion1=5;motion2=1 if lvl==17:ycross-=1;motion1=4;motion2=0 if lvl==18:xcross-=50;motion1=7;motion2=0 if lvl==19:motion1=8;motion2=4 if lvl==21:motion1=8;motion2=6 if lvl==20:motion1=9;motion2=5 if lvl==22:motion1=8;motion2=6 if lvl==23:motion1=6;motion2=7 if lvl==24:motion1=8;motion2=7 if lvl==25:motion1=4;motion2=7 if lvl==26:ysqu-=25;motion1=8;motion2=2 if lvl==27:xsqu+=35;motion1=5;motion2=8 if lvl==28:motion1=6;motion2=8 if lvl==29:motion1=4;motion2=8 if lvl==31:motion1=8;motion2=8 if lvl==30:motion1=7;motion2=8 if lvl==32:xsqu-=5;motion1=5;motion2=4 if lvl==33:xsqu+=92;motion1=5;motion2=6 if lvl==34:motion1=9;motion2=5 if lvl==35:ysqu+=10;motion1=8;motion2=6 if lvl==36:ysqu+=22;motion1=6;motion2=2 if lvl==37:xsqu+=69;motion1=5;motion2=3 if lvl==38:motion1=0;motion2=7;xsqu=12 if lvl==39:xsqu=25;motion1=5;motion2=8 if lvl==40:xsqu=150;motion1=2;motion2=8 if lvl==41:print("you won !") displvl(lvl);Kd() loadlv() def loop(): global tick,xsqu,ysqu,xcross,ycross while 1: t=monotonic() if motion1==1:xsqu=round(sin(tick)*50)+75 if motion1==2:ysqu=round(sin(tick)*50)+75 if motion1==3:xsqu=round(cos(tick)*125)+75 if motion1==4:xsqu=round(cos(tick)*125)+75;ysqu=round(sin(tick)*50)+75 if motion1==5:ysqu=round(cos(tick)*50)+75 if motion1==6:xsqu=round(cos(tick)*250)+75 if motion1==7:xsqu=round(tan(tick)*5)+75 if motion1==8:xsqu=round(tan(tick)*5)+90 if motion1==9:xsqu=round(tan(tick)*5)+60 if motion1==10:ysqu=round(cos(tick)*50)+75 if motion2==1:xcross=round(sin(tick)*50)+75 if motion2==2:xcross=round(cos(tick)*50)+75;ycross=round(cos(tick)*50)+75 if motion2==3:xcross=round(cos(tick/2)*50)+75;ycross=round(sin(tick)*50)+75 if motion2==4:xcross=round(cos(tick)*-70)+75;ycross=round(sin(tick)*70)+75 if motion2==5:xcross=round(cos(tick*5)*50)+75;ycross=round(sin(tick*5)*50)+80 if motion2==6:xcross=round(cos(tick*10)*75)+75;ycross=round(sin(tick*10)*75)+80 if motion2==7:xcross=round(-tan(tick))+75 if motion2==8:xcross=round(tan(cos(tick)*30)*3)+75 C();F(xsqu,ysqu,50,1,"k");F(xsqu,ysqu+49,50,1,"k");F(xsqu,ysqu,1,50,"k");F(xsqu+49,ysqu,1,50,"k");F(xcross-12,ycross,25,1,"k");F(xcross,ycross-12,1,25,"k") if K(4)|K(52):return while monotonic()-t<.1/diff:0 tick+=.05 def shoot(): global totalmiss,xsqu,xcross,ysqu,ycross,lvl,motion1,motion2;missed=0;C();F(xsqu,ysqu,50,50,"k");F(xsqu+1,ysqu+1,48,48,"w");F(xcross-12,ycross,25,1,"k");F(xcross,ycross-12,1,25,"k");d=0 if xsqu<xcross and xcross<xsqu+50 and ysqu<ycross and ycross<ysqu+50:D("good",215,25);d=1 else:D("missed. "+str(2-totalmiss)+" try left",140,25);missed=1;totalmiss+=1 sleep(1) if d:print("Level "+str(lvl)+" completed !");lvl+=1;loadlv() if missed: if totalmiss<3:return # else:raise Game_over("try again") else:print("try again");totalmiss=0 while 1:loop();shoot()