Post by bluatigro on Feb 11, 2019 13:15:38 GMT
black uses mouse
white keyboard
error :
black not placing stone
white keyboard
error :
black not placing stone
'' bluatigro 11 feb 2019
'' go [ 9 x 9 ]
WindowWidth = DisplayWidth
WindowHeight = DisplayHeight
global winx , winy
winx = WindowWidth
winy = WindowHeight
dim bord( 9 , 9 )
global black , white , empty , player , gamestate
empty = 0
black = 1
white = 2
global black.black , black.white , white.black , white.white , white.x , white.y
black.black = 0
black.white = 1
white.white = 2
white.black = 3
gamestate = black.black
nomainwin
menu #m , "game" , "read me" , [info]
open "GO [9x9]" for graphics as #m
#m "trapclose [quit]"
#m "when leftBottunDown [leftdown]"
#m "when rightButtonDown [rightdown]"
#m "when characterInput [key]"
#m "setfocus"
call drawbord
scan
timer 250 , [tick]
wait
[quit]
close #m
end
[tick]
scan
wait
[info]
notice chr$( 13 ) _
+ "this is a GO game board ." + chr$( 13 ) + chr$( 13 ) _
+ "black :" + chr$( 13 ) _
+ "use mouse left button to place black stones ." + chr$( 13 ) _
+ "then use mouse left button to remove white if nesery ." + chr$( 13 ) _
+ "use mouse right button to end action's ," + chr$( 13 ) + chr$( 13 ) _
+ "white :" + chr$( 13 ) _
+ "use cursor key's to move and spacebar to place stone ." + chr$( 13 ) _
+ "use spacebar to remove black stones if nesery ." + chr$( 13 ) _
+ "use x key to end action's ."
scan
wait
[leftdown]
x = MouseX
y = MouseY
x = int( x / winx * 9 )
y = int( y / winy * 11 )
if gamestate = black.black then
bord( x , y ) = black
gamestate = black.white
else
bord( x , y ) = empty
end if
call drawbord
scan
wait
[rightdown]
gamestate = white.white
scan
wait
[key]
key$ = right$( Inkey$ , 1 )
select case key$
case chr$( _VK_UP )
if white.y > 0 then
white.y = white.y - 1
end if
case chr$( _VK_DOWN )
if white.y < 9 then
white.y = white.y + 1
end if
case chr$( _VK_LEFT )
if white.x > 0 then
white.x = white.x - 1
end if
case chr$( _VK_RIGHT )
if white.x < 9 then
white.x = white.x + 1
end if
case " "
if gamstate = white.white then
bord( white.x , white.y ) = white
gamstate = white.black
else
bord( white.x , white.y ) = white
end if
case "x" , "X"
gamestate = black.black
case else
end select
call drawbord
scan
wait
sub drawbord
#m "fill lightgray"
#m "color black"
for i = 0 to 8
#m "down"
#m "line 0 " ; int( ( i + .5 ) * winy / 11 ) _
; " " ; winx ; " " ; int( ( i + .5 ) * winy / 11 )
#m "up"
#m "down"
#m "line " ; int( ( i + .5 ) * winx / 9 ) _
; " 0 " ; int( ( i + .5 ) * winx / 9 ) ; " " ; winy
#m "up"
next i
for x = 0 to 8
for y = 0 to 8
select case bord( x , y )
case black
call rond x , y , "black"
case white
call rond x , y , "white"
case else
end select
next y
next x
#m "goto 100 " ; winy - 100
#m "font 50 bold"
#m "backcolor lightgray"
#m "color black"
#m "down"
select case gamestate
case black.black
#m "\black is placing black stone ."
case black.white
#m "\black is removing white stones[s] ."
case white.white
#m "\white is placing white stone ."
case white.black
#m "\white is removing black stone[s] ."
case else
end select
#m "up"
end sub
sub rond x , y , kl$
#m "color " ; kl$
#m "backcolor " ; kl$
#m "goto " ; int( ( x + .5 ) * winx / 9 ) _
; " " ; int( ( y + .5 ) * winy / 11 )
#m "down"
#m "ellipsefilled " ; winx / 9 ; " " ; winy / 11
#m "up"
end sub