As a quick intro to Esenthel I wrote a Tic Tac Toe game that uses buttons to represent each of the squares and adds a quit button, a scoreboard and multiple games.
I have run into a few problems. First off the victory script does not work. Well it doesn't work all the time. The program runs by executing a MarkButton script when a button is clicked, Checking for victory and then incrementing the turn to the other player. Everything works except the victory script. Here is the Victory Checking script (Button numbers correlate to the numbers on the numpad):
Code:
void VictoryCheck(Char16 CheckChr,Int Player)
{
bool won;
if(button_1.text.first() == CheckChr && button_2.text.first() == CheckChr && button_3.text.first() == CheckChr) won = true;
else if(button_4.text.first() == CheckChr && button_5.text.first() == CheckChr && button_6.text.first() == CheckChr) won = true;
else if(button_7.text.first() == CheckChr && button_8.text.first() == CheckChr && button_9.text.first() == CheckChr) won = true;
else if(button_1.text.first() == CheckChr && button_4.text.first() == CheckChr && button_7.text.first() == CheckChr) won = true;
else if(button_2.text.first() == CheckChr && button_5.text.first() == CheckChr && button_8.text.first() == CheckChr) won = true;
else if(button_3.text.first() == CheckChr && button_6.text.first() == CheckChr && button_9.text.first() == CheckChr) won = true;
else if(button_1.text.first() == CheckChr && button_5.text.first() == CheckChr && button_9.text.first() == CheckChr) won = true;
else if(button_3.text.first() == CheckChr && button_5.text.first() == CheckChr && button_7.text.first() == CheckChr) won = true;
else won = false;
if (won == true)
{
if (Player == 1)
{
p1_vic ++;
winner = 1;
}
else
{
p2_vic ++;
winner = 2;
}
}
}
My next problem involves my score counter. I am trying to draw two ints. One for each players victory count. The numbers however do not appear. My Draw function looks like this:
Code:
void Draw()
{
D .clear(WHITE);
Gui.draw ();
D.text(0,0.85,msg);
//Draw Victories
if (p1_vic > p2_vic)
D.circL(Color(255,0,0,255),.075,-0.35,-0.9);
else if (p2_vic > p1_vic)
D.circL(Color(255,0,0,255),.075,0.35,-0.9);
D.text(-0.35,-0.9,S+p1_vic);
D.text(0.35,-0.9,S+p2_vic);
}
I have tried to move the text around but nothing works. Did I miss something?
If you need the full code I uploaded it to my site here:
http://code.google.com/p/theprojects/wik...=TicTacToe. I would prefer a helpful hint rather then a "here's the code" type of answer as I feel I will learn better if I have to fix the problems myself.
Thanks for the help and time.