keys: Arrow Clear Shift
from math import * from kandinsky import * from random import * from ion import * from time import * print("By merle") score=0 skin=0 car_circuit=0 bg_color=(0,255,255) circuit=[ (0,220,0),(150,150,70),(255,200,0),(255,255,0),(200,0,0),(255,0,0),(255,255,255),(0,200,200) ] car_skin=[ (180,0,0),(255,0,0),(255,0,255),(180,0,180),(0,0,180),(0,0,255),(0,100,0),(0,180,0),(0,255,0),(255,220,0),(255,180,0),(255,100,0) ] cadenas_skin=[ 0,1,1,1,1,1,1,1,1,1,1,1 ] def mini_car(x,y): draw_string("Cars",140,5,(0,0,255),bg_color) fill_rect(x-50,y-40,100,65,bg_color) fill_rect(x-40,y-15,80,30,car_skin[skin]) fill_rect(x+15,y+5,20,18,bg_color) fill_rect(x+17,y+7,16,16,(100,100,100)) fill_rect(x-35,y+5,20,18,bg_color) fill_rect(x-33,y+7,16,16,(100,100,100)) fill_rect(x+29,y-12,8,8,(255,255,0)) fill_rect(x+20,y,6,-35,car_skin[skin]) fill_rect(x-33,y,6,-35,car_skin[skin]) fill_rect(x-30,y-38,53,6,car_skin[skin]) draw_string(">",x+50,y-20,(0,0,255),bg_color) draw_string("<",x-60,y-20,(0,0,255),bg_color) if cadenas_skin[skin]==1: fill_rect(160-10,62-10,20,15,(0,0,0)) fill_rect(160-7,62-10,5,-8,(0,0,0)) fill_rect(160+2,62-10,5,-8,(0,0,0)) fill_rect(160-5,62-20,10,5,(0,0,0)) def car(x,y): fill_rect(x-50,y-40,100,60,bg_color) fill_rect(x-40,y-15,80,30,car_skin[skin]) fill_rect(x+15,y+5,20,18,bg_color) fill_rect(x+17,y+7,16,16,(100,100,100)) fill_rect(x-35,y+5,20,18,bg_color) fill_rect(x-33,y+7,16,16,(100,100,100)) fill_rect(x+29,y-12,8,8,(255,255,0)) fill_rect(x+20,y,6,-35,car_skin[skin]) fill_rect(x-33,y,6,-35,car_skin[skin]) fill_rect(x-30,y-38,53,6,car_skin[skin]) def map(xm,y): fill_rect(xm,y+22,10000,10,circuit[car_circuit]) fill_rect(xm,y+32,10000,80,circuit[car_circuit+1]) for i in range(0,800,20): fill_rect(xm+i,180+((i%3)*10),10,10,circuit[car_circuit]) def mini_map(x,y): draw_string("Grounds",125,100,(0,0,255),bg_color) fill_rect(x-40,y-50,80,10,circuit[car_circuit]) fill_rect(x-40,y-40,80,50,circuit[car_circuit+1]) fill_rect(x-35,y-20,10,10,circuit[car_circuit]) fill_rect(x,y,10,10,circuit[car_circuit]) fill_rect(x+25,y-40,10,10,circuit[car_circuit]) draw_string(">",x+50,y-20,(0,0,255),bg_color) draw_string("<",x-60,y-20,(0,0,255),bg_color) def coin(x,y,val): fill_rect(x-5,y-2,44,34,bg_color) fill_rect(x-2,y-2,34,34,(255,180,0)) fill_rect(x,y,30,30,(255,255,0)) draw_string(""+str(val),x+4,y+7,(255,180,0),(255,255,0)) def feu(x,y): fill_rect(x-10,y-10,20,20,bg_color) fill_rect(x-7,y-7,14,14,(255,180,0)) fill_rect(x-5,y-5,10,10,(255,220,0)) def aff_score(): fill_rect(250,3,14,14,(255,180,0)) fill_rect(252,5,10,10,(255,255,0)) draw_string("x"+str(score)+" ",265,3,(0,0,255),bg_color) def feuc(n,x): fill_rect(x-15,30,30,135,bg_color) fill_rect(x-5,80,10,85,(100,100,100)) fill_rect(x-10,30,20,50,(50,)*3) fill_rect(x-5,35,10,10,(100,0,0)) fill_rect(x-5,50,10,10,(150,100,0)) fill_rect(x-5,65,10,10,(0,100,0)) if n==1: fill_rect(x-5,35,10,10,(255,0,0)) if n==2: fill_rect(x-5,50,10,10,(255,180,0)) if n==-1: fill_rect(x-5,65,10,10,(0,255,0)) fill_rect(0,0,320,230,bg_color) mini_car(160,65) mini_map(160,170) select=1 while True: aff_score() if select==1: draw_string("*",100,5,(0,0,255),bg_color) draw_string(" ",100,100,(0,0,255),bg_color) elif select==2: draw_string("*",100,100,(0,0,255),bg_color) draw_string(" ",100,5,(0,0,255),bg_color) if cadenas_skin[skin]==1 and select==1: draw_string("Cost => "+str(skin*50)+" ",105,190,(0,0,255),bg_color) else: draw_string(" OK => Play",105,190,(0,0,255),bg_color) if keydown(KEY_RIGHT)and skin<11 and select==1: skin+=1 mini_car(160,65) while keydown(KEY_RIGHT): pass if keydown(KEY_LEFT)and skin>0 and select==1: skin-=1 mini_car(160,65) while keydown(KEY_LEFT): pass if keydown(KEY_RIGHT)and car_circuit<6 and select==2: car_circuit+=2 mini_map(160,170) while keydown(KEY_RIGHT): pass if keydown(KEY_LEFT)and car_circuit>0 and select==2: car_circuit-=2 mini_map(160,170) while keydown(KEY_LEFT): pass if keydown(KEY_DOWN)and select<2: select+=1 while keydown(KEY_DOWN): pass if keydown(KEY_UP)and select>1: select-=1 while keydown(KEY_UP): pass if keydown(KEY_VAR): score+=50 if keydown(KEY_OK) and cadenas_skin[skin]==1 and score>=skin*50 and select==1: while keydown(KEY_OK): pass cadenas_skin[skin]=0 score-=skin*50 aff_score() mini_car(160,65) if keydown(KEY_OK) and cadenas_skin[skin]==0: while keydown(KEY_OK): pass fill_rect(0,0,320,230,bg_color) car(100,143) v=0 y=143 xm=0 map(xm,143) fuel=200 draw_string("Fuel",140,5,(0,0,255),bg_color) fill_rect(58,20,204,9,(100,100,100)) fill_rect(60,22,200,5,(150,150,150)) x_fuel=650 y_fuel=123 x_coin=randint(3,8)*100 y_coin=123 x_coin2=randint(3,8)*100 y_coin2=123 x_bad=randint(3,8)*100 y_bad=40 x_feuc=160 a=1 n=1 t=monotonic() fill_rect(60,22,fuel,5,(0,255,0)) while fuel>0: aff_score() feu(x_bad,y_bad) coin(x_coin,y_coin,10) coin(x_coin2,y_coin2,5) fill_rect(x_fuel-20,y_fuel-5,65,40,bg_color) fill_rect(x_fuel,y_fuel,25,30,(240,0,0)) fill_rect(x_fuel-7,y_fuel+3,7,4,(240,0,0)) fill_rect(x_fuel-7,y_fuel+25,7,4,(240,0,0)) fill_rect(x_fuel-9,y_fuel+5,4,22,(240,0,0)) fill_rect(x_fuel+25,y_fuel,5,10,(240,0,0)) feuc(n,x_feuc) if monotonic()-t>6 and t-monotonic()-t<8: t=monotonic() n-=n*2 if x_feuc<150 and x_feuc>90 and n==-1: car(100,143) elif x_feuc<150 and x_feuc>90 and n==1: fuel=0 draw_string("you have run the",90,105,(0,0,255),bg_color) draw_string("traffic lights",105,125,(0,0,255),bg_color) while not keydown(KEY_OK): pass while keydown(KEY_OK): pass if x_feuc<0: x_feuc=randint(8,12)*100 fill_rect(0,20,230,170,bg_color) car(100,143) if x_fuel<150: fuel=200 fill_rect(0,20,230,170,bg_color) car(100,143) x_fuel=randint(50,65)*10 if x_bad<150 and x_bad>70 and y_bad>120: fuel=0 car(100,143) draw_string("you hit the",90,105,(0,0,255),bg_color) draw_string("fireball",105,125,(0,0,255),bg_color) while not keydown(KEY_OK): pass while keydown(KEY_OK): pass if x_bad<0: fill_rect(0,20,230,170,bg_color) x_bad=randint(3,10)*100 y_bad=40 car(100,143) if x_coin<150: score+=10 fill_rect(0,20,230,170,bg_color) x_coin=randint(3,8)*100 car(100,143) if x_coin2<150: score+=5 fill_rect(0,20,230,170,bg_color) x_coin2=randint(3,8)*100 car(100,143) if y_bad>150 or y_bad<40: a-=a*2 y_bad+=a if v!=0: map(xm,143) xm-=v if xm>300: xm=0 if xm<-300: xm=0 if keydown(KEY_BACKSPACE) and v<3: v+=1 x_fuel-=3 x_coin-=3 x_coin2-=3 x_bad-=3 x_feuc-=3 fuel-=1 draw_string("Fuel",140,5,(0,0,255),bg_color) fill_rect(58,20,204,9,(100,100,100)) fill_rect(60,22,200,5,(150,150,150)) fill_rect(60,22,200,5,(150,150,150)) fill_rect(60,22,fuel,5,(0,255,0)) elif v>0: v-=1 elif v<0: v+=1 elif keydown(KEY_SHIFT) and v>-4: v-=1 x_fuel-=-3 x_coin-=-3 x_coin2-=-3 x_bad-=-3 x_feuc-=-3 fuel-=1 fill_rect(60,22,200,5,(150,150,150)) fill_rect(60,22,fuel,5,(0,255,0)) if keydown(KEY_ALPHA): bg_color=(0,)*3 fill_rect(0,0,320,230,bg_color) draw_string(" Game Over!! ",90,105,(0,0,255),bg_color) draw_string(" ",90,125,(0,0,255),bg_color) while not keydown(KEY_OK): pass while keydown(KEY_OK): pass fill_rect(0,20,320,230,bg_color) mini_car(160,65) mini_map(160,170) select=1