Code 2048 :

© Baptystes 2014

:.THE2048  By Baptystes
:ClrDrawClrHome
:
:"<fonct>v</fonct>THE2048"Str1
:!If GetCalc(Str1)→Θ
:GetCalc(Str1,2)→Θ
:Return!If Θ
:0→{Θ}r
:End
:
:
:DiagnosticOff
:1Q
:While Q and (getKey15)
:0CD
:For(A,0,15
:0→{L1+A}
:End
:
:0Q
:ClrHomeClrDraw
:
:If (sub(RND,0)=2)
:sub(RND,1)
:Else
:sub(RND,0)
:End
:.
:0S
:sub(NUM
:StoreGDB 
:sub(GRI
:DispGraph
:0Q
:Repeat (getKey(15)) or Q
:Repeat (((getKey→K>0) and (K<5)) or getKey(15))
:End
:If (K>0) and (K<5)
:If sub(MOV,K
:.Pause 2000
:ClrHomeClrDraw
:(sub(RND,0)=0)→Q
:sub(NUM
:StoreGDB 
:sub(GRI
:DispGraph
:End:End
:1Q
:For(K,1,4
:If (sub(TST,K
:0Q
:End:End
:
:End
:
:If Q
:Text(27,26,"Game Over !"
:Pause 500
:Text(15,32,"[annul] ou [entrer]"
:0Q
:Repeat ((getKey→K=9) or (K=15))
:End
:0Q
:If (K=9)
:1Q
:End
:End
:If (S>{Θ}r)
:S→{Θ}r
:End
:.Q:
:End
:ClrDrawClrHome
:If (getKey(15) and getKey(54) and getKey(9))
:DelVar "<fonct>v</fonct>THE2048"
:End
:
:Return
:
:
:Lbl MOV
:0L
:For(A,0,3
:4Y
:For(B,0,3
:.V:DIRECTION
:.W:PERPENDIC
:If (r1=3) or (r1=2)
:BV
:AW
:Else
:AV
:BW
:End
:If (r1=3) or (r1=1)
:3-VV
:3-WW
:End
:If ({W*4+V+L1}→M0)
:0X
:0C
:Repeat C
:0H
:If (((V>0) and (r1=2)) or ((V<3) and (r1=3)) or ((W>0) and (r1=4)) or ((W<3) and (r1=1)))
:0XU
:{W*4+V+L1}→M
:If ({W+(r1=1)-(r1=4)*4+V+(r1=3)-(r1=2)→N+L1}=0)
:L++
:0→{W*4+V+L1}
:M→{N+L1}
:ElseIf ({N+L1}=M)
:1C
:If (((V>Y) and (r1=2)) or ((V<Y) and (r1=3)) or ((W>Y) and (r1=4)) or ((W<Y) and (r1=1)) or (Y=4))
:If ((r1=3) or (r1=2))
:VY
:Else:WY
:End
:0→{W*4+V+L1}
:M+1M→{N+L1}
:L++
:.Disp "B"
:MH
:.ACTIVED?:
:End
:
:.TEST U=1,2?:
:Else
:1C
:End
:
:If H
:1M
:For(R,1,H
:M*2M
:End
:M+SS
:End
:Else
:1C
:End
:V-(r1=2)+(r1=3)→V
:W-(r1=4)+(r1=1)→W
:
:.REPEAT
:End
:.M0:
:End
:End:End
:ReturnL
:
:
:Lbl TST
:0L
:For(A,0,3
:4Y
:For(B,0,3
:If (r1=3) or (r1=2)
:BV
:AW
:Else
:AV
:BW
:End
:If (r1=3) or (r1=1)
:3-VV
:3-WW
:End
:If ({W*4+V+L1}→M0)
:0C
:Repeat C
:0H
:If (((V>0) and (r1=2)) or ((V<3) and (r1=3)) or ((W>0) and (r1=4)) or ((W<3) and (r1=1)))
:0U
:{W*4+V+L1}→M
:If (({W+(r1=1)-(r1=4)*4+V+(r1=3)-(r1=2)→N+L1}=0) or ({N+L1}=M))
:1C
:L++
:.ACTIVED?:
:End
:.TEST U=1,2?:
:Else
:1C
:End
:
:V-(r1=2)+(r1=3)→V
:W-(r1=4)+(r1=1)→W
:
:End
:
:.M0:
:End
:End:End
:ReturnL
:
:
:Lbl RND
:1C
:For(A,0,3
:For(B,0,3
:!If {A*4+B+L1}
:0C
:End
:End:End
:!If C
:While (getKey15)
:rand^4A
:rand^4B
:End!If ({A*4+B+L1})
:!If r1
:rand^2+1Z→{A*4+B+L1}
:Else
:r1Z→{A*4+B+L1}
:End
:Text(B*13+26,A*13+15,"."
:Else
:0Z
:End
:ReturnZ
:
:
:Lbl NUM
:.0S
:For(A,0,3
:For(B,0,3
:{B*4+A+L1}→E
:1N
:If E
:If E9
:For(C,1,E
:N*2N
:End
:NE
:Else
:Text(A*13+21,B*13+5,"."
:Text(A*13+32,B*13+5,"."
:Text(A*13+21,B*13+16,"."
:Text(A*13+32,B*13+16,"."
:End
:Text(A*13+25-(2*(E>10))-(2*(E>100)),B*13+12,E►Dec
:
:End:End:End
:Text(0,0,"BAPTYSTES"
:Text(42,0,S►Dec
:Text(65,0,{Θ}r►Dec
:Text(0,58,"0.9"
:Return
:
:
:Lbl GRI
:For(A,0,4
:Line(A*13+20,9,A*13+20,61
:Line(20,A*13+9,72,A*13+9
:End
:Return

Nouveau site :


Abonne toi!