Post by honky on May 28, 2024 9:54:00 GMT
Good morning,
The final goal is a two -playing naval battle.
The problems are in: [PLA], [Plab], and [Mark]
Although the two procedures are the same.
A): Click in the "Place A (MDP) box", gives: "LightGray" in the map (while it should give "Red".
B): click in the box "Place B (MDP)", gives well: "Yellow" in the map.
C): But if we recall in the box: "Place a (MDP)", the color remains "yellow" instead of ironing in "red".
C) And sometimes it goes back: "red"
The final goal is a two -playing naval battle.
The problems are in: [PLA], [Plab], and [Mark]
Although the two procedures are the same.
A): Click in the "Place A (MDP) box", gives: "LightGray" in the map (while it should give "Red".
B): click in the box "Place B (MDP)", gives well: "Yellow" in the map.
C): But if we recall in the box: "Place a (MDP)", the color remains "yellow" instead of ironing in "red".
C) And sometimes it goes back: "red"
I give my tongue to the cat, and ask for a little light.
Thank you for
[/div][div] nomainwin
NbXmax = 45: NbYmax = 20
dc = 20 'dimension d'une case en pixels
MapWidth = NbXmax*dc: MapHeight = NbYmax*dc
WindowWidth = MapWidth+15: WindowHeight = 560
UpperLeftX = 20: UpperLeftY =5
ncx = int(MapWidth/dc) 'nb of X cells
ncy = int(MapHeight/dc) 'nb of Y cells
dim cell(ncx,ncy), cell$(ncx,ncy)
statictext #w.txt "",10,12,280,20
BUTTON #w.grid, "Grid", [grid], UL, WindowWidth-60, 5, 50, 25
textbox #w.a, 180, 75, 50, 25
BUTTON #w.aa, "<--Ok", [valia], UL, 235, 75, 50, 20
textbox #w.b, 310, 75, 50, 25
BUTTON #w.bb, "<--Ok", [valib], UL, 365, 75, 50, 20
graphicbox #w.g, 5, 35, MapWidth, 75
graphicbox #w.map, 5, 120, MapWidth, MapHeight
open " TEST GRID Coord..." for window_nf as #w 'graphics_nf_nsb
#w "trapclose [quit]"
#w.map "down; fill black": #w.g, "down;fill darkgreen;color white;backcolor darkgreen"
#w.map "backcolor lightgray; color lightgray"
#w.g, "font courrier 12 bold": #w, "font courrier 12 bold"
#w.g, "place 200 30": #w.g, "\Joueur A": #w.g, "place 320 30": #w.g, "\Joueur B"
#w.g, "place 10 60": #w.g, "\Mot De Passe-->"
#w.map "when leftButtonDown [Mark]"
#w.g, "when leftButtonDown [clic]"
#w.g, "when rightButtonDown [coord]"
dim jeuax(ncx+1),jeuay(ncy+1),jeua$(1400),jeubx(ncx+1),jeuyx(ncy+1),jeub$(1400)
#w.a, "aze": #w.b, "qsd"
' col$="green"
'(((((((((((((((((((((((
#w.g, "color yellow;backcolor darkgreen"
#w.g, "place 460 15": #w.g, "\Clic in the red box And Clic in the grid"
#w.g, "place 450 55": #w.g, "\Placer A (MPDP)"
#w.g, "place 600 55": #w.g, "\Fin"
#w.g, "place 670 55": #w.g, "\Placer B (MPDP)"
#w.g, "place 820 55": #w.g, "\Fin"
#w.g, "color red;size 3"
#w.g, "place 440 35": #w.g, "box 580 65" 'place A
#w.g, "place 660 35": #w.g, "box 800 65"
#w.g, "place 590 35": #w.g, "box 640 65" 'place B
#w.g, "place 815 35": #w.g, "box 855 65"
gosub [DispMap]
wait
[clic]
cx=MouseX: cy=MouseY
if cy>35 and cy<65 then
if cx>440 and cx<500 then
goto [pla]
end if
if cx>660 and cx<795 then
goto [plb]
end if
end if
wait
' [valpla]
' gosub [savea]
' wait
[pla]
' #w.g, "color darkgreen;backcolor darkgreen": #w.g, "place 440 0": #w.g, "boxfilled 900 25"
' #w.g, "color white"
' #w.g, "place 550, 20": #w.g, "\Entrer Mot de passe"
#w.a, "!contents? mdpa$"
' if mdpa$="aze" then
' col$="red": flaga=1
#w.map, "color red;backcolor red": flaga=1
#w.map, "when leftButtonDown [Mark]"
' end if
wait
[plb]
' #w.g, "color darkgreen;backcolor darkgreen": #w.g, "place 440 0": #w.g, "boxfilled 900 25"
' #w.g, "color white"
' #w.g, "place 550, 20": #w.g, "\Entrer Mot de passe"
' #w.b, "!contents? mdpb$"
' if mdpb$="qsd" then
' col$="yellow": flaga=2
#w.map, "color yellow;backcolor yellow": flaga=2
#w.map, "when leftButtonDown [Mark]"
' end if
wait
[Mark]
mx = int(MouseX/dc)
my = int(MouseY/dc)
if mx<=ncx and my<=ncy then
' #w.map, "color ";" ";col$: #w.map, "backcolor ";" ";col$
#w.map, "place ";mx*dc+1;" ";my*dc+1;"; boxfilled ";mx*dc+dc-1;" ";my*dc+dc-1
if flaga=1 then
pa=pa+1: jeua$(pa)="red"
jeuax(pa)=mx+1: jeuay(pa)=my+1
end if
if flaga=2 then
pb=pb+1: jeub$(pb)="yellow"
jeubx(pb)=mx+1: jeuby(pb)=my+1
end if
end if
gosub [infos]
wait
[infos]
#w.txt "pixels : ";MouseX;" / ";MouseY;" Cell ( ";mx;" , ";my;" )"
return
[DispMap]
#w.map "fill black;color lightgray"
for y=1 to ncy
#w.map "place 0 ";y*dc;"; goto ";MapWidth;" ";y*dc
next y
for x=1 to ncx
#w.map "place ";x*dc;" 0; goto ";x*dc;" ";MapHeight
next
#w.map "flush; discard"
return
[savea]
open "jeua.txt" for output as #f
for x=1 to pa
print #f, jeua$(x)
print #f, jeuax(x)
print #f, jeuay(x)
next x
close #f
return
[saveb]
open "jeub.txt" for output as #f
for x=1 to pb
print #f, jeub$(x)
print #f, jeubx(x)
print #f, jeuby(x)
next x
close #f
return
[coord]
ax=MouseX: ay=MouseY
#w.g, "place ";ax;" ";ay: #w.g, "\ ";str$(ax);" ";str$(ay)
wait
[quit]
close #w
end
wait