Aujourd'hui je vous présente mon nouveau jeu, 2048!
Il s'agit d'une adaptation du jeu sur smartphone, réalisée en TIbasic z80 et compatible TI82/83/84/+
Voici un screenshoot:
Ainsi que le code:
- Code: Tout sélectionner
:DelVar Θ
:ClrDraw:AxesOff
:0→Xmin:0→Ymin
:1→∆X:1→∆Y
:DelVar [A]{4,4→dim([A]
:Lbl 9
:ClrHome
:Menu(" Design?","Default",D,"Manual",M,"Random",R
:Lbl R
:randInt(1,3→M
:randInt(1,7→L
:Goto 2
:Lbl D:2→L:2→M:Goto 2
:Lbl M
:Disp "Type?1=·/2=□/3=˖
:Input "",M
:If not(max(M={1,2,3:Goto 9
:Disp "Size?
:Input "",L
:abs(L→L
:Lbl 2
:ClrDraw
:DelVar L<sub>1</sub>DelVar L<sub>2</sub>
:randInt(1,4→V
:randInt(1,4→W
:For(A,12,62,L
:Pt-On(22,A,M
:Pt-On(48,A,M
:Pt-On(72,A,M
:End
:For(A,0,94,L
:Pt-On(A,24,M
:Pt-On(A,38,M
:Pt-On(A,52,M
:End
:StorePic 1
:DelVar B
:{1,26,51,76→L<sub>1</sub>
:{0,13,28,42→L<sub>2</sub>
:Repeat K=72
:getKey→K
:If K=94:Goto Q
:Text(1,1,"Menu>
:Text(13,27,"Play
:Text(28,52,"Optn
:Text(43,78,"Exit
:Text(55,10,"*****2048*****
:If K=83:Goto 9
:End
:ClrDraw:RecallPic 1
:DelVar Z2→A:2→B
:Lbl 1
:DelVar [A]{4,4→dim([A]
:ClrDraw:RecallPic 1
:2→[A](randInt(1,4),randInt(1,4)
:Lbl 5
:For(A,1,4
:For(B,1,4
:Text(L<sub>2</sub>(A),L<sub>1</sub>(B)," "
:If [A](A,B:Text(L<sub>2</sub>(A),L<sub>1</sub>(B),[A](A,B
:End:End
:Repeat K=45
:getKey→K
:Text(55,40,Θ
:If K=45:Stop
:If max(K={24,25,26,34:Then
:If K=26 or K=34:Then
:1→I:3→J:1→L
:End
:If K=24 or K=25:Then
:4→I:2→J:‾1→L
:End
:If K=26 or K=24:Then
:For(W,1,4
:For(V,I,J,L
:If [A](W,V)=[A](W,V+L):Then
:[A](W,V)+[A](W,V+L)→[A](W,V+L:0→[A](W,V
:Θ+2[A](W,V+L→Θ
:End
:If not([A](W,V+L:Then
:[A](W,V)→[A](W,V+L
:0→[A](W,V
:End
:End:End:End
:If K=34 or K=25:Then
:For(W,1,4
:For(V,I,J,L
:If [A](V,W)=[A](V+L,W:Then
:[A](V,W)+[A](V+L,W)→[A](V+L,W
:0→[A](V,W
:Θ+2[A](V+L,W→Θ
:End
:If not([A](V+L,W:Then
:[A](V,W)→[A](V+L,W
:0→[A](V,W
:End
:End:End:End
:Repeat not([A](E,F
:randInt(1,4→E
:randInt(1,4→F
:End
:2→[A](E,F
:Goto 5
:End:End:End
Enfin, voici le lien de téléchargement: archives_voir.php?id=43458
Vous pouvez créer votre propre design!
N'hésitez pas à me proposer vos suggestions, vos optimisations et vos questions!
@++