xeros le 20/01/2007 à 15:26
bonjour tt le monde
j'ai enfin terminé mon prog aprè bien des difficultés !!
c'est une bataille navale
il est decoupé en deux parties afin qu'il soit plus rapide :
1-pour l'enregistrement des positions du bateau
2-pou jouer la partie
mais rien ne vous empeche de les recoller pour n'en faire qu'un seul bloc .Cependant,il sera assez long dans le traitement des listes et les calcul
voici les codes:
1-partie enregistrative : WARSHIPS
Code
:clrhome
:output(4,1,"*** warships ***
:for(t,0,500
:end
:clrdraw
:clralllists
:clrhome
:-0.8 -> xmin
:0 -> ymin
:10.5 -> xmax
:10.5 -> ymax
:fnoff
:gridon
:axeson
:text(1,1,"j
:text(6,1,"i
:text(12,1,"h
:text(18,1,"g
:text(24,1,"f
:text(30,1,"e
:text(36,1,"d
:text(42,1,"c
:text(48,1,"b
:text(54,1,"a
:storepic 2
:storepic 1
:1 -> teta
:5 -> k
:1 ->a
:2 ->b
:3 ->c
:4 ->d
:5 ->e
:6 ->f
:7 ->g
:8 ->h
:9 ->i
:10 ->j
:0 -> y
:1 -> x
:1 -> n
:output(1,1,"place tes
:output(2,1,"navires :
:for(t,0,300
:end
:lbl 0
:2 -> o
:5 -> l
:5 -> m
:0 -> r
:lbl l
:getkey -> w
:if w=34
:l-1 -> l
:if l=<1
:1 -> l
:if w=25
:l+1 -> l
:if l>=10
:10 -> l
:if w=26
:m+1 -> m
:if m>=10
:10 -> m
:if w=24
:m-1 -> m
:if m=<1
:1 -> m
:if w=105
:goto d
:if n=0
:goto q
:l -> q
:m+k-1 -> p
:lbl q
:if w=21
:1 -> r
:if r=1
:then
:m -> p
:l+k-1 -> q
:1 -> o
:0 -> n
:end
:if w=31
:then
:2 -> o
:1 -> n
:0 -> r
:end
:pt-off(m,l
:pt-off(p,q
:for(t,0,50
:end
:pt-on(l,m
:pt-on(p,q
:goto l
:lbl d
:0 -> r
:1 -> n
:l -> L1(x)
:m -> L2(x)
:1-> teta
:if o=1
:goto 1
:goto 2
:lbl 1
:teta +1 -> teta
:m -> m
:L+1 -> l
:if teta > k -> erreur corrigée
:goto 3
:l -> L1(teta+y)
:m -> L2(teta+y)
:qoto 1
:lbl 3
:y+k -> y
:line(L2(x),L1(x),L2(y),L1(y)
:storepic 1
:pause
:x+k -> x
:k-1 -> k
:if k<2
:goto 4
:2 -> o
:goto 0
:lbl 2
:1 -> teta
:lbl 5
:l -> l
:m+1 -> m
:teta +1 -> teta
:if teta>k
:goto 3
:l -> L1(teta+y)
:m -> L2(teta+y)
:goto 5
:lbl 4
:clrhome
:5 -> y
:5 -> k
:1 -> z
:1 -> teta
:1 -> n
:output(1,1,"je place mes
:output(2,1,"navires :
:output(3,1,"batau de :
:output(6,5,"patiente...
:lbl 6
:output(3,12,k
:randint(1,8) -> l
:randint(1,8) -> m
:randint(1,2) -> x
:goto 13
:lbl 10
:if x=1
:goto 11
:if x=2
:goto 12
:lbl 11
:if l+k>10
:then
:l-(l+k-10) -> l
:goto 13
:end
:l+1 -> l
:goto 13
:lbl 12
:if m+k>10
:then
:m-(m+k-10) -> m
:goto 13
:end
:m+1 -> m
:lbl 13
:if teta=1
:goto 14
:if l=L3(z) and m=L4(z)
:then
:n -> teta
:goto 6
:end
:if l#L3(z) or m#L4(z)
:then
:z+1 -> z
:if z> teta-1
:goto 14
:goto 13
:end
:lbl 14
:1 -> z
:l -> L3(teta)
:m -> L4(teta)
:teta+1 -> teta
:if teta > y
:then
:n+k -> n
:k-1 -> k
:k+y -> y
:if k<2
:goto 15
:goto 6
:end
:goto 10
:lbl 15
:clrhome
:output(1,1,"strategie enre.
:output(4,1,"quitte le prog
:output(5,1,"et lance le 2e
:11794591 -> r
:pause
:clrhome
:stop
code
fin de la partie enregistrative
lorsque la calculatrice place ces batiments,elle est un peu longue laissez lui le temp de terminer,n'arretez pa le prog croyant qu'il bug (sauf si vous avez fait une faute de frappe)
2-partie "action" :WARSHIP
Code
:if r=11794591
:goto 1
:clrhome
:output(2,1,"partie non
:output(3,5,"initialisée
:output(6,1,"reconfigure tes
:output(7,5,"positions
:pause
:clrhome
:prgmWARSHIPS
:lbl 1
:clrhome -> erreur corrigée
:output(3,1,"sauvegarde
:output(4,3,"correcte
:for(t,0,200
:end
:1 -> w
:1 -> n
:1 -> o
:clrdraw
:clrhome
:output(4,1,"a toi de
:output(5,4,"commencer !
:for(t,0,200
:end
:lbl a
:5 -> l
:5 -> m
:1 -> teta
:recallpic 2
:clrhome
:lbl n
:getkey -> k
:if k=24
:l-1 ->l
:if if l=<1
:1 -> l
:if k=26
:l+1 -> l
:if l>=10
:10 -> l
:if k=25
:m+1 -> m
:if m>=10
:10 -> m
:if k=34
:m-1 -> m
:if m=<1
:1 -> m
:if k=21
:then
:0 -> r
:clrdraw
:clralllists
:gridoff
:output(3,2,"lache !
:output(4,4,"tu fuit !
:for(t,0,200
:end
:clrhome
:stop
:end
:if k=105
:goto b
:pt-on(l+0.1,m
:pt-on(l-0.1'm
:pt-on(l,m+0.17
:pt-on(l,m-0.17
:for(t,0,50
:end
:pt-off(l+0.1,m
:pt-off(l-0.1,m
:pt-off(l,m+0.17
:pt-off(l,m-0.17
:goto n
:lbl b
:if l=L3(teta) and m=L4(teta)
:goto c
:if l#L3(teta) or m#L4(teta)
:teta+1 -> teta
:if teta>14
:goto d
:goto b
:lbl c
:0 -> L3(teta)
:0 -> L4(teta)
:circle(l,m,o.5
:storepic 2
:1 -> teta
:n+1 -> n
:if n=15 -> erreur corrigée
:goto q
:clrhome
:output(3,1,"bien joué !
:output(4,3,"recommence !
:for(t,0,200
:end
:goto a
:lbl d
:circle(l,m,0.2
:storepic2
:1 -> teta
:clrhome
:output(4,2,"a moi de
:output(5,4,"jouer
:clrdraw
:for(t,0,200
:end
:lbl h
:randint(1,10) -> l
:randint(1,10) -> m
:recallpic 1
:1 -> v
:if w=1
:goto t
:lbl u
:if l=L5(v) and m=L6(v)
:goto h
:if l#L5(v) or m#L6(v)
:v+1 -> v
:if v>w-1
:goto t
:goto u
:lbl t
:l -> L5(w)
:m -> L6(w)
:w+1 -> w
:lbl g
:if l=L1(teta) and m=L2(teta)
:goto e
:if l#L1(teta) or m#L2(teta)
:teta+1 -> teta
:if teta>14
:goto f
:goto g
:lbl f
:circle(m,l,0.2
:storepic 1
:clrhome
:output(4,2,"a toi de
:output(5,4,"jouer
:clrdraw
:for(t,0,200
:end
:goto a
:lbl e
:0 -> L1(teta)
:0 -> L2(teta)
:circle(m,l,0.5
:storepic 1
:o+1 -> o
:if o=15
:goto y
:clrhome
:output(4,2,"je continue
:for(t,0,200
:end
:goto s
:lbl q
:clrhome
:output(4,4,"you win
:clrdraw
:0 -> r
:stop
:lbl y
:clrhome
:output(4,4,"you loose !
:clrdraw
:0 -> r
:stop
:lbl s
:randint(1,3) -> x
:if x#3
:then
:if teta+1>14
:0 -> teta
:L1(teta+1) -> l
:L2(teta+1) -> m
:1 -> teta
:goto u
:end
:goto h
voila
les 2 morceaux sont independants l'un de l'autre.cependant,lorsque vous quittez le prog au milieu d'une partie il faudra réinitialiser la partie
cela evite d'aller voir les positions de l'adversaires et de tricher !
(j'ai deja perdu contre la machine ...
bon amusement et bonne chasse !
ps:dite moi ce que vous en pensez , et les eventuelles modifications a faire, merci
xeros le 20/01/2007 à 16:11
autres informations :
il y a 4 bateaux ,
-un de 5
-un de 4
-un de 3
-et un de 2
pour l'enregistrement de vos bateaux :
vous entrez la premiere coordonnée ensuite avec le menu (verticale/horizontale) la calculatrice fait le reste.cependant arrangez vous pour que le bateau ne sorte pas du tableau ou n'en croise un autre (vous pouvez trè bien rajouter ces conditions dans le prg)
pour jouer :
deplacez le curseur clignotant avec le pavet multidirectionnel et appuyez sur enter pour valider l'attaque :
-un petit rond -> a l'eau !
-un grand rond -> touché !
pour quitter la partie en coure,appuyez sur 2nd
voila je pense avoir fait le tour .
Désoler pour la lisibilitée , et je suis sur que tu peu mieux faire !!
le prog n'est pas au plus simplifié , pour les adeptes de la simplification et de l'acceleration des prog rien ne vous empêches de le faire, mais tenez moi au courant des modifications que vous faites que je puisse ameliorer les prochains progs .
Désoler aussi pou ceux qui demanderait le lien 82p je n'ai aucun moyen de le faire.
bye
xeros le 07/06/2008 à 21:00
et la voici la voila !!!
après bien du temps , voici la nouvelle version de WARSHIPS ( dur dur de trouver du temp libre en prépa

)
le programme entier est toujours divisé en 2 parties (enregistrative et action), afin d'augmenter les capacités de chaque partie
prgm d'enregistrement des positions :"WARENREG"
Code
:clralllists
:FnOFF
:GridOFF
:AxesOFF
:Clrdraw
:for(A,1,92
:92-A -> B
:Pxl-On(20,A
:Pxl-On(45,B
:End
:Text(25,20,"B A T T L E S H I P S
:"THE LAST AFFRONTEMENT" -> Str1
:for(A,1,lenght(Str1
:sub(Str1,1,A -> Str2
:Text(35,10,Str2
:End
:For(T,0,300
:End
:For(A,92,1,-1
:92-A -> B
:Pxl-Off(20,A
:Pxl-Off(45,B
:End
:Clrdraw
:Text(5,1,"POSITIONNE TES BATIMENTS :
:Text(15,10,"- 1 BATEAU DE 5
:Text(22,10,"- 1 BATEAU DE 4
:Text(29,10,"- 2 BATEAU DE 3
:Text(36,10,"- 1 BATEAU DE 2
:Text(55,72,"ENTER
:Pause
:Clrdraw
:-1 -> xmin
:0 -> ymin
:11.1 -> xmax
:11.1 -> ymax
:1 -> Xscl
:1 -> Yscl
:fnoff
:gridon
:axeson
:Line(-1,0,-1,11.1
:Line(11.1,0,11.1,11.1
:Line(-1,11.1,11.1,11.1
:Text(1,3,"w
:Text(7,3,"a
:Text(13,3,"r
:Text(19,3,"s
:Text(25,3,"h
:Text(31,3,"i
:Text(37,3,"p
:Text(43,3,"s
:text(55,3,1
:storepic 2
:Text(55,1,"IA
:storepic 1
:{10,10} -> Dim([A]
:0[A] -> [A]
:[A] -> [B]
:[B] -> [C]
:1 -> teta
:5 -> K
:1 ->A
:0 -> Y
:1 -> X
:1 -> N
:lbl 0
:2 -> O
:5 -> L
:5 -> M
:0 -> R
:lbl l
:getkey -> W
:if W=34
:L-1 -> L
:if L=<1
:1 -> L
:if W=25
:L+1 -> L
:if L+K-1>=10 And R=1
:10-K+1 -> L
:if L>=10
:10 -> L
:if W=26
:M+1 -> M
:if M+K-1>=10 And R=0
:10-K+1 -> M
:if M>=10
:10 -> M
:if W=24
:M-1 -> M
:if M=<1
:1 -> M
:if W=105
:goto d
:if N=0
:goto q
:l -> Q
:M+K-1 -> P
:lbl q
:if W=21
:1 -> R
:if R=1
:then
:M -> P
:L+K-1 -> Q
:1 -> O
:0 -> N
:End
:if W=31
:then
:2 -> O
:1 -> N
:0 -> R
:End
:Line(M,L,P,Q
:for(t,0,25
:End
:Line(M,L,P,Q,0
:RecallPic 1
:goto l
:lbl d
:0 -> R
:1 -> N
:L+M/100 -> C
:C -> L1(X)
:1-> [A](L,M)
:1 -> teta
:if O=1
:goto 1
:goto 2
:lbl 1
:teta +1 -> teta
:M -> M
:L+1 -> L
:L+(M/100) -> C
:if teta > K
:goto 3
:C -> L1(teta+Y
:1 -> [A](L,M
:qoto 1
:lbl 3
:Y+K -> Y
:(L1(X)-int(L1(X)))*100 -> T
:(L1(Y)-int(L1(Y)))*100 -> U
:int(L1(X) -> V
:int(L1(Y) -> Y
:line(T,V,U,S
:storepic 1
:pause
:X+K -> X
:If k=3
:A+1 -> A
:If A=2 and K=3
:4 -> K
:K-1 -> K
:if k<2
:goto 4
:2 -> O
:goto 0
:lbl 2
:1 -> teta
:lbl 5
:L -> L
:M+1 -> M
:L+(M-100) -> C
:teta +1 -> teta
:if teta>k
:goto 3
:C -> L1(teta+y
:1 -> [A](L,M
:goto 5
:lbl 4
:Clrdraw
:RecallPic 2
:Text(5,10,"JE PLACE MES NAVIRES :
:Text(20,13,"BATEAU DE :
:Text(45,40,"PATIENTE ...
:5 -> k
:1 -> A
:lbl 6
:0[C] -> [C]
:1 -> teta
:Text(20,50,k
:Text(20,57,"......
:If A=2
:Text(20,57,"BIS
:randint(1,8) -> l
:randint(1,8) -> m
:randint(1,2) -> x
:If X=1 and M+K>10
:Goto 6
:If X=2 and L+K>10
:Goto 6
:goto 13
:Lbl H
:If X=1
:M+1 -> M
:If X=2
:L+1 -> L
:Lbl 13
:if [B](L,M)=1
:Goto 6
:1 -> [C](L,M)
:teta+1 -> teta
:if teta>K
:Goto 14
:Goto H
:if K=3
:A+1 -> A
:if A=2 and K=3
:4 -> K
:K-1 -> K
:if K<2
:Goto 15
:[B]+[C] -> [B]
:0[C] -> [C]
:clrhome
:Output(1,1,"STRATEGIE ENRE.
:11794591 -> R
:Pause
:Clrhome
:AxesOff
:GridOff
:Return
prgm du jeu proprement dit : "WARSHIPS"
Code
:if r=11794591
:goto M
:prgmWARSHIPS
:lbl M
:clrhome
:output(3,1,"sauvegarde
:output(4,3,"correcte
:for(t,0,150
:end
:{10,10} -> dim([C]
:0[C] -> [C]
:0 -> G
:5 -> A
:0 -> H
:0 -> X
:0 -> I
:0 -> R
:1 -> W
:1 -> N
:1 -> O
:5 -> L3(1
:5 -> L3(2
:clrdraw
:clrhome
:output(4,1,"a toi de
:output(5,4,"commencer !
:for(t,0,200
:end
:lbl a
:L3(1 -> L
:L3(2 -> M
:1 -> teta
:recallpic 2
:lbl N
:getkey -> K
:if K=24
:L-1 ->L
:if L=<1
:1 -> L
:if K=26
:L+1 -> L
:if L>=10
:10 -> L
:if K=25
:M+1 -> M
:if M>=10
:10 -> M
:if K=34
:M-1 -> M
:if M=<1
:1 -> M
:if K=102
:Goto 36
:L -> L3(1
:M -> L3(2
:if k=21
:goto B
:Line(L,M-1,L,M+1
:Line(L-1,M,L+1,M
:For(t,0,25
:end
:Line(L,M-1,L,M+1,0
:Line(L-1,M,L+1,M,0
:recallPic 2
:goto N
:lbl B
:L+(M/100) -> C
:if [B](L,M)=1
:goto C
:if [B](L,M)=0
:goto D
:goto B
:lbl C
:1 -> [B](L,M
:circle(L,M,0.5
:storepic 2
:1 -> teta
:N+1 -> N
:if n=18
:Goto Q
:Goto A
:lbl q
:Clrdraw
:Text(5,20,"MA VENGEANCE
:Text(11,25,"SERA
:text(17,23,"TERRIBLE !
:pause
:Goto 42
:Lbl d
:circle(L,M,0.2
:storepic2
:clrdraw
:text(20,30,"A MOI
:for(t,0,200
:end
:clrdraw
:recallpic 1
:If I#1
:goto H
:L3(3) -> C
:int(C) -> L
:(C-int(C))*100 -> M
:If I=1 and R>1
:Goto 9
:If I=1
:Goto 6
:Lbl H
:randint(1,10) -> L
:randint(1,10) -> M
:Lbl 8
:If [C](L,M)#1
:Goto 1
:If [C](L,M)=1
:Then
:If I#1
:Goto H
:L3(3) -> C
:int(C) -> L
:(C-int(C))*100 -> M
:If I=1 and R>1
:Goto 9
:If I=1
:Goto 6
:End
:Lbl1
:if [A](L,M)=1
:Goto E
:If [A](L,M)=0
:Then
:1 -> [C](L,M)
:Circle(M,L,0.2
:StorePic 1
:Clrdraw
:Text(20,20,"A TOI
:For(T,0,250
:End
:Clrhome
:Clrdraw
:Goto A
:
:Lbl E
:1 -> I
:R+1 -> R
:1 -> [C](L,M
:1 -> [D](L,M
:Circle(M,L,0.5
:StorePic 1
:L+(M/100) -> C
:C -> L3(3
:for(teta,1,17
:If C=L1(teta)
:100 -> L1(teta
:End
:1 -> B
:5 -> A
:5 -> V
:1 -> teta
:Lbl2
:If B=2
:4 -> A
:If L1(teta)#100
:Then
:V+1 -> V
:A-1 -> A
:A+V -> V
:if A=3
:B+1 -> B
:End
:If V>17
:Then
:If R>1
:Goto 7
:Goto 4
:End
:If L1(teta)=100
:teta+1 -> teta
:If teta>V
:Then
:0 -> L1(teta-1
:0 -> R
:0 -> I
:0 -> X
:1 -> teta
:If [D]=[A]
:Goto 48
:RecallPic 1
:Goto H
:End
:Goto 2
:
:Lbl 4
:rndint(1,4) -> X
:
:Lbl 7
:If X=1
:Then
:If L+1>10 and R=<1
:Goto 6
:If L+1>10
:goto 9
:L+1 ->L
:goto 8
:End
:If X=2
:Then
:If L-1<1 and R=<1
:Goto 6
:If L-1<1
:Goto 9
:L-1 ->L
:Goto 8
:End
:If X=3
:Then
:If M+1>10 and R=<1
:Goto 6
:If m+1>10
:Goto 9
:M+1 ->M
:Goto 8
:End
:If X=4
:Then
:If M-1<1 and R=<1
:Goto 6
:If M-1<1
:Goto 9
:m-1 -> M
:Goto 8
:End
:
:Lbl 6
:If X=1 or X=2 or X=3
:Then
:X+1 -> X
:Goto 7
:End
:If X=4
:then
:1 -> X
:Goto 7
:End
:
:Lbl 9
:if X=1
:Then
:2 -> X
:L-R -> L
:Goto 8
:End
:If X=2
:Then
:1 -> X
:L+R -> L
:Goto 8
:End
:If X=3
:Then
:4 -> X
:M-R -> M
:Goto 8
:End
:If X=4
:Then
:3 -> X
:M+R -> R
:
:Lbl 48
:Clrdraw
:Text(20,20,"TOUTE TA FLOTTE
:Text(27,25,"A SOMBRE !
:For(T,0,550
:End
:lbl 36
:1 -> Z
:Lbl 30
:Line(0,Z,11,Z
:For(teta,1,10
:RecallPic 2
:Line(teta,0,teta,11
:If [B](teta,Z)=1
:Then
:circle(teta,Z,0.5
:0 -> [B](teta,Z
:If [B]=0[B]
:Goto 31
:End
:Line(teta,0,teta, 11,0
:RecallPic 2
:End
:Line(0,Z,11,Z,0
:Z+1 -> Z
:Goto 30
:Lbl 31
:Line(teta,0,teta,11,0
:Line(0,Z,11,Z,0
:RecallPic 2
:Pause
:Lbl 42
:Clrhome
:Menu("ON RECOMMENCE ?","OUI",Z,"NON",teta
:Lbl teta
:Stop
:LblZ
:prgmWARENREG
il est certain que les 2 parties forment un gros "pavé" (1591 octets pour la 1ere et 1767 pour la 2eme

) , mais bon ...
PS: il est imperatif de nommer les programmes comme spécifié ( WARENREG et WARSHIPS )
les regle sont toujours les memes :
-pour l'enregistrement:
on deplace avec les pavé multidirectionnel et on valide sur [enter]
on peut changer l'orientation : [2nd] -> vertical
[Alpha] -> horizontal
-pour jouer :
on deplace le curseur avec le pavé et on valide avec [2nd]
on peut abandonner la partie : [0]
voila voila !!
quelques modifications restent encore à faire , mais rien de bien mechant !

( evitez de coller les bateaux directement les uns a coté des autres , pour eviter qql petits soucis passagers , auxquels je cogite une solution !!

)
dites moi ce que vous en pensez !!! ainsi que les problemes que vous rencontrez !
Xeros