Hello community,
i created a tictactoe game and would like you to point me at how to simplify the algorithm to check wether someonehas won or not..
funtion is located in main card script.
regards viro
TicTacToe
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
TicTacToe
- Attachments
-
- tictactoe.zip
- (2.61 KiB) Downloaded 473 times
the funniest thing about this particular signature is that by the time you realize it doesn't say anything it's too late to stop reading it
Re: TicTacToe
HI viro,
sehr schön!
Thanks for sharing this one!
Some general hints::
1. Avoid using NUMBERS as the NAMES of objects in any case!
This will "confuse" the engine and might give unexspected results
In your case it works, because your buttons are correctly named like their LAYERS:
button "1" = first button etc.
2. When "sending" commands, put the commands in QUOTES:
...
send "whatever" to this cd
...
But since the card script is in the message heirachie, you do not need to send
this command at all, just execute it (NO quotes in that case):
The algorithm for checking is OK, one might "finetune" the syntax, but it works
"und dat is de Hauptsach', Jung"!
Best
Klaus
sehr schön!
Thanks for sharing this one!
Some general hints::
1. Avoid using NUMBERS as the NAMES of objects in any case!
This will "confuse" the engine and might give unexspected results
In your case it works, because your buttons are correctly named like their LAYERS:
button "1" = first button etc.
2. When "sending" commands, put the commands in QUOTES:
...
send "whatever" to this cd
...
But since the card script is in the message heirachie, you do not need to send
this command at all, just execute it (NO quotes in that case):
Code: Select all
...
if tName is "x" then
checkWin
put "o" into tName
else
...
"und dat is de Hauptsach', Jung"!
Best
Klaus
Re: TicTacToe
And here some "code cleaning" for the script of grp "feld" (??? )
Code: Select all
global tID,tName,tGameStarted,tFirstMove
on mouseUp
put the childControlIDs of group "feld" into tID
## I avoid nested IF THEN clauses wherever possible:
if the label of the target <> empty then
exit to top
end if
## ONE IF END IF less so far! :-D
set the label of the target to tName
## We need to check right now, to be able to stop the game immediately after clicking!
checkWin
put true into tGameStarted
if tName is "x" then
put "O" into tName
else
put "X" into tName
end if
put false into tFirstMove
put tName into fld "fldReihe"
end mouseUp
Re: TicTacToe
just done your suggested code cleaning^^
still not happy with the reference to btn numbers though :/
everybody may use this stack without my permission
still not happy with the reference to btn numbers though :/
everybody may use this stack without my permission
- Attachments
-
- tictactoe.zip
- (2.6 KiB) Downloaded 399 times
the funniest thing about this particular signature is that by the time you realize it doesn't say anything it's too late to stop reading it