
-----------------------------------
ohgeez_
Wed Apr 05, 2006 9:27 pm

tic tac toe
-----------------------------------
my first game =D.  I didn't use x's and o's because i didn't want to waste time drawing them.  Just finished a massive pixel graphic program for school.  Please give comments on how to improve this.




setscreen ("graphics: 460;480")

var x, y, button : int
var count : int := 1
var reds : array 1 .. 8 of int
var blues : array 1 .. 8 of int

for i : 1 .. 8
    reds (i) := 0
    blues (i) := 0
end for

%blue1 top horizontal
%blue2 middle horizontal
%blue3 bottom horizontal
%blue4 left vertical
%blue5 middle vertical
%blue6 right vertical
%blue7 diagonal from top left
%blue8 diagonal form top right

%layout
drawbox (100, 100, 400, 400, black)
drawline (200, 100, 200, 400, black)
drawline (300, 100, 300, 400, black)
drawline (100, 200, 400, 200, black)
drawline (100, 300, 400, 300, black)

procedure one_and_one
    if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
        drawfilloval (150, 150, 50, 50, brightblue)
        blues (3) := blues (3) + 1
        blues (4) := blues (4) + 1
        blues (8) := blues (8) + 1
    elsif count = 2 or count = 4 or count = 6 or count = 8 then
        drawfilloval (150, 150, 50, 50, brightred)
        reds (3) := reds (3) + 1
        reds (4) := reds (4) + 1
        reds (8) := reds (8) + 1
    end if
end one_and_one

procedure one_and_two
    if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
        drawfilloval (150, 250, 50, 50, brightblue)
        blues (2) := blues (2) + 1
        blues (4) := blues (4) + 1
    elsif count = 2 or count = 4 or count = 6 or count = 8 then
        drawfilloval (150, 250, 50, 50, brightred)
        reds (2) := reds (2) + 1
        reds (4) := reds (4) + 1
    end if
end one_and_two

procedure one_and_three
    if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
        drawfilloval (150, 350, 50, 50, brightblue)
        blues (1) := blues (1) + 1
        blues (4) := blues (4) + 1
        blues (7) := blues (7) + 1
    elsif count = 2 or count = 4 or count = 6 or count = 8 then
        drawfilloval (150, 350, 50, 50, brightred)
        reds (1) := reds (1) + 1
        reds (4) := reds (4) + 1
        reds (7) := reds (7) + 1
    end if
end one_and_three

procedure two_and_one
    if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
        drawfilloval (250, 150, 50, 50, brightblue)
        blues (3) := blues (3) + 1
        blues (5) := blues (5) + 1
    elsif count = 2 or count = 4 or count = 6 or count = 8 then
        drawfilloval (250, 150, 50, 50, brightred)
        reds (3) := reds (3) + 1
        reds (5) := reds (5) + 1
    end if
end two_and_one

procedure two_and_two
    if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
        drawfilloval (250, 250, 50, 50, brightblue)
        blues (2) := blues (2) + 1
        blues (5) := blues (5) + 1
        blues (7) := blues (7) + 1
        blues (8) := blues (8) + 1
    elsif count = 2 or count = 4 or count = 6 or count = 8 then
        drawfilloval (250, 250, 50, 50, brightred)
        reds (2) := reds (2) + 1
        reds (5) := reds (5) + 1
        reds (7) := reds (7) + 1
        reds (8) := reds (8) + 1
    end if
end two_and_two

procedure two_and_three
    if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
        drawfilloval (250, 350, 50, 50, brightblue)
        blues (1) := blues (1) + 1
        blues (5) := blues (5) + 1
    elsif count = 2 or count = 4 or count = 6 or count = 8 then
        drawfilloval (250, 350, 50, 50, brightred)
        reds (1) := reds (1) + 1
        reds (5) := reds (5) + 1
    end if
end two_and_three

procedure three_and_one
    if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
        drawfilloval (350, 150, 50, 50, brightblue)
        blues (3) := blues (3) + 1
        blues (6) := blues (6) + 1
        blues (7) := blues (7) + 1
    elsif count = 2 or count = 4 or count = 6 or count = 8 then
        drawfilloval (350, 150, 50, 50, brightred)
        reds (3) := reds (3) + 1
        reds (6) := reds (6) + 1
        reds (7) := reds (7) + 1
    end if
end three_and_one

procedure three_and_two
    if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
        drawfilloval (350, 250, 50, 50, brightblue)
        blues (2) := blues (2) + 1
        blues (6) := blues (6) + 1
    elsif count = 2 or count = 4 or count = 6 or count = 8 then
        drawfilloval (350, 250, 50, 50, brightred)
        reds (2) := reds (2) + 1
        reds (6) := reds (6) + 1
    end if
end three_and_two

procedure three_and_three
    if count = 1 or count = 3 or count = 5 or count = 7 or count = 9 then
        drawfilloval (350, 350, 50, 50, brightblue)
        blues (1) := blues (1) + 1
        blues (6) := blues (6) + 1
        blues (8) := blues (8) + 1
    elsif count = 2 or count = 4 or count = 6 or count = 8 then
        drawfilloval (350, 350, 50, 50, brightred)
        reds (1) := reds (1) + 1
        reds (6) := reds (6) + 1
        reds (8) := reds (8) + 1
    end if
end three_and_three


loop
    mousewhere (x, y, button)

    if button = 1 and x >= 100 and x = 100 and y = 100 and x = 200 and y = 100 and x = 300 and y = 200 and x = 100 and y = 200 and x = 200 and y = 200 and x = 300 and y = 300 and x = 100 and y = 300 and x = 200 and y = 300 and x = 300 and y 