from math import * from random import * from kandinsky import * from ion import * from time import * print("---------------- CUBE MAN -----------------") print("Keys:") print("-Left: move left") print("-Right: move right") print("-Up: take a bloc") print("-Down: pose the bloc") print("-Ok: restart the level") print("-Exe: pass the level") print("") print("Create by Merle in 2024") print("") print("") print("") print("->PRESS <OK> TO CONTINUE") while not keydown(KEY_OK): pass _player=[ 0,0,0,2,2,2,0,0,0,0, 0,2,2,2,2,2,2,2,2,2, 0,2,2,2,2,2,2,1,0,0, 2,2,2,2,1,1,1,1,1,0, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1,1,0, 0,0,1,1,1,1,1,1,0,0, 0,0,0,1,1,1,1,0,0,0, 0,2,2,2,2,2,2,2,2,0, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 0,2,2,2,2,2,2,2,2,0] _player1=[ 0,0,0,0,2,2,2,0,0,0, 2,2,2,2,2,2,2,2,2,0, 0,0,1,2,2,2,2,2,2,0, 0,1,1,1,1,1,2,2,2,2, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1, 0,1,1,1,1,1,1,1,1,0, 0,0,1,1,1,1,1,1,0,0, 0,0,0,1,1,1,1,0,0,0, 0,2,2,2,2,2,2,2,2,0, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2, 0,2,2,2,2,2,2,2,2,0] _caisse=[ 4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4, 4,4,4,4,5,5,5,5,4,4, 4,4,4,4,4,5,5,5,4,4, 4,4,5,4,4,4,5,5,4,4, 4,4,5,5,4,4,4,5,4,4, 4,4,5,5,5,4,4,4,4,4, 4,4,5,5,5,5,4,4,4,4, 4,4,4,4,4,4,4,4,4,4, 4,4,4,4,4,4,4,4,4,4] _glace=[ 6,6,6,6,6,6,6,6,6,6, 6,7,7,6,7,7,7,6,7,6, 6,7,7,6,7,7,7,7,7,6, 6,7,7,7,6,7,7,7,7,6, 6,7,7,7,7,6,7,7,7,6, 6,7,7,7,7,6,7,7,7,6, 6,7,7,6,7,7,7,7,7,6, 6,7,7,7,6,7,7,7,7,6, 6,7,7,7,6,7,7,7,7,6, 6,6,6,6,6,6,6,6,6,6] _pic=[ 0,0,0,0,0,0,0,0,0,0, 0,0,0,0,8,8,0,0,0,0, 0,0,0,8,8,8,8,0,0,0, 0,0,0,8,8,8,8,0,0,0, 0,0,8,8,8,8,8,8,0,0, 0,0,8,8,8,8,8,8,0,0, 0,8,8,8,8,8,8,8,8,0, 0,8,8,8,8,8,8,8,8,0, 8,8,8,8,8,8,8,8,8,8, 8,8,8,8,8,8,8,8,8,8] colors=[(0,)*3,(255,180,100),(0,0,255),(255,)*3,(150,150,100),(200,200,150),(0,200,255),(0,255,255),(150,)*3,(200,)*3] def player1(x,y): a=0 for b in range(y,y+20): for c in range(x,x+10): if _player[a]!=0:set_pixel(c,b,colors[_player[a]]) a+=1 def player2(x,y): a=0 for b in range(y,y+20): for c in range(x,x+10): if _player1[a]!=0:set_pixel(c,b,colors[_player1[a]]) a+=1 def caisse(x,y): a=0 for b in range(y,y+10): for c in range(x,x+10): if _caisse[a]!=0:set_pixel(c,b,colors[_caisse[a]]) a+=1 def glace(x,y): a=0 for b in range(y,y+10): for c in range(x,x+10): if _glace[a]!=0:set_pixel(c,b,colors[_glace[a]]) a+=1 def pic(x,y): a=0 for b in range(y,y+10): for c in range(x,x+10): if _pic[a]!=0:set_pixel(c,b,colors[_pic[a]]) a+=1 def bloc(x,y): fill_rect(x,y,10,10,colors[4]) def blocs(n,x,y): if n==0:fill_rect(x,y,10,10,(255,)*3) if n==1:caisse(x,y) if n==2:glace(x,y) if n==3:pic(x,y) if n==4:bloc(x,y) def draw_map(list): fill_rect(0,0,320,132,(255,)*3) a=0 for b in range(132,222,10): for c in range(0,320,10): blocs(list[a],c,b);a+=1 def jeu(n): niveau1=[ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,#1 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,#2 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,#3 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,#4 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,#5 0,0,0,0,0,0,0,0,0,0,1,0,0,4,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,4,#6 4,0,0,0,0,0,0,4,0,4,4,4,4,4,2,2,2,2,2,2,2,4,4,4,0,0,0,1,0,0,0,4,#7 4,4,4,0,4,4,4,4,3,4,4,4,4,4,4,0,0,0,0,0,4,4,4,4,0,0,4,4,4,4,4,4,#8 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,3,3,3,3,4,4,4,4,4,4,4,4,4,4,4,4]#9 niveau2=[ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,#1 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,#2 0,0,0,0,0,0,0,0,0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,0,4,2,4,3,2,0,0,0,4,3,2,0,0,0,4,#6 0,2,4,0,0,0,0,0,0,0,0,0,1,4,0,0,0,0,2,4,4,3,2,0,0,4,4,3,2,0,0,4,#7 0,2,4,0,0,0,0,0,0,0,0,0,1,1,4,0,0,0,2,4,0,4,3,2,0,4,0,4,3,2,4,4,#8 4,3,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,3,4,4,4,4,3,4,4,4,4,4,3,4,4]#9 niveau7=[ 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,#1 4,0,0,0,0,4,4,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,#2 4,0,0,0,0,4,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,#3 4,0,4,4,0,0,0,4,0,4,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,#4 4,0,4,1,0,0,4,1,0,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,#5 4,0,4,1,4,0,1,1,0,1,2,2,2,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,#6 0,0,4,1,1,0,1,1,0,1,2,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,#7 0,0,4,1,1,0,1,1,0,1,2,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,4,#8 4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4,4]#9 if n==1: n_level=1 fill_rect(0,0,320,222,(255,)*3) draw_string(" Level 1 ",125,100) sleep(1) niv1=niveau1 if n==2: n_level=2 fill_rect(0,0,320,222,(255,)*3) draw_string(" Level 2 ",125,100) sleep(1) niv1=niveau2 if n==3: n_level=3 fill_rect(0,0,320,222,(255,)*3) draw_string(" Level 3 ",125,100) sleep(1) niv1=niveau3 if n==4: n_level=4 fill_rect(0,0,320,222,(255,)*3) draw_string(" Level 4 ",125,100) sleep(1) niv1=niveau4 if n==5: n_level=5 fill_rect(0,0,320,222,(255,)*3) draw_string(" Level 5 ",125,100) sleep(1) niv1=niveau5 draw_map(niv1) _y=182 _x=300 _a=222 _b=0 _c=0 _p=0 _g=0 player2(_x,_y) life=True while life: if keydown(KEY_LEFT)and niv1[_a-1]==0: _x-=10 _a-=1 _d=1 draw_map(niv1) player2(_x,_y) if keydown(KEY_LEFT)and niv1[_a-1]!=0 and niv1[_a-33]==0: _y-=10 _x-=10 _a-=33 _d=1 draw_map(niv1) player2(_x,_y) if keydown(KEY_RIGHT)and niv1[_a+1]==0: _x+=10 _a+=1 _d=2 draw_map(niv1) player1(_x,_y) if keydown(KEY_RIGHT)and niv1[_a+1]!=0 and niv1[_a-31]==0: _y-=10 _x+=10 _a-=31 _d=2 draw_map(niv1) player1(_x,_y) if niv1[_a+32]==0: while niv1[_a+32]==0: _y+=10 _a+=32 draw_map(niv1) player2(_x,_y) if niv1[_a+32]==2: niv1[_a+32]=0 if niv1[_a+32]==3 or keydown(KEY_OK): draw_string("Game Over",125,100) sleep(0.5) jeu(n_level) if niv1[_a+1]==1: if keydown(KEY_UP) and _p==0: niv1[_a+1]=0 _p=1 draw_map(niv1) player1(_x,_y) if niv1[_a-1]==1: if keydown(KEY_UP) and _p==0: niv1[_a-1]=0 _p=1 draw_map(niv1) player2(_x,_y) if _p==1: blocs(1,_x,_y-10) if keydown(KEY_DOWN)and _p==1: if _d==1 and niv1[_a-1]==0: niv1[_a-1]=1 _p=0 if _d==2 and niv1[_a+1]==0: niv1[_a+1]=1 _p=0 draw_map(niv1) player2(_x,_y) for i in range(0,288): if niv1[i]==1 and niv1[i+32]==0: niv1[i]=0 niv1[i+32]=1 draw_map(niv1) player2(_x,_y) if _x<10 or keydown(KEY_EXE): draw_string("You Won",135,100) sleep(0.5) if n_level<5: n_level+=1 jeu(n_level) if _x>=320:_x=0 if keydown(KEY_NINE):_p=1 n_level=1 jeu(1)