
-----------------------------------
batman
Thu Jun 08, 2006 8:16 pm

Game
-----------------------------------
I need help fiquire out how to prevent an x and a o being drawn over each other if the user clicks a boc twice. 


colour (brightgreen)
put "PLEASE ENTER THE NAMES OF THE TWO PLAYERS!"
get name1
get name2

var x1, y1, button, buttonnumber, buttonupdown : int
var counter : int := 1
var x : array 1 .. 8 of int
var o : array 1 .. 8 of int
var ch : string(1) 


for loc : 1 .. 8
    x (loc) := 0
    o (loc) := 0
end for

setscreen ("graphics:400,400")
font := Font.New ("Palatino:38:bold")
Draw.FillBox (maxx, maxy, 0, 0, black)
Draw.FillBox (135, 0, 131, maxy, brightgreen)
Draw.FillBox (268, 0, 264, maxy, brightgreen)
Draw.FillBox (0, 135, maxx, 131, brightgreen)
Draw.FillBox (0, 268, maxx, 264, brightgreen)


procedure one
    if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
        Draw.Text ("X", 50, 320, font, brightgreen)
        x (3) := x (3) + 1
        x (4) := x (4) + 1
        x (8) := x (8) + 1
    else
        Draw.Text ("O", 50, 320, font, brightgreen)
        o (3) := o (3) + 1
        o (4) := o (4) + 1
        o (8) := o (8) + 1
    end if
end one

procedure two
    if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
        Draw.Text ("X", 175, 320, font, brightgreen)
        x (2) := x (2) + 1
        x (4) := x (4) + 1
    else
        Draw.Text ("O", 175, 320, font, brightgreen)
        o (2) := o (2) + 1
        o (4) := o (4) + 1
    end if
end two

procedure three
    if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
        Draw.Text ("X", 300, 320, font, brightgreen)
        x (1) := x (1) + 1
        x (4) := x (4) + 1
        x (7) := x (7) + 1
    else
        Draw.Text ("O", 300, 320, font, brightgreen)
        o (1) := o (1) + 1
        o (4) := o (4) + 1
        o (7) := o (7) + 1
    end if
end three

procedure four
    if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
        Draw.Text ("X", 50, 175, font, brightgreen)
        x (3) := x (3) + 1
        x (5) := x (5) + 1
    else
        Draw.Text ("O", 50, 175, font, brightgreen)
        o (3) := o (3) + 1
        o (5) := o (5) + 1
    end if
end four

procedure five
    if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
        Draw.Text ("X", 175, 175, font, brightgreen)
        x (2) := x (2) + 1
        x (5) := x (5) + 1
        x (7) := x (7) + 1
        x (8) := x (8) + 1
    else
        Draw.Text ("O", 175, 175, font, brightgreen)
        o (2) := o (2) + 1
        o (5) := o (5) + 1
        o (7) := o (7) + 1
        o (8) := o (8) + 1
    end if
end five

procedure six
    if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
        Draw.Text ("X", 300, 175, font, brightgreen)
        x (1) := x (1) + 1
        x (5) := x (5) + 1
    else
        Draw.Text ("O", 300, 175, font, brightgreen)
        o (1) := o (1) + 1
        o (5) := o (5) + 1
    end if
end six

procedure seven
    if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
        Draw.Text ("X", 50, 50, font, brightgreen)
        x (3) := x (3) + 1
        x (6) := x (6) + 1
        x (7) := x (7) + 1
    else
        Draw.Text ("O", 50, 50, font, brightgreen)
        o (3) := o (3) + 1
        o (6) := o (6) + 1
        o (7) := o (7) + 1
    end if
end seven

procedure eight
    if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
        Draw.Text ("X", 175, 50, font, brightgreen)
        x (2) := x (2) + 1
        x (6) := x (6) + 1
    else
        Draw.Text ("O", 175, 50, font, brightgreen)
        o (2) := o (2) + 1
        o (6) := o (6) + 1

    end if
end eight

procedure nine
    if counter = 1 or counter = 3 or counter = 5 or counter = 7 or counter = 9 then
        Draw.Text ("X", 300, 50, font, brightgreen)
        x (1) := x (1) + 1
        x (6) := x (6) + 1
        x (8) := x (8) + 1
    else
        Draw.Text ("O", 300, 50, font, brightgreen)
        o (1) := o (1) + 1
        o (6) := o (6) + 1
        o (8) := o (8) + 1
    end if
end nine
loop
    mousewhere (x1, y1, button)
    if button = 1 and x1 >= 0 and x1 = 268 and win not= 1 then
        one
    elsif button = 1 and x1 >= 134 and x1 = 268 and win not= 1 then
        two
    elsif button = 1 and x1 >= 267 and x1 = 268 and win not= 1 then
        three
    elsif button = 1 and x1 >= 0 and x1 = 134 and x1 = 135 and y1 = 267 and x1 = 135 and y1 = 0 and x1 = 0 and y1 = 134 and x1 = 0 and y1 = 268 and x1 = 0 and y1 