Computer Science Canada

Tic Tac Toe with WhatDotColour

Author:  TheOneTrueGod [ Thu Jun 15, 2006 6:00 pm ]
Post subject:  Tic Tac Toe with WhatDotColour

In order to show that problems can be done virtually any way you think they can, I decided to write this TicTacToe game using WhatDotColour. There is no way to check for a winner yet, but I may implement that later, if I feel like it.

code:

const boxSize := 50
for i : 1 .. 3
    for j : 1 .. 3
        drawfillbox (i * boxSize, j * boxSize, (i + 1) * boxSize - 1, (j + 1) * boxSize - 1, i + j * 3)
    end for
end for

var mx, my, button, squareOn, i, j, turnOn : int
turnOn := 0
loop
    mousewhere (mx, my, button)
if button = 1 and View.WhatDotColour (mx, my) not= white and View.WhatDotColour(mx,my) not= 33 and View.WhatDotColour(mx,my) not= 35 then
        squareOn := View.WhatDotColour (mx, my)
        i := (squareOn - 1) mod 3 + 1
        j := (squareOn - 1) div 3
        drawfillbox (i * boxSize, j * boxSize, (i + 1) * boxSize - 1, (j + 1) * boxSize - 1, white)
        if turnOn mod 2 = 0 then
            Draw.ThickLine (i * boxSize, j * boxSize, (i + 1) * boxSize - 1, (j + 1) * boxSize - 1, 3, 35)
            Draw.ThickLine (i * boxSize, (j + 1) * boxSize - 1, (i + 1) * boxSize - 1, j * boxSize, 3, 35)
        else
            drawfilloval (i * boxSize + boxSize div 2, j * boxSize + boxSize div 2, boxSize div 2, boxSize div 2, 33)
            drawfilloval (i * boxSize + boxSize div 2, j * boxSize + boxSize div 2, boxSize div 2 - 5, boxSize div 2 - 5, white)
        end if
        turnOn += 1
    end if
end loop


On the plus side, I think that If I removed some of the 'prettying' up lines, and some of the excess lines, this may be below 20 Very Happy

Edit:Oops, thanks SuperFreak. I patched that up. I just did this 'cuz I was feeling bored, and because I was looking through the Turing help at the projects people were submitting, and crying inside at the length of the simple programs...

Author:  Clayton [ Thu Jun 15, 2006 9:22 pm ]
Post subject: 

hm i think theres a glitch with your turn order.... i started playing and it went X,O,XX,O,X,O etc, and i dont know y, u might want to look into that Wink u must have been feeling a little ambitious to actually do tictactoe with View.WhatDotColor lol, Andy would be proud Very Happy

Author:  Bored [ Fri Jun 16, 2006 9:11 am ]
Post subject:  Re: Tic Tac Toe with WhatDotColour

TheOneTrueGod wrote:
I just did this 'cuz I was feeling bored, and because I was looking through the Turing help at the projects people were submitting, and crying inside at the length of the simple programs...

LOL, I know, I remmeber righting programs like that, but unlike many of those people I actually listened on how to shorten things up. But anyways, that's a interesting way to do it, and maybe this Tic Tac Toe wave will begin to read this post before making these verry inneficent versions and posting them in a section already overflowed with simple, beginner coded tic tac toe games.

Author:  xXInsanityXx [ Mon Jun 26, 2006 10:29 am ]
Post subject:  Re: Tic Tac Toe with WhatDotColour

Bored wrote:
TheOneTrueGod wrote:
I just did this 'cuz I was feeling bored, and because I was looking through the Turing help at the projects people were submitting, and crying inside at the length of the simple programs...

LOL, I know, I remmeber righting programs like that, but unlike many of those people I actually listened on how to shorten things up. But anyways, that's a interesting way to do it, and maybe this Tic Tac Toe wave will begin to read this post before making these verry inneficent versions and posting them in a section already overflowed with simple, beginner coded tic tac toe games.


I agree this kicks the shyt outa my code nice job...

Author:  upthescale [ Mon Jun 26, 2006 1:06 pm ]
Post subject: 

Watch ur lagnauge!!!! but any way nice game its less than 40 lines lol

Author:  Mr. T [ Mon Jun 26, 2006 11:17 pm ]
Post subject:  Alex's Opinion

upthescale wrote:
Watch ur lagnauge!!!! but any way nice game its less than 40 lines lol

LOL. Before you try correcting other people's use of language, why don't you first take a look at your signature. Hypocrite. Snooty


: