Tic Tak Toe help
Author |
Message |
notleetprogrammer
|
Posted: Thu May 25, 2006 4:10 pm Post subject: Tic Tak Toe help |
|
|
Mod edit: moved to [Turing Help]
made this game in about 10 min....so far it's pretty bad...umm i need this for school project along with another game that will probably be black jack..umm i need some help with having turing tell me which player has won or not..thnx
left click is x
right click is y
var x, y, button : int
var buttonnumber, buttonupdown : int
var font1 : int
var check : boolean := false
drawbox (300, 300, 100, 100, black)
drawline (235, 300, 235, 100, black)
drawline (160, 300, 160, 100, black)
drawline (300, 235, 100, 235, black)
drawline (300, 170, 100, 170, black)
font1 := Font.New ("serif:40:bold")
mousewhere (x, y, button)
buttonchoose ("multibutton")
loop
check := false
loop
buttonwait ("down", x, y, buttonnumber, buttonupdown)
if buttonnumber = 1 and buttonupdown = 1 then
drawfilloval (x, y, 20, 20, black)
check := true
end if
exit when check = true
end loop
check := false
loop
buttonwait ("down", x, y, buttonnumber, buttonupdown)
if buttonnumber = 3 and buttonupdown = 1 then
Font.Draw ("X", x, y, font1, red)
check := true
end if
exit when check = true
end loop
end loop |
|
|
|
|
|
Sponsor Sponsor
|
|
|
TheOneTrueGod
|
Posted: Thu May 25, 2006 4:30 pm Post subject: (No subject) |
|
|
Welcome to compsci. First of all, if you need turing help, post in the [Turing Help] section. Also, use code tags. Highlite the text that you want to be "code tagged" and press the code button.
Eg
Allright, now that thats out of the way, you've got turn recognition, which is a start, but now you want to make sure they can only click in the apropriate location. You're going to want to start by making the squares an equal size and after thats done, you're going to want to ensure that the mouse's co-ordinates are within the bounds of the squares.
Some background info you should know before starting this, is arrays. For this program you should use either a two dimensional array, or a nine element one dimensonal array (If you have math skillz to pay da billz... or just a grade 9 math education and a willingness to think. Whichever )
This array will keep track of which squares have which player on them. You want to display the squares accordingly. Using math (Yes, computer science is FULL of math. Hope you enjoy applying what you learnt from grades 5 - 9) you can determine where the mouse's location is in that array, and set that to whichever turn it is.
If you want to use left click for both Xs and Os, you're going to need to use an "oldbutton" variable.
Finally, instead of having two nested loops, change them into one procedure, which accepts a parameter indicating who's turn it is (should implement the oldbutton variable) and will place the correct piece where it should go. Your other option is to just keep em in the main loop, and have a variable keep track of who's turn it is, and place the apropriate piece based on this variable (A while ago I would have used the variable. Now I realise that the procedure method is much MUCH better.)
Good Luck |
|
|
|
|
|
notleetprogrammer
|
Posted: Thu May 25, 2006 4:34 pm Post subject: (No subject) |
|
|
wow thnx man..well i'll work on it caus ei still have like 3 weeks...umm i will post up the finished product here in about a week or two...lol thnx for ur help...i'm grade 10...just in case lol |
|
|
|
|
|
|
|