Post by yoric on Feb 28, 2006 22:20:52 GMT -5
Just to make this thread 'legal'
Here is my demo code, for starters:
dim Board (9, 9)
dim x, y, d, char$
dim xd, yd, xl, yl, sc
dim Check, up, down, left, right
xd = 15
yd = 5
color (0, 0, 255)
locate 3, 1: print "Left-Click a ball for directions"
locate 16, 3: print "score " + sc
locate 0, 22: print "Hold Cursor Key and Left-Click Selection"
color (255, 0, 0)
for y = 3 to 5
for x = 1 to 7
color (255, 0, 0)
locate x + xd, y + yd: print "O"
next
next
for y = 1 to 7
for x = 3 to 5
color (255, 0, 0)
locate x + xd, y + yd: print "O"
next
next
color (255, 0, 0)
locate xd + 4, yd + 4: print "+"
while true
if not Mouse_Button (MOUSE_LBUTTON) then
locate x, y
endif
x = Mouse_X () * TextCols ()
y = Mouse_Y () * TextRows ()
xl = x - 15: yl = y - 5
if xl < 0 or xl > 7 then xl = 0 endif
if yl < 0 or yl > 7 then yl = 0 endif
char$ = CharAt$ (x, y)
locate 13, 15: print "X = " + xl; " " "Y = " + yl: Sleep (100)
if Mouse_Button (MOUSE_LBUTTON) then gosub Check: endif
wend
Check:
if CharAt$(x, y) = "O" and CharAt$(x, y - 1) = "O" and CharAt$(x, y - 2) = "+" then
locate 1, 17: color (0, 0, 255): print "Up OK" : up = true: color (255, 0, 0)
else locate 1, 17: print "Up No": up = false
endif
if CharAt$(x, y) = "O" and CharAt$(x, y + 1) = "O" and CharAt$(x, y + 2) = "+" then
locate 1, 18: color (0, 0, 255): print "Down OK": down = true: color (255, 0, 0)
else locate 1, 18: print "Down No": down = false
endif
if CharAt$(x, y) = "O" and CharAt$(x - 1, y) = "O" and CharAt$(x - 2, y) = "+" then
locate 1, 19: color (0, 0, 255): print "Left OK": left = true: color (255, 0, 0)
else locate 1, 19: print "Left No": left = false
endif
if CharAt$(x, y) = "O" and CharAt$(x + 1, y) = "O" and CharAt$(x + 2, y) = "+" then
locate 1, 20: color (0, 0, 255): print "Right OK": right = true: color (255, 0, 0)
else locate 1, 20: print "Right No": right = false
endif
if ScanKeyDown (VK_UP) and up then gosub up endif
if ScanKeyDown (VK_DOWN) and down then gosub down endif
if ScanKeyDown (VK_LEFT) and left then gosub left endif
if ScanKeyDown (VK_RIGHT) and right then gosub right endif
color (0, 0, 255)
locate 16, 3: print "score " + sc
color (255, 0, 0)
Sleep (2000)
return
up:
board (xl, yl) = 1: board (xl, yl - 1) = 1: board (xl, yl - 2) = 2
locate x, y: print "+": locate x, y - 1: print "+": locate x, y - 2: print "O"
sc = sc + 1
return
down:
board (xl, yl) = 1: board (xl, yl + 1) = 1: board (xl, yl + 2) = 2
locate x, y: print "+": locate x, y + 1: print "+": locate x, y + 2: print "O"
sc = sc + 1
return
left:
board (xl, yl) = 1: board (xl - 1, yl) = 1: board (xl - 2, yl) = 2
locate x, y: print "+": locate x - 1, y: print "+": locate x - 2, y: print "O"
sc = sc + 1
return
right:
board (xl, yl) = 1: board (xl + 1, yl) = 1: board (xl + 2, yl) = 2
locate x, y: print "+": locate x + 1, y: print "+": locate x + 2, y: print "O"
sc = sc + 1
return
All for now, but more to follow - I hope. Yoric
Here is my demo code, for starters:
dim Board (9, 9)
dim x, y, d, char$
dim xd, yd, xl, yl, sc
dim Check, up, down, left, right
xd = 15
yd = 5
color (0, 0, 255)
locate 3, 1: print "Left-Click a ball for directions"
locate 16, 3: print "score " + sc
locate 0, 22: print "Hold Cursor Key and Left-Click Selection"
color (255, 0, 0)
for y = 3 to 5
for x = 1 to 7
color (255, 0, 0)
locate x + xd, y + yd: print "O"
next
next
for y = 1 to 7
for x = 3 to 5
color (255, 0, 0)
locate x + xd, y + yd: print "O"
next
next
color (255, 0, 0)
locate xd + 4, yd + 4: print "+"
while true
if not Mouse_Button (MOUSE_LBUTTON) then
locate x, y
endif
x = Mouse_X () * TextCols ()
y = Mouse_Y () * TextRows ()
xl = x - 15: yl = y - 5
if xl < 0 or xl > 7 then xl = 0 endif
if yl < 0 or yl > 7 then yl = 0 endif
char$ = CharAt$ (x, y)
locate 13, 15: print "X = " + xl; " " "Y = " + yl: Sleep (100)
if Mouse_Button (MOUSE_LBUTTON) then gosub Check: endif
wend
Check:
if CharAt$(x, y) = "O" and CharAt$(x, y - 1) = "O" and CharAt$(x, y - 2) = "+" then
locate 1, 17: color (0, 0, 255): print "Up OK" : up = true: color (255, 0, 0)
else locate 1, 17: print "Up No": up = false
endif
if CharAt$(x, y) = "O" and CharAt$(x, y + 1) = "O" and CharAt$(x, y + 2) = "+" then
locate 1, 18: color (0, 0, 255): print "Down OK": down = true: color (255, 0, 0)
else locate 1, 18: print "Down No": down = false
endif
if CharAt$(x, y) = "O" and CharAt$(x - 1, y) = "O" and CharAt$(x - 2, y) = "+" then
locate 1, 19: color (0, 0, 255): print "Left OK": left = true: color (255, 0, 0)
else locate 1, 19: print "Left No": left = false
endif
if CharAt$(x, y) = "O" and CharAt$(x + 1, y) = "O" and CharAt$(x + 2, y) = "+" then
locate 1, 20: color (0, 0, 255): print "Right OK": right = true: color (255, 0, 0)
else locate 1, 20: print "Right No": right = false
endif
if ScanKeyDown (VK_UP) and up then gosub up endif
if ScanKeyDown (VK_DOWN) and down then gosub down endif
if ScanKeyDown (VK_LEFT) and left then gosub left endif
if ScanKeyDown (VK_RIGHT) and right then gosub right endif
color (0, 0, 255)
locate 16, 3: print "score " + sc
color (255, 0, 0)
Sleep (2000)
return
up:
board (xl, yl) = 1: board (xl, yl - 1) = 1: board (xl, yl - 2) = 2
locate x, y: print "+": locate x, y - 1: print "+": locate x, y - 2: print "O"
sc = sc + 1
return
down:
board (xl, yl) = 1: board (xl, yl + 1) = 1: board (xl, yl + 2) = 2
locate x, y: print "+": locate x, y + 1: print "+": locate x, y + 2: print "O"
sc = sc + 1
return
left:
board (xl, yl) = 1: board (xl - 1, yl) = 1: board (xl - 2, yl) = 2
locate x, y: print "+": locate x - 1, y: print "+": locate x - 2, y: print "O"
sc = sc + 1
return
right:
board (xl, yl) = 1: board (xl + 1, yl) = 1: board (xl + 2, yl) = 2
locate x, y: print "+": locate x + 1, y: print "+": locate x + 2, y: print "O"
sc = sc + 1
return
All for now, but more to follow - I hope. Yoric