Forum Liberty Basic France
• Index
Bonjor à tous, sur ce code :
Code :
Lorsque je ferme la fenetre du jeu ( #main ) j'ai un erreur, why ?
Et de plus est il possible de sauvegarder la partie ? ( et de la reprendre si le joueur le veut ).
J'ai testé le truc de Casiope01 pour sauvegarder dans un fichier texte mais sa marche pas.
J'èspere que quelqu'un pourra éclairer mes lanternes.
Code :
[menu]
button #1, "Jouer", [jeu], UL, 130, 20
button #1, "Aide", About, UL, 135, 60
button #1, "Crédit", [apropos], UL, 129, 100
button #1, "Quitter", [quitter], UL, 125, 140
open "Puissance 4" for graphics_nsb as #1
print #1, "trapclose [quitter]"
wait
[quitter]
s$ = "Voulez vous vraiment quitter ?"
WindowWidth = 384
WindowHeight = 336
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #fermer.frame, "Quitter", 22, 16, 336, 240
statictext #fermer.text, "", 38, 46, 304, 200
button #fermer.default, "Oui", [oui], UL, 50, 270, 122, 25
button #fermer.default, "Non", [non], UL, 200, 270, 122, 25
open "Quitter" for dialog_nf_modal as #fermer
#fermer, "trapclose [aboutOk]"
#fermer, "font ms_sans_serif 10"
#fermer.frame, "!font ms_sans_serif 12"
#fermer.text, s$
wait
[oui]
close #fermer
close #1
end
[non]
close #fermer
wait
[jeu]
close #1
randomize 0.5
dim ROW(12) 'arrays are larger, to hold empty margins
dim B(11,12)'only indices 3-9 are used
global DIFFICULTY : DIFFICULTY = 3 'default difficulty
global MOVE
for i = 1 to 40 : separator$ = separator$+"__" : next
'read texts
global COMPUTERTHINKS
read COMPUTERTHINKS
dim compThink$(COMPUTERTHINKS)
for i = 1 to COMPUTERTHINKS : read a$ : compThink$(i) = a$ : next
global YOURTURN
read YOURTURN
dim makeYourMove$(YOURTURN)
for i = 1 to YOURTURN : read a$ : makeYourMove$(i) = a$ : next
global HUMANWIN
read HUMANWIN
dim youWin$(HUMANWIN)
for i = 1 to HUMANWIN : read a$ : youWin$(i) = a$ : next
global COMPUTERWIN
read COMPUTERWIN
dim compWin$(COMPUTERWIN)
for i = 1 to COMPUTERWIN : read a$ : compWin$(i) = a$ : next
global DRAW
read DRAW
dim drawMessage$(DRAW)
for i = 1 to DRAW : read a$ : drawMessage$(i) = a$ : next
nomainwin
WindowWidth = 552
WindowHeight = 437
UpperLeftX=int((DisplayWidth-WindowWidth)/3)
UpperLeftY=int((DisplayHeight-WindowHeight)/4)
graphicbox #main.graph, 22, 6, 385, 330
button #main.new, "Nouveau jeu", [newGame], UL, 414, 21, 112, 25
button #main.difficulty, "Difficulté", GetDifficulty, UL, 414, 80, 112, 25
button #main.skip, "Démarrer le jeu", [CompStart], UL, 414, 161, 112, 25
statictext #main, separator$, 1, 366, 546, 18
statictext #main.info, "", 4, 385, 548, 18
open "Puissance 4" for window_nf as #main
print #main.graph,"down"
print #main, "trapclose quitter2"
print #main, "font ms_sans_serif 10"
#main.graph "when leftButtonDown RowButton"
' wait
[newGame]
#main.info, "Selectionner le niveau de dificulté ou appuyez sur : démarrer le jeu "
redim ROW(12)
redim B(11,12)
MOVE = 0
call DrawEmptyGrid
for i = 3 to 9
ROW(i) = 2 'row is "empty", 3 is first level
' h$ = "#main.button"+str$(i-2)
' #h$, "!enable" 'enable all buttons
next i
#main.skip, "!enable"
wait
sub GetDifficulty h$
WindowWidth = 208
WindowHeight = 230
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #difficulty, "Selectionnez le niveau de dificulté:", 14, 11, 168, 180
radiobutton #difficulty.rb4, "Très facile", [dummy], [dummy], 38, 41, 72, 20
radiobutton #difficulty.rb2, "Facile", [dummy], [dummy], 38, 66, 48, 20
radiobutton #difficulty.rb3, "Normal", [dummy], [dummy], 38, 91, 64, 20
radiobutton #difficulty.rb1, "Dificile", [dummy], [dummy], 38, 116, 60, 20
button #difficulty.default, "Valider", [difficultyOk], UL, 54, 146, 80, 25
open "Niveau" for dialog_nf_modal as #difficulty
print #difficulty, "trapclose [difficultyOk]"
h$ = "#difficulty.rb"+str$(DIFFICULTY)
#h$, "set"
wait
[dummy]
wait
[difficultyOk]
for i = 1 to 4
h$ = "#difficulty.rb"+str$(i)
#h$, "value? a$"
if a$ = "set" then DIFFICULTY = i
next i
close #difficulty
end sub
[CompStart]
#main.skip, "!disable"
call CompMove DIFFICULTY
wait
sub DrawEmptyGrid
#main.graph, "cls; fill lightgray; color darkgray; size 2"
for i = 1 to 6
#main.graph, "line "; i*55-1; " 0 "; i*55-1; " 384"
next i
for i = 1 to 5
#main.graph, "line 0 "; i*55-1; " 384 "; i*55-1
next i
#main.graph, "flush"
end sub
sub DrawMove x, y
x = x-2
y = 9-y
#main.graph, "place "; x*55-28; " "; y*55-28
#main.graph, "circlefilled 24; flush"
end sub
sub RowButton handle$, mx, my
#main.skip, "!disable"
' n = val(right$(handle$,1))+2
n = int(mx/(385/7))+3
ROW(n) = ROW(n)+1
B(ROW(n), n) = 1
#main.graph, "color darkblue; backcolor darkblue"
MOVE = MOVE+1
call DrawMove n, ROW(n)
'check human move
MOVE = CheckWin(MOVE, 1, ROW(n), n)
if MOVE < 42 then call CompMove DIFFICULTY
MOVE = MOVE+1
end sub
sub quitter2 handle$
s$ = "Voulez vous vraiment quitter ?"
WindowWidth = 384
WindowHeight = 336
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #fermer.frame, "Quitter", 22, 16, 336, 240
statictext #fermer.text, "", 38, 46, 304, 200
button #fermer.default, "Oui", [oui], UL, 50, 270, 122, 25
button #fermer.default, "Non", [non], UL, 200, 270, 122, 25
open "Quitter" for dialog_nf_modal as #fermer
#fermer, "trapclose [aboutOk]"
#fermer, "font ms_sans_serif 10"
#fermer.frame, "!font ms_sans_serif 12"
#fermer.text, s$
wait
[oui]
close #main
end
[non]
close #fermer
end sub
sub About handle$
s$ = "Pour jouer : "
s2$ = "Vous devez selectionner le niveau ou cliquer sur démarrer le jeu."
s3$ = " Puis le but sera d'aligner 4 jetons horizontalement, verticalement ou diagonalement."
s4$ = " Mais gare à l'ordinateur ..."
WindowWidth = 384
WindowHeight = 336
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #about.frame, "Comment jouer", 22, 16, 336, 240
statictext #about.text, "", 38, 46, 304, 200
button #about.default, "Ok", [aboutOk], UL, 126, 270, 122, 25
open "Aide" for dialog_nf_modal as #about
#about, "trapclose [aboutOk]"
#about, "font ms_sans_serif 10"
#about.frame, "!font ms_sans_serif 12"
#about.text, s$ ; s2$ ; s3$ ; s4$
wait
[aboutOk]
close #about
end sub
sub CompMove depth
#main.info, compThink$(int(rnd(1)*COMPUTERTHINKS)+1)
' for i = 1 to 7
' h$ = "#main.button"+str$(i)
' #h$, "!disable"
' next i
n = BestMove(-1, depth)
ROW(n) = ROW(n)+1
B(ROW(n),n) = -1
' for i = 1 to 7
' if ROW(i+2) < 8 then
' h$ = "#main.button"+str$(i)
' ' #h$, "!enable"
' end if
' next i
#main.graph, "color darkred; backcolor darkred"
call DrawMove n, ROW(n)
#main.info, makeYourMove$(int(rnd(1)*YOURTURN)+1)
MOVE = CheckWin(MOVE, -1, ROW(n), n)
end sub
function IsWin$(pl, row, col)
if B(row-1,col)=pl and B(row-2,col)=pl and B(row-3,col)= pl then _
IsWin$ = str$(row-1); col; str$(row-2); col; str$(row-3); col
if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col-3)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col-3)
if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col+1)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col+1)
if B(row,col-1)=pl and B(row,col+1)=pl and B(row,col+2)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col+1); row; str$(col+2)
if B(row,col+1)=pl and B(row,col+2)=pl and B(row,col+3)= pl then _
IsWin$ = IsWin$; row; str$(col+1); row; str$(col+2); row; str$(col+3)
if B(row+3,col-3)=pl and B(row+2,col-2)=pl and B(row+1,col-1)= pl then _
IsWin$ = IsWin$; str$(row+3); str$(col-3); str$(row+2); str$(col-2); str$(row+1); str$(col-1)
if B(row+2,col-2)=pl and B(row+1,col-1)=pl and B(row-1,col+1)= pl then _
IsWin$ = IsWin$; str$(row+2); str$(col-2); str$(row+1); str$(col-1); str$(row-1); str$(col+1)
if B(row+1,col-1)=pl and B(row-1,col+1)=pl and B(row-2,col+2)= pl then _
IsWin$ = IsWin$; str$(row+1); str$(col-1); str$(row-1); str$(col+1); str$(row-2); str$(col+2)
if B(row-1,col+1)=pl and B(row-2,col+2)=pl and B(row-3,col+3)= pl then _
IsWin$ = IsWin$; str$(row-1); str$(col+1); str$(row-2); str$(col+2); str$(row-3); str$(col+3)
if B(row-3,col-3)=pl and B(row-2,col-2)=pl and B(row-1,col-1)= pl then _
IsWin$ = IsWin$; str$(row-3); str$(col-3); str$(row-2); str$(col-2); str$(row-1); str$(col-1)
if B(row-2,col-2)=pl and B(row-1,col-1)=pl and B(row+1,col+1)= pl then _
IsWin$ = IsWin$; str$(row-2); str$(col-2); str$(row-1); str$(col-1); str$(row+1); str$(col+1)
if B(row-1,col-1)=pl and B(row+1,col+1)=pl and B(row+2,col+2)= pl then _
IsWin$ = IsWin$; str$(row-1); str$(col-1); str$(row+1); str$(col+1); str$(row+2); str$(col+2)
if B(row+1,col+1)=pl and B(row+2,col+2)=pl and B(row+3,col+3)= pl then _
IsWin$ = IsWin$; str$(row+1); str$(col+1); str$(row+2); str$(col+2); str$(row+3); str$(col+3)
if IsWin$ <> "" then IsWin$ = str$(row); str$(col); IsWin$
end function
function CheckWin(CheckWin, player, row, col)
s$ = IsWin$(player, row, col)
if s$ <> "" then
CheckWin = 42
if player = 1 then
#main.info, youWin$(int(rnd(1)*HUMANWIN)+1)
#main.graph, "color blue; backcolor blue"
else
#main.info, compWin$(int(rnd(1)*COMPUTERWIN)+1)
#main.graph, "color red; backcolor red"
end if
for i = 1 to len(s$) step 2
x = val(mid$(s$, i, 1))
y = val(mid$(s$, i+1, 1))
call DrawMove y, x
next i
else
if CheckWin = 42 then #main.info, drawMessage$(int(rnd(1)*DRAW)+1)
end if
' if CheckWin = 42 then
' for i = 1 to 7
' h$ = "#main.button"+str$(i)
' ' #h$, "!disable"
' next i
' end if
end function
function GetValue(player, depth, row, column)
pl = -1*player
if (B(row-1,column)=pl and B(row-2,column)=pl and B(row-3,column)= pl) or _
(B(row,column-1)=pl and B(row,column-2)=pl and B(row,column-3)= pl) or _
(B(row,column-1)=pl and B(row,column-2)=pl and B(row,column+1)= pl) or _
(B(row,column-1)=pl and B(row,column+1)=pl and B(row,column+2)= pl) or _
(B(row,column+1)=pl and B(row,column+2)=pl and B(row,column+3)= pl) or _
(B(row+3,column-3)=pl and B(row+2,column-2)=pl and B(row+1,column-1)= pl) or _
(B(row+2,column-2)=pl and B(row+1,column-1)=pl and B(row-1,column+1)= pl) or _
(B(row+1,column-1)=pl and B(row-1,column+1)=pl and B(row-2,column+2)= pl) or _
(B(row-1,column+1)=pl and B(row-2,column+2)=pl and B(row-3,column+3)= pl) or _
(B(row-3,column-3)=pl and B(row-2,column-2)=pl and B(row-1,column-1)= pl) or _
(B(row-2,column-2)=pl and B(row-1,column-1)=pl and B(row+1,column+1)= pl) or _
(B(row-1,column-1)=pl and B(row+1,column+1)=pl and B(row+2,column+2)= pl) or _
(B(row+1,column+1)=pl and B(row+2,column+2)=pl and B(row+3,column+3)= pl) then
GetValue = -128
else
if depth = 0 then exit function
GetValue = -1000
for i = 3 to 9
if ROW(i) < 8 then
ROW(i) = ROW(i)+1
B(ROW(i), i) = player
value = -1*GetValue(-1*player, depth-1, ROW(i), i)/2
B(ROW(i), i) = 0
ROW(i) = ROW(i)-1
if value > GetValue then
GetValue = value
if value = 64 then exit for
end if
end if
next i
end if
end function
function BestMove(player, depth)
max = -1000
for i = 3 to 9
if ROW(i) < 8 then
ROW(i) = ROW(i)+1
B(ROW(i),i) = player
value = -1*GetValue(-1*player, depth, ROW(i), i)
B(ROW(i), i) = 0
ROW(i) = ROW(i)-1
if value > max then
max = value
BestList$ = str$(i)
if max = 128 then exit for
else
if value = max then BestList$ = BestList$+str$(i)
end if
end if
next i
'print BestList$, max
BestMove = val(mid$(BestList$, int(rnd(1)*len(BestList$))+1, 1))
end function
data 9
data "Hmm... Laisse moi réfléchir"
data "Tu joues bien, Je le sais !"
data "Je le sais, je vais gagner, laisse moi juste réfléchir."
data "Silence ! Je réfléchis"
data "Ne me frappe pas !"
data "Silence s'il vous plait, je gagne."
data "Je suis sur... je pense... dur..."
data "Alors tu n'y arrive pas ? x)"
data "Arrete d'aller trop vite, je ne suis plus."
data 8
data "Je ne crains rien! Donne-moi ton meilleur coup !"
data "Réveillez-moi quand vous êtes prêt à jouer."
data "Montrez-moi ce que tu sais faire! "
data "Prouve-moi que tu es le meilleur !"
data "Je vais prendre une petite sieste pendant que vous comprendre cela !"
data "Réfléchissez bien! Une petite erreur et vous avez terminé !"
data "Vous pensez que ce n'est un tirage au sort ? "
data "Je ne le crois pas! "
data "Prenez votre temps."
data 11
data "Un grand bravo au gagnant du jeu !"
data "Cela devrait vous donner une leçon. Vous ne gagnerais JAMAIS avec moi !"
data "Vous avez perdu !"
data "Nous pouvons jouer un autre partie, mais vous allez encore perdre ..."
data "Je parie que vous n'avez pas vu que vous venez de perdre ."
data "Nous ne pouvons rester amis !"
data "Ouch! çà doit faire mal !"
data "Alors, qu'est-ce que tu fais ce soir ? Tu perds ?"
data "Mesdames et Messieurs, nous avons un gagnant. Devinez qui!"
data "C'est une autre victoire question-sur-esprit ..."
data "Je suis le roi du monde ."
data 8
data "J'offre un rêve ."
data "Dessine! Pourtant, vous étiez si proches ..."
data "Vous m'avez mis sous beaucoup de pression, mais vous ne pouviez pas me casser!"
data "Fait Nouveau Jeu maintenant ! Nous devons savoir qui est le meilleur. "
data "Euh, que c'est il passé ?"
data "Je leur ai dit que nous allions avoir besoin d'une plus grande carte pour cela."
data "Il faut que je change mon CPU ..."
data "Je vous promets, la prochaine fois je ne vais pas te laisser partir si facilement."
[apropos]
s$ = "Version : 1.0"
s2$ = " Traduis et amélioré par alex877 "
WindowWidth = 384
WindowHeight = 336
groupbox #about2.frame, "Version/Editeur", 22, 16, 336, 240
statictext #about2.text, "", 38, 46, 304, 200
button #about2.default, "Ok", [about2Ok], UL, 126, 270, 122, 25
open "A propos" for dialog_nf_modal as #about2
#about2, "trapclose [aboutOk]"
#about2, "font ms_sans_serif 10"
#about2.frame, "!font ms_sans_serif 12"
#about2.text, s$ ; s2$
wait
[about2Ok]
close #about2
close #1
Lorsque je ferme la fenetre du jeu ( #main ) j'ai un erreur, why ?
Et de plus est il possible de sauvegarder la partie ? ( et de la reprendre si le joueur le veut ).
J'ai testé le truc de Casiope01 pour sauvegarder dans un fichier texte mais sa marche pas.
J'èspere que quelqu'un pourra éclairer mes lanternes.
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
A oui et : est il possible de mettre une image en fond de la premiere fenetre ?
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Premier avis de l'expert newbee:
Pourquoi une dialog modal...modal veut dire que cette fenetre prédomine sur les autres
comme l'est une fenetre d'exploration de fichiers ( ouvrir/enregistrer...ext)
Une fenetre window ferait aussi bien l'affaire
D'aprés moi, ce "open "Puissance 4" for graphics_nsb as #1" dans ton menu joue les trouble fete. Puisqu'il appartient déjà au jeu lui-meme.
open menu for window ,serait mieux parce que for graphic n'aime pas trop contenir des controles (boutons...ext)
graphic, c'est bon pour des dessins et des sprites
Je me doute que tu a mis tout ce bazar pour le tester, mais ça fait beaucoup en meme temps.....à+
Pourquoi une dialog modal...modal veut dire que cette fenetre prédomine sur les autres
comme l'est une fenetre d'exploration de fichiers ( ouvrir/enregistrer...ext)
Une fenetre window ferait aussi bien l'affaire
D'aprés moi, ce "open "Puissance 4" for graphics_nsb as #1" dans ton menu joue les trouble fete. Puisqu'il appartient déjà au jeu lui-meme.
open menu for window ,serait mieux parce que for graphic n'aime pas trop contenir des controles (boutons...ext)
graphic, c'est bon pour des dessins et des sprites
Je me doute que tu a mis tout ce bazar pour le tester, mais ça fait beaucoup en meme temps.....à+
____________________
Roro
Roro
Recompte le nombre de blocs de messages data : tu en as oublié 1 et l'un d'entre eux n'a pas le bon nombre de ligne.
Tes radiobutton sont inversés. Ce qui fait que le 4 est le 1 etc...
Tu fabriques des fenêtres de confirmation sans avoir regardé si ça n'existait pas déjà tout fait en JB.
Cherche "Built-in Dialogs" dans l'aide.
Roland a raison pour la windows graphic qui n'est pas spécialement à l'aise avec les boutons et autres contrôles.
alex877:
à quel endroit ça ne marche pas ?
Il te faut comprendre d'abord quoi sauvegarder !
Le bouton "Démarrer le Jeu" ne me semble vraiment pas utile.
Pour mettre une image de fond, il te faudrait fabriquer et gérer des sprites. Regarde l'aide à ce sujet.
Edité par cassiope01 Le 03/08/2012 à 06h53
Tes radiobutton sont inversés. Ce qui fait que le 4 est le 1 etc...
Tu fabriques des fenêtres de confirmation sans avoir regardé si ça n'existait pas déjà tout fait en JB.
Cherche "Built-in Dialogs" dans l'aide.
Roland a raison pour la windows graphic qui n'est pas spécialement à l'aise avec les boutons et autres contrôles.
alex877:
Bonjor à tous, sur ce code :
J'ai testé le truc de Cassiope01 pour sauvegarder dans un fichier texte mais sa marche pas.
J'ai testé le truc de Cassiope01 pour sauvegarder dans un fichier texte mais sa marche pas.
à quel endroit ça ne marche pas ?
Il te faut comprendre d'abord quoi sauvegarder !
Le bouton "Démarrer le Jeu" ne me semble vraiment pas utile.
Pour mettre une image de fond, il te faudrait fabriquer et gérer des sprites. Regarde l'aide à ce sujet.
Edité par cassiope01 Le 03/08/2012 à 06h53
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Web
Citation:
J'ai testé ton système de sauvegarde mais il ne se passe rien.
Pour le reste, je vais aller tester et je vous diras ce qu'il en découle .
++
à quel endroit ça ne marche pas ?
J'ai testé ton système de sauvegarde mais il ne se passe rien.
Pour le reste, je vais aller tester et je vous diras ce qu'il en découle .
++
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Alex fait comme moi, il teste un peu tous azimuth.
Conseil pour Alex: teste les trucs un par un , c'est plus facile pour voir ce qui ne va pas.
Conseil pour Alex: teste les trucs un par un , c'est plus facile pour voir ce qui ne va pas.
____________________
Roro
Roro
Ok merci de conseil je vais m'empresser de l'utiliser .
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Citation:
En fait je suis partis d'un exemple fournis avec Just Basic pour réaliser le menu d'ou Code :
Citation:
Citation:
Citation:
Je me doute que tu a mis tout ce bazar pour le tester, mais ça fait beaucoup en meme temps.....à+
En fait je suis partis d'un exemple fournis avec Just Basic pour réaliser le menu d'ou Code :
open "Puissance 4" for graphics_nsb as #1
Citation:
Tes radiobutton sont inversés. Ce qui fait que le 4 est le 1 etc...
fait exprès car sinon on a l'impression que le "très facile" est plus dur que le "dur" .Citation:
Tu fabriques des fenêtres de confirmation sans avoir regardé si ça n'existait pas déjà tout fait en JB.
Cherche "Built-in Dialogs" dans l'aide.
Là c'était surtout pour tester et comprendre le fonctionnement .Cherche "Built-in Dialogs" dans l'aide.
Citation:
Pour mettre une image de fond, il te faudrait fabriquer et gérer des sprites. Regarde l'aide à ce sujet.
C'est plus simple de mettre une couleur .
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Et le code :
Code :
Code :
[menu]
button #1, "Jouer", [jeu], UL, 130, 20
button #1, "Aide", About, UL, 135, 60
button #1, "Crédit", [apropos], UL, 129, 100
button #1, "Quitter", [quitter], UL, 125, 140
open "Menu" for window_nf as #1
print #1, "trapclose [quitter]"
wait
[quitter]
s$ = "Voulez vous vraiment quitter ?"
WindowWidth = 384
WindowHeight = 336
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #fermer.frame, "Quitter", 22, 16, 336, 240
statictext #fermer.text, "", 38, 46, 304, 200
button #fermer.default, "Oui", [oui], UL, 50, 270, 122, 25
button #fermer.default, "Non", [non], UL, 200, 270, 122, 25
open "Quitter" for dialog_nf_modal as #fermer
#fermer, "trapclose [aboutOk]"
#fermer, "font ms_sans_serif 10"
#fermer.frame, "!font ms_sans_serif 12"
#fermer.text, s$
wait
[oui]
close #fermer
close #1
end
[non]
close #fermer
wait
[jeu]
close #1
randomize 0.5
dim ROW(12) 'arrays are larger, to hold empty margins
dim B(11,12)'only indices 3-9 are used
global DIFFICULTY : DIFFICULTY = 3 'default difficulty
global MOVE
for i = 1 to 40 : separator$ = separator$+"__" : next
'read texts
global COMPUTERTHINKS
read COMPUTERTHINKS
dim compThink$(COMPUTERTHINKS)
for i = 1 to COMPUTERTHINKS : read a$ : compThink$(i) = a$ : next
global YOURTURN
read YOURTURN
dim makeYourMove$(YOURTURN)
for i = 1 to YOURTURN : read a$ : makeYourMove$(i) = a$ : next
global HUMANWIN
read HUMANWIN
dim youWin$(HUMANWIN)
for i = 1 to HUMANWIN : read a$ : youWin$(i) = a$ : next
global COMPUTERWIN
read COMPUTERWIN
dim compWin$(COMPUTERWIN)
for i = 1 to COMPUTERWIN : read a$ : compWin$(i) = a$ : next
global DRAW
read DRAW
dim drawMessage$(DRAW)
for i = 1 to DRAW : read a$ : drawMessage$(i) = a$ : next
nomainwin
WindowWidth = 552
WindowHeight = 437
UpperLeftX=int((DisplayWidth-WindowWidth)/3)
UpperLeftY=int((DisplayHeight-WindowHeight)/4)
graphicbox #main.graph, 22, 6, 385, 330
button #main.new, "Nouveau jeu", [newGame], UL, 414, 21, 112, 25
button #main.difficulty, "Difficulté", GetDifficulty, UL, 414, 80, 112, 25
button #main.skip, "Démarrer le jeu", [CompStart], UL, 414, 161, 112, 25
statictext #main, separator$, 1, 366, 546, 18
statictext #main.info, "", 4, 385, 548, 18
open "Puissance 4" for window_nf as #main
print #main.graph,"down"
print #main, "trapclose quitter2"
print #main, "font ms_sans_serif 10"
#main.graph "when leftButtonDown RowButton"
' wait
[newGame]
#main.info, "Selectionner le niveau de dificulté ou appuyez sur : démarrer le jeu "
redim ROW(12)
redim B(11,12)
MOVE = 0
call DrawEmptyGrid
for i = 3 to 9
ROW(i) = 2 'row is "empty", 3 is first level
' h$ = "#main.button"+str$(i-2)
' #h$, "!enable" 'enable all buttons
next i
#main.skip, "!enable"
wait
sub GetDifficulty h$
WindowWidth = 208
WindowHeight = 230
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #difficulty, "Selectionnez le niveau de dificulté:", 14, 11, 168, 180
radiobutton #difficulty.rb4, "Très facile", [dummy], [dummy], 38, 41, 72, 20
radiobutton #difficulty.rb2, "Facile", [dummy], [dummy], 38, 66, 48, 20
radiobutton #difficulty.rb3, "Normal", [dummy], [dummy], 38, 91, 64, 20
radiobutton #difficulty.rb1, "Dificile", [dummy], [dummy], 38, 116, 60, 20
button #difficulty.default, "Valider", [difficultyOk], UL, 54, 146, 80, 25
open "Niveau" for dialog_nf_modal as #difficulty
print #difficulty, "trapclose [difficultyOk]"
h$ = "#difficulty.rb"+str$(DIFFICULTY)
#h$, "set"
wait
[dummy]
wait
[difficultyOk]
for i = 1 to 4
h$ = "#difficulty.rb"+str$(i)
#h$, "value? a$"
if a$ = "set" then DIFFICULTY = i
next i
close #difficulty
end sub
[CompStart]
#main.skip, "!disable"
call CompMove DIFFICULTY
wait
sub DrawEmptyGrid
#main.graph, "cls; fill lightgray; color darkgray; size 2"
for i = 1 to 6
#main.graph, "line "; i*55-1; " 0 "; i*55-1; " 384"
next i
for i = 1 to 5
#main.graph, "line 0 "; i*55-1; " 384 "; i*55-1
next i
#main.graph, "flush"
end sub
sub DrawMove x, y
x = x-2
y = 9-y
#main.graph, "place "; x*55-28; " "; y*55-28
#main.graph, "circlefilled 24; flush"
end sub
sub RowButton handle$, mx, my
#main.skip, "!disable"
' n = val(right$(handle$,1))+2
n = int(mx/(385/7))+3
ROW(n) = ROW(n)+1
B(ROW(n), n) = 1
#main.graph, "color darkblue; backcolor darkblue"
MOVE = MOVE+1
call DrawMove n, ROW(n)
'check human move
MOVE = CheckWin(MOVE, 1, ROW(n), n)
if MOVE < 42 then call CompMove DIFFICULTY
MOVE = MOVE+1
end sub
sub quitter2 handle$
s$ = "Voulez vous vraiment quitter ?"
WindowWidth = 384
WindowHeight = 336
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #fermer.frame, "Quitter", 22, 16, 336, 240
statictext #fermer.text, "", 38, 46, 304, 200
button #fermer.default, "Oui", [oui], UL, 50, 270, 122, 25
button #fermer.default, "Non", [non], UL, 200, 270, 122, 25
open "Quitter" for dialog_nf_modal as #fermer
#fermer, "trapclose [aboutOk]"
#fermer, "font ms_sans_serif 10"
#fermer.frame, "!font ms_sans_serif 12"
#fermer.text, s$
wait
[oui]
close #main
end
[non]
close #fermer
end sub
sub About handle$
s$ = "Pour jouer : "
s2$ = "Vous devez selectionner le niveau ou cliquer sur démarrer le jeu."
s3$ = " Puis le but sera d'aligner 4 jetons horizontalement, verticalement ou diagonalement."
s4$ = " Mais gare à l'ordinateur ..."
WindowWidth = 384
WindowHeight = 336
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #about.frame, "Comment jouer", 22, 16, 336, 240
statictext #about.text, "", 38, 46, 304, 200
button #about.default, "Ok", [aboutOk], UL, 126, 270, 122, 25
open "Aide" for dialog_nf_modal as #about
#about, "trapclose [aboutOk]"
#about, "font ms_sans_serif 10"
#about.frame, "!font ms_sans_serif 12"
#about.text, s$ ; s2$ ; s3$ ; s4$
wait
[aboutOk]
close #about
end sub
sub CompMove depth
#main.info, compThink$(int(rnd(1)*COMPUTERTHINKS)+1)
' for i = 1 to 7
' h$ = "#main.button"+str$(i)
' #h$, "!disable"
' next i
n = BestMove(-1, depth)
ROW(n) = ROW(n)+1
B(ROW(n),n) = -1
' for i = 1 to 7
' if ROW(i+2) < 8 then
' h$ = "#main.button"+str$(i)
' ' #h$, "!enable"
' end if
' next i
#main.graph, "color darkred; backcolor darkred"
call DrawMove n, ROW(n)
#main.info, makeYourMove$(int(rnd(1)*YOURTURN)+1)
MOVE = CheckWin(MOVE, -1, ROW(n), n)
end sub
function IsWin$(pl, row, col)
if B(row-1,col)=pl and B(row-2,col)=pl and B(row-3,col)= pl then _
IsWin$ = str$(row-1); col; str$(row-2); col; str$(row-3); col
if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col-3)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col-3)
if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col+1)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col+1)
if B(row,col-1)=pl and B(row,col+1)=pl and B(row,col+2)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col+1); row; str$(col+2)
if B(row,col+1)=pl and B(row,col+2)=pl and B(row,col+3)= pl then _
IsWin$ = IsWin$; row; str$(col+1); row; str$(col+2); row; str$(col+3)
if B(row+3,col-3)=pl and B(row+2,col-2)=pl and B(row+1,col-1)= pl then _
IsWin$ = IsWin$; str$(row+3); str$(col-3); str$(row+2); str$(col-2); str$(row+1); str$(col-1)
if B(row+2,col-2)=pl and B(row+1,col-1)=pl and B(row-1,col+1)= pl then _
IsWin$ = IsWin$; str$(row+2); str$(col-2); str$(row+1); str$(col-1); str$(row-1); str$(col+1)
if B(row+1,col-1)=pl and B(row-1,col+1)=pl and B(row-2,col+2)= pl then _
IsWin$ = IsWin$; str$(row+1); str$(col-1); str$(row-1); str$(col+1); str$(row-2); str$(col+2)
if B(row-1,col+1)=pl and B(row-2,col+2)=pl and B(row-3,col+3)= pl then _
IsWin$ = IsWin$; str$(row-1); str$(col+1); str$(row-2); str$(col+2); str$(row-3); str$(col+3)
if B(row-3,col-3)=pl and B(row-2,col-2)=pl and B(row-1,col-1)= pl then _
IsWin$ = IsWin$; str$(row-3); str$(col-3); str$(row-2); str$(col-2); str$(row-1); str$(col-1)
if B(row-2,col-2)=pl and B(row-1,col-1)=pl and B(row+1,col+1)= pl then _
IsWin$ = IsWin$; str$(row-2); str$(col-2); str$(row-1); str$(col-1); str$(row+1); str$(col+1)
if B(row-1,col-1)=pl and B(row+1,col+1)=pl and B(row+2,col+2)= pl then _
IsWin$ = IsWin$; str$(row-1); str$(col-1); str$(row+1); str$(col+1); str$(row+2); str$(col+2)
if B(row+1,col+1)=pl and B(row+2,col+2)=pl and B(row+3,col+3)= pl then _
IsWin$ = IsWin$; str$(row+1); str$(col+1); str$(row+2); str$(col+2); str$(row+3); str$(col+3)
if IsWin$ <> "" then IsWin$ = str$(row); str$(col); IsWin$
end function
function CheckWin(CheckWin, player, row, col)
s$ = IsWin$(player, row, col)
if s$ <> "" then
CheckWin = 42
if player = 1 then
#main.info, youWin$(int(rnd(1)*HUMANWIN)+1)
#main.graph, "color blue; backcolor blue"
else
#main.info, compWin$(int(rnd(1)*COMPUTERWIN)+1)
#main.graph, "color red; backcolor red"
end if
for i = 1 to len(s$) step 2
x = val(mid$(s$, i, 1))
y = val(mid$(s$, i+1, 1))
call DrawMove y, x
next i
else
if CheckWin = 42 then #main.info, drawMessage$(int(rnd(1)*DRAW)+1)
end if
' if CheckWin = 42 then
' for i = 1 to 7
' h$ = "#main.button"+str$(i)
' ' #h$, "!disable"
' next i
' end if
end function
function GetValue(player, depth, row, column)
pl = -1*player
if (B(row-1,column)=pl and B(row-2,column)=pl and B(row-3,column)= pl) or _
(B(row,column-1)=pl and B(row,column-2)=pl and B(row,column-3)= pl) or _
(B(row,column-1)=pl and B(row,column-2)=pl and B(row,column+1)= pl) or _
(B(row,column-1)=pl and B(row,column+1)=pl and B(row,column+2)= pl) or _
(B(row,column+1)=pl and B(row,column+2)=pl and B(row,column+3)= pl) or _
(B(row+3,column-3)=pl and B(row+2,column-2)=pl and B(row+1,column-1)= pl) or _
(B(row+2,column-2)=pl and B(row+1,column-1)=pl and B(row-1,column+1)= pl) or _
(B(row+1,column-1)=pl and B(row-1,column+1)=pl and B(row-2,column+2)= pl) or _
(B(row-1,column+1)=pl and B(row-2,column+2)=pl and B(row-3,column+3)= pl) or _
(B(row-3,column-3)=pl and B(row-2,column-2)=pl and B(row-1,column-1)= pl) or _
(B(row-2,column-2)=pl and B(row-1,column-1)=pl and B(row+1,column+1)= pl) or _
(B(row-1,column-1)=pl and B(row+1,column+1)=pl and B(row+2,column+2)= pl) or _
(B(row+1,column+1)=pl and B(row+2,column+2)=pl and B(row+3,column+3)= pl) then
GetValue = -128
else
if depth = 0 then exit function
GetValue = -1000
for i = 3 to 9
if ROW(i) < 8 then
ROW(i) = ROW(i)+1
B(ROW(i), i) = player
value = -1*GetValue(-1*player, depth-1, ROW(i), i)/2
B(ROW(i), i) = 0
ROW(i) = ROW(i)-1
if value > GetValue then
GetValue = value
if value = 64 then exit for
end if
end if
next i
end if
end function
function BestMove(player, depth)
max = -1000
for i = 3 to 9
if ROW(i) < 8 then
ROW(i) = ROW(i)+1
B(ROW(i),i) = player
value = -1*GetValue(-1*player, depth, ROW(i), i)
B(ROW(i), i) = 0
ROW(i) = ROW(i)-1
if value > max then
max = value
BestList$ = str$(i)
if max = 128 then exit for
else
if value = max then BestList$ = BestList$+str$(i)
end if
end if
next i
'print BestList$, max
BestMove = val(mid$(BestList$, int(rnd(1)*len(BestList$))+1, 1))
end function
data 9
data "Hmm... Laisse moi réfléchir"
data "Tu joues bien, Je le sais !"
data "Je le sais, je vais gagner, laisse moi juste réfléchir."
data "Silence ! Je réfléchis"
data "Ne me frappe pas !"
data "Silence s'il vous plait, je gagne."
data "Je suis sur... je pense... dur..."
data "Alors tu n'y arrive pas ? x)"
data "Arrete d'aller trop vite, je ne suis plus."
data 8
data "Je ne crains rien! Donne-moi ton meilleur coup !"
data "Réveillez-moi quand vous êtes prêt à jouer."
data "Montrez-moi ce que tu sais faire! "
data "Prouve-moi que tu es le meilleur !"
data "Je vais prendre une petite sieste pendant que vous comprendre cela !"
data "Réfléchissez bien! Une petite erreur et vous avez terminé !"
data "Vous pensez que ce n'est un tirage au sort ? "
data "Je ne le crois pas! "
data "Prenez votre temps."
data 11
data "Un grand bravo au gagnant du jeu !"
data "Cela devrait vous donner une leçon. Vous ne gagnerais JAMAIS avec moi !"
data "Vous avez perdu !"
data "Nous pouvons jouer un autre partie, mais vous allez encore perdre ..."
data "Je parie que vous n'avez pas vu que vous venez de perdre ."
data "Nous ne pouvons rester amis !"
data "Ouch! çà doit faire mal !"
data "Alors, qu'est-ce que tu fais ce soir ? Tu perds ?"
data "Mesdames et Messieurs, nous avons un gagnant. Devinez qui!"
data "C'est une autre victoire question-sur-esprit ..."
data "Je suis le roi du monde ."
data 8
data "J'offre un rêve ."
data "Dessine! Pourtant, vous étiez si proches ..."
data "Vous m'avez mis sous beaucoup de pression, mais vous ne pouviez pas me casser!"
data "Fait Nouveau Jeu maintenant ! Nous devons savoir qui est le meilleur. "
data "Euh, que c'est il passé ?"
data "Je leur ai dit que nous allions avoir besoin d'une plus grande carte pour cela."
data "Il faut que je change mon CPU ..."
data "Je vous promets, la prochaine fois je ne vais pas te laisser partir si facilement."
[apropos]
s$ = "Version : 1.0"
s2$ = " Traduis et amélioré par alex877 "
WindowWidth = 384
WindowHeight = 336
groupbox #about2.frame, "Version/Editeur", 22, 16, 336, 240
statictext #about2.text, "", 38, 46, 304, 200
button #about2.default, "Ok", [about2Ok], UL, 126, 270, 122, 25
open "A propos" for dialog_nf_modal as #about2
#about2, "trapclose [aboutOk]"
#about2, "font ms_sans_serif 10"
#about2.frame, "!font ms_sans_serif 12"
#about2.text, s$ ; s2$
wait
[about2Ok]
close #about2
close #1
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Et bien finalement j'ai résolus le problème de l'erreur de la fermeture ( je crois que c'étais à cause de la non-fermeture d'une fenêtre mais c'est réparé . )
Mais je n'arrive pas à faire le système de sauvegarde et de chargement .
Voilà le code corrigé :
Code :
J'espère que vous pourrez m'aider .
a +
Mais je n'arrive pas à faire le système de sauvegarde et de chargement .
Voilà le code corrigé :
Code :
[menu]
button #1, "Jouer", [jeu], UL, 130, 20
button #1, "Charger partie", [load], UL, 100, 50
button #1, "Aide", About, UL, 135, 80
button #1, "Crédit", [apropos], UL, 130, 110
button #1, "Quitter", [quitter], UL, 127, 140
open "Menu" for window_nf as #1
print #1, "trapclose [quitter]"
wait
[quitter]
s$ = "Voulez vous vraiment quitter ?"
WindowWidth = 384
WindowHeight = 336
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #fermer.frame, "Quitter", 22, 16, 336, 240
statictext #fermer.text, "", 38, 46, 304, 200
button #fermer.default, "Oui", [oui], UL, 50, 270, 122, 25
button #fermer.default, "Non", [non], UL, 200, 270, 122, 25
open "Quitter" for dialog_nf_modal as #fermer
#fermer, "trapclose [aboutOk]"
#fermer, "font ms_sans_serif 10"
#fermer.frame, "!font ms_sans_serif 12"
#fermer.text, s$
wait
[oui]
close #fermer
close #1
end
[non]
close #fermer
wait
[jeu]
close #1
randomize 0.5
dim ROW(12) 'arrays are larger, to hold empty margins
dim B(11,12)'only indices 3-9 are used
global DIFFICULTY : DIFFICULTY = 3 'default difficulty
global MOVE
for i = 1 to 40 : separator$ = separator$+"__" : next
'read texts
global COMPUTERTHINKS
read COMPUTERTHINKS
dim compThink$(COMPUTERTHINKS)
for i = 1 to COMPUTERTHINKS : read a$ : compThink$(i) = a$ : next
global YOURTURN
read YOURTURN
dim makeYourMove$(YOURTURN)
for i = 1 to YOURTURN : read a$ : makeYourMove$(i) = a$ : next
global HUMANWIN
read HUMANWIN
dim youWin$(HUMANWIN)
for i = 1 to HUMANWIN : read a$ : youWin$(i) = a$ : next
global COMPUTERWIN
read COMPUTERWIN
dim compWin$(COMPUTERWIN)
for i = 1 to COMPUTERWIN : read a$ : compWin$(i) = a$ : next
global DRAW
read DRAW
dim drawMessage$(DRAW)
for i = 1 to DRAW : read a$ : drawMessage$(i) = a$ : next
nomainwin
WindowWidth = 552
WindowHeight = 437
UpperLeftX=int((DisplayWidth-WindowWidth)/3)
UpperLeftY=int((DisplayHeight-WindowHeight)/4)
graphicbox #main.graph, 22, 6, 385, 330
button #main.new, "Nouveau jeu", [newGame], UL, 414, 21, 112, 25
button #main.new, "Sauvegarder", [sauver], UL, 414, 50, 112, 25
button #main.difficulty, "Difficulté", [dificile], UL, 414, 80, 112, 25
button #main.skip, "Démarrer le jeu", [CompStart], UL, 414, 110, 112, 25
statictext #main, separator$, 1, 366, 546, 18
statictext #main.info, "", 4, 385, 548, 18
open "Puissance 4" for window_nf as #main
print #main.graph,"down"
print #main, "trapclose quitter2"
print #main, "font ms_sans_serif 10"
#main.graph "when leftButtonDown RowButton"
' wait
[newGame]
#main.info, "Selectionner le niveau de dificulté ou appuyez sur : démarrer le jeu "
redim ROW(12)
redim B(11,12)
MOVE = 0
call DrawEmptyGrid
for i = 3 to 9
ROW(i) = 2 'row is "empty", 3 is first level
' h$ = "#main.button"+str$(i-2)
' #h$, "!enable" 'enable all buttons
next i
#main.skip, "!enable"
wait
[dificile]
WindowWidth = 208
WindowHeight = 230
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #difficulty, "Selectionnez le niveau de dificulté:", 14, 11, 168, 180
radiobutton #difficulty.rb4, "Très facile", [dummy], [dummy], 38, 41, 72, 20
radiobutton #difficulty.rb2, "Facile", [dummy], [dummy], 38, 66, 48, 20
radiobutton #difficulty.rb3, "Normal", [dummy], [dummy], 38, 91, 64, 20
radiobutton #difficulty.rb1, "Dificile", [dummy], [dummy], 38, 116, 60, 20
button #difficulty.default, "Valider", [difficultyOk], UL, 54, 146, 80, 25
open "Niveau" for dialog_nf_modal as #difficulty
print #difficulty, "trapclose [difficultyOk]"
h$ = "#difficulty.rb"+str$(DIFFICULTY)
#h$, "set"
wait
[dummy]
wait
[difficultyOk]
for i = 1 to 4
h$ = "#difficulty.rb"+str$(i)
#h$, "value? a$"
if a$ = "set" then DIFFICULTY = i
next i
close #difficulty
[CompStart]
#main.skip, "!disable"
call CompMove DIFFICULTY
wait
sub DrawEmptyGrid
#main.graph, "cls; fill lightgray; color darkgray; size 2"
for i = 1 to 6
#main.graph, "line "; i*55-1; " 0 "; i*55-1; " 384"
next i
for i = 1 to 5
#main.graph, "line 0 "; i*55-1; " 384 "; i*55-1
next i
#main.graph, "flush"
end sub
sub DrawMove x, y
x = x-2
y = 9-y
#main.graph, "place "; x*55-28; " "; y*55-28
#main.graph, "circlefilled 24; flush"
end sub
sub RowButton handle$, mx, my
#main.skip, "!disable"
' n = val(right$(handle$,1))+2
n = int(mx/(385/7))+3
ROW(n) = ROW(n)+1
B(ROW(n), n) = 1
#main.graph, "color darkblue; backcolor darkblue"
MOVE = MOVE+1
call DrawMove n, ROW(n)
'check human move
MOVE = CheckWin(MOVE, 1, ROW(n), n)
if MOVE < 42 then call CompMove DIFFICULTY
MOVE = MOVE+1
end sub
sub quitter2 handle$
s$ = "Voulez vous vraiment quitter ?"
WindowWidth = 384
WindowHeight = 336
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #fermer.frame, "Quitter", 22, 16, 336, 240
statictext #fermer.text, "", 38, 46, 304, 200
button #fermer.default, "Oui", [oui], UL, 50, 270, 122, 25
button #fermer.default, "Non", [non], UL, 200, 270, 122, 25
open "Quitter" for dialog_nf_modal as #fermer
#fermer, "trapclose [aboutOk]"
#fermer, "font ms_sans_serif 10"
#fermer.frame, "!font ms_sans_serif 12"
#fermer.text, s$
wait
[oui]
close #fermer
close #main
end
[non]
close #fermer
end sub
sub About handle$
s$ = "Pour jouer : "
s2$ = "Vous devez selectionner le niveau ou cliquer sur démarrer le jeu."
s3$ = " Puis le but sera d'aligner 4 jetons horizontalement, verticalement ou diagonalement."
s4$ = " Mais gare à l'ordinateur ..."
WindowWidth = 384
WindowHeight = 336
' UpperLeftX=int((DisplayWidth-WindowWidth)/2)
' UpperLeftY=int((DisplayHeight-WindowHeight)/2)
groupbox #about.frame, "Comment jouer", 22, 16, 336, 240
statictext #about.text, "", 38, 46, 304, 200
button #about.default, "Ok", [aboutOk], UL, 126, 270, 122, 25
open "Aide" for dialog_nf_modal as #about
#about, "trapclose [aboutOk]"
#about, "font ms_sans_serif 10"
#about.frame, "!font ms_sans_serif 12"
#about.text, s$ ; s2$ ; s3$ ; s4$
wait
[aboutOk]
close #about
end sub
sub CompMove depth
#main.info, compThink$(int(rnd(1)*COMPUTERTHINKS)+1)
' for i = 1 to 7
' h$ = "#main.button"+str$(i)
' #h$, "!disable"
' next i
n = BestMove(-1, depth)
ROW(n) = ROW(n)+1
B(ROW(n),n) = -1
' for i = 1 to 7
' if ROW(i+2) < 8 then
' h$ = "#main.button"+str$(i)
' ' #h$, "!enable"
' end if
' next i
#main.graph, "color darkred; backcolor darkred"
call DrawMove n, ROW(n)
#main.info, makeYourMove$(int(rnd(1)*YOURTURN)+1)
MOVE = CheckWin(MOVE, -1, ROW(n), n)
end sub
function IsWin$(pl, row, col)
if B(row-1,col)=pl and B(row-2,col)=pl and B(row-3,col)= pl then _
IsWin$ = str$(row-1); col; str$(row-2); col; str$(row-3); col
if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col-3)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col-3)
if B(row,col-1)=pl and B(row,col-2)=pl and B(row,col+1)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col-2); row; str$(col+1)
if B(row,col-1)=pl and B(row,col+1)=pl and B(row,col+2)= pl then _
IsWin$ = IsWin$; row; str$(col-1); row; str$(col+1); row; str$(col+2)
if B(row,col+1)=pl and B(row,col+2)=pl and B(row,col+3)= pl then _
IsWin$ = IsWin$; row; str$(col+1); row; str$(col+2); row; str$(col+3)
if B(row+3,col-3)=pl and B(row+2,col-2)=pl and B(row+1,col-1)= pl then _
IsWin$ = IsWin$; str$(row+3); str$(col-3); str$(row+2); str$(col-2); str$(row+1); str$(col-1)
if B(row+2,col-2)=pl and B(row+1,col-1)=pl and B(row-1,col+1)= pl then _
IsWin$ = IsWin$; str$(row+2); str$(col-2); str$(row+1); str$(col-1); str$(row-1); str$(col+1)
if B(row+1,col-1)=pl and B(row-1,col+1)=pl and B(row-2,col+2)= pl then _
IsWin$ = IsWin$; str$(row+1); str$(col-1); str$(row-1); str$(col+1); str$(row-2); str$(col+2)
if B(row-1,col+1)=pl and B(row-2,col+2)=pl and B(row-3,col+3)= pl then _
IsWin$ = IsWin$; str$(row-1); str$(col+1); str$(row-2); str$(col+2); str$(row-3); str$(col+3)
if B(row-3,col-3)=pl and B(row-2,col-2)=pl and B(row-1,col-1)= pl then _
IsWin$ = IsWin$; str$(row-3); str$(col-3); str$(row-2); str$(col-2); str$(row-1); str$(col-1)
if B(row-2,col-2)=pl and B(row-1,col-1)=pl and B(row+1,col+1)= pl then _
IsWin$ = IsWin$; str$(row-2); str$(col-2); str$(row-1); str$(col-1); str$(row+1); str$(col+1)
if B(row-1,col-1)=pl and B(row+1,col+1)=pl and B(row+2,col+2)= pl then _
IsWin$ = IsWin$; str$(row-1); str$(col-1); str$(row+1); str$(col+1); str$(row+2); str$(col+2)
if B(row+1,col+1)=pl and B(row+2,col+2)=pl and B(row+3,col+3)= pl then _
IsWin$ = IsWin$; str$(row+1); str$(col+1); str$(row+2); str$(col+2); str$(row+3); str$(col+3)
if IsWin$ <> "" then IsWin$ = str$(row); str$(col); IsWin$
end function
function CheckWin(CheckWin, player, row, col)
s$ = IsWin$(player, row, col)
if s$ <> "" then
CheckWin = 42
if player = 1 then
#main.info, youWin$(int(rnd(1)*HUMANWIN)+1)
#main.graph, "color blue; backcolor blue"
else
#main.info, compWin$(int(rnd(1)*COMPUTERWIN)+1)
#main.graph, "color red; backcolor red"
end if
for i = 1 to len(s$) step 2
x = val(mid$(s$, i, 1))
y = val(mid$(s$, i+1, 1))
call DrawMove y, x
next i
else
if CheckWin = 42 then #main.info, drawMessage$(int(rnd(1)*DRAW)+1)
end if
' if CheckWin = 42 then
' for i = 1 to 7
' h$ = "#main.button"+str$(i)
' ' #h$, "!disable"
' next i
' end if
end function
function GetValue(player, depth, row, column)
pl = -1*player
if (B(row-1,column)=pl and B(row-2,column)=pl and B(row-3,column)= pl) or _
(B(row,column-1)=pl and B(row,column-2)=pl and B(row,column-3)= pl) or _
(B(row,column-1)=pl and B(row,column-2)=pl and B(row,column+1)= pl) or _
(B(row,column-1)=pl and B(row,column+1)=pl and B(row,column+2)= pl) or _
(B(row,column+1)=pl and B(row,column+2)=pl and B(row,column+3)= pl) or _
(B(row+3,column-3)=pl and B(row+2,column-2)=pl and B(row+1,column-1)= pl) or _
(B(row+2,column-2)=pl and B(row+1,column-1)=pl and B(row-1,column+1)= pl) or _
(B(row+1,column-1)=pl and B(row-1,column+1)=pl and B(row-2,column+2)= pl) or _
(B(row-1,column+1)=pl and B(row-2,column+2)=pl and B(row-3,column+3)= pl) or _
(B(row-3,column-3)=pl and B(row-2,column-2)=pl and B(row-1,column-1)= pl) or _
(B(row-2,column-2)=pl and B(row-1,column-1)=pl and B(row+1,column+1)= pl) or _
(B(row-1,column-1)=pl and B(row+1,column+1)=pl and B(row+2,column+2)= pl) or _
(B(row+1,column+1)=pl and B(row+2,column+2)=pl and B(row+3,column+3)= pl) then
GetValue = -128
else
if depth = 0 then exit function
GetValue = -1000
for i = 3 to 9
if ROW(i) < 8 then
ROW(i) = ROW(i)+1
B(ROW(i), i) = player
value = -1*GetValue(-1*player, depth-1, ROW(i), i)/2
B(ROW(i), i) = 0
ROW(i) = ROW(i)-1
if value > GetValue then
GetValue = value
if value = 64 then exit for
end if
end if
next i
end if
end function
function BestMove(player, depth)
max = -1000
for i = 3 to 9
if ROW(i) < 8 then
ROW(i) = ROW(i)+1
B(ROW(i),i) = player
value = -1*GetValue(-1*player, depth, ROW(i), i)
B(ROW(i), i) = 0
ROW(i) = ROW(i)-1
if value > max then
max = value
BestList$ = str$(i)
if max = 128 then exit for
else
if value = max then BestList$ = BestList$+str$(i)
end if
end if
next i
'print BestList$, max
BestMove = val(mid$(BestList$, int(rnd(1)*len(BestList$))+1, 1))
end function
data 9
data "Hmm... Laisse moi réfléchir"
data "Tu joues bien, Je le sais !"
data "Je le sais, je vais gagner, laisse moi juste réfléchir."
data "Silence ! Je réfléchis"
data "Ne me frappe pas !"
data "Silence s'il vous plait, je gagne."
data "Je suis sur... je pense... dur..."
data "Alors tu n'y arrive pas ? x)"
data "Arrete d'aller trop vite, je ne suis plus."
data 8
data "Je ne crains rien! Donne-moi ton meilleur coup !"
data "Réveillez-moi quand vous êtes prêt à jouer."
data "Montrez-moi ce que tu sais faire! "
data "Prouve-moi que tu es le meilleur !"
data "Je vais prendre une petite sieste pendant que vous comprendre cela !"
data "Réfléchissez bien! Une petite erreur et vous avez terminé !"
data "Vous pensez que ce n'est un tirage au sort ? "
data "Je ne le crois pas! "
data "Prenez votre temps."
data 11
data "Un grand bravo au gagnant du jeu !"
data "Cela devrait vous donner une leçon. Vous ne gagnerais JAMAIS avec moi !"
data "Vous avez perdu !"
data "Nous pouvons jouer un autre partie, mais vous allez encore perdre ..."
data "Je parie que vous n'avez pas vu que vous venez de perdre ."
data "Nous ne pouvons rester amis !"
data "Ouch! çà doit faire mal !"
data "Alors, qu'est-ce que tu fais ce soir ? Tu perds ?"
data "Mesdames et Messieurs, nous avons un gagnant. Devinez qui!"
data "C'est une autre victoire question-sur-esprit ..."
data "Je suis le roi du monde ."
data 8
data "J'offre un rêve ."
data "Dessine! Pourtant, vous étiez si proches ..."
data "Vous m'avez mis sous beaucoup de pression, mais vous ne pouviez pas me casser!"
data "Fait Nouveau Jeu maintenant ! Nous devons savoir qui est le meilleur. "
data "Euh, que c'est il passé ?"
data "Je leur ai dit que nous allions avoir besoin d'une plus grande carte pour cela."
data "Il faut que je change mon CPU ..."
data "Je vous promets, la prochaine fois je ne vais pas te laisser partir si facilement."
[apropos]
s$ = "Version : 1.0"
s2$ = " Traduis et amélioré par alex877 "
WindowWidth = 384
WindowHeight = 336
groupbox #about2.frame, "Version/Editeur", 22, 16, 336, 240
statictext #about2.text, "", 38, 46, 304, 200
button #about2.default, "Ok", [about2Ok], UL, 126, 270, 122, 25
open "A propos" for dialog_nf_modal as #about2
#about2, "trapclose [aboutOk]"
#about2, "font ms_sans_serif 10"
#about2.frame, "!font ms_sans_serif 12"
#about2.text, s$ ; s2$
wait
[about2Ok]
close #about2
close #1
[load]
close #1
a$= "Nous sommes désolé mais cette partie est en cours de création"
statictext #charger.text, "", 5, 46, 304, 200
open "Charger une partie" for dialog_nf_modal as #charger
#charger.text, a$
wait
close #charger
[sauver]
close #main
a$= "Nous sommes désolé mais cette partie est en cours de création"
statictext #sauver.text, "", 5, 46, 304, 200
open "Sauvegarder une partie" for dialog_nf_modal as #sauver
#sauver.text, a$
wait
close #sauver
J'espère que vous pourrez m'aider .
a +
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
Tu peux mettre de la couleur dans la window, avec backgroundcolr$ et foregroundcolor$, à déclarer avant l'open. voir dans le "Amber"-->gui-->color and the graphical user interface, pour les majuscules de la syntaxe.
Le pb, c'est que en faisant cela, c'est un vrai micmac pour gerer les couleurs dans le reste du code.
Ce que tu peux faire, c'est de faire une graphicbox de 5 ou 10 pixels de moins que la window, qui elle, est beaucoup plus facile à gerer.
Tu peux aussi y mettre un bmp, mais alors, le prog qui pour l'instant est un fichier "volant", devra etre mis dans un dossier avec le bmp, et le tout mis en zip, dans ton profil/gestion des fichiers/ajouter/choisir/uploader, dont il faudra faire un lien à l'aide de la disquette qui est en haut, à droite
du champs de saisie des messages.
Bon, voyons ce que tu a bricolé.........à+
Le pb, c'est que en faisant cela, c'est un vrai micmac pour gerer les couleurs dans le reste du code.
Ce que tu peux faire, c'est de faire une graphicbox de 5 ou 10 pixels de moins que la window, qui elle, est beaucoup plus facile à gerer.
Tu peux aussi y mettre un bmp, mais alors, le prog qui pour l'instant est un fichier "volant", devra etre mis dans un dossier avec le bmp, et le tout mis en zip, dans ton profil/gestion des fichiers/ajouter/choisir/uploader, dont il faudra faire un lien à l'aide de la disquette qui est en haut, à droite
du champs de saisie des messages.
Bon, voyons ce que tu a bricolé.........à+
____________________
Roro
Roro
Pour le reste, je ne peux pas t'aider car le prog est trop complexe pour moi.
Le premier truc sur lequel je tombe, c'est une variable:"HUMANWIN", qui n'est pas initialisée, et ce genre de chose me laisse perplexe.
Je retourne à la chasse au bug dans bd_jb.............à+
Le premier truc sur lequel je tombe, c'est une variable:"HUMANWIN", qui n'est pas initialisée, et ce genre de chose me laisse perplexe.
Je retourne à la chasse au bug dans bd_jb.............à+
____________________
Roro
Roro
alex877:
?????????????? ton code donne effectivement ce problème donc je répondait à ce dont tu te plaignais c'est à dire précisément ça !!!!!!!!
Je t'ai déjà dit d'ou venait ton bug de fermeture alex : première ligne de mon post du 02/08/12 à 20h47.
Il y aurait peut-être une solution plus simple pour mettre une image de fond, car rien ne bouge en définitive...
Au départ tu affiches l'image et puis c'est tout.
@+
Edité par cassiope01 Le 03/08/2012 à 20h33
Citation:
Tes radiobutton sont inversés. Ce qui fait que le 4 est le 1 etc...
fait exprès car sinon on a l'impression que le "très facile" est plus dur que le "dur" .?????????????? ton code donne effectivement ce problème donc je répondait à ce dont tu te plaignais c'est à dire précisément ça !!!!!!!!
Je t'ai déjà dit d'ou venait ton bug de fermeture alex : première ligne de mon post du 02/08/12 à 20h47.
Il y aurait peut-être une solution plus simple pour mettre une image de fond, car rien ne bouge en définitive...
Au départ tu affiches l'image et puis c'est tout.
@+
Edité par cassiope01 Le 03/08/2012 à 20h33
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Web
Petit cadeau pour toi alex, et pour tout le monde bien sûr.
Il reste peut-être quelques bug, mais j'ai fait de mon mieux
Puissance 4
@+
Edité par cassiope01 Le 05/08/2012 à 07h44
Il reste peut-être quelques bug, mais j'ai fait de mon mieux

Puissance 4
@+
Edité par cassiope01 Le 05/08/2012 à 07h44
____________________
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Devise Shadocks : "Mieux vaut mobiliser son intelligence pour des conneries, que mobiliser sa connerie pour des choses intelligentes"
Coluche disait : "C'est parce que la vitesse de la lumière est plus rapide que celle du son que certains peuvent paraîtrent brillants jusqu'à ce qu'ils ouvrent la bouche."
Web
Merci bien des que je peux je test sa .
____________________
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute
Si le meilleurs langage de programmation existe, alors le Just Basic est loin devant.
Ne me tappez pas dessus ! Je débute

Web
• Index
1 Utilisateur en ligne : 0 Administrateur, 0 Modérateur, 0 Membre et 1 Visiteur
Utilisateur en ligne : Aucun membre connecté
Utilisateur en ligne : Aucun membre connecté
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie