G
GrayDwarf
Guest
In the example code provided, there is a while loop which ends up in an infinite loop because it's missing an "exit". The game quietly hangs and it's not an easy thing to troubleshoot so new GameMakers will likely get hung up on it.
The problematic example code is on page 7 of 7.
The fixed code which allows the game to run and work as expected.
Another minor issue is on page 6 of 7. On ln 1, scrCheckGameresult should be scrCheckGameResult.
The problematic example code is on page 7 of 7.
Code:
// Easy difficulty (or no move on other difficulties) forces the PC to place randomly
while(true){
var i = irandom(2);
var j = irandom(2);
if (!gameCell[i, j].occupied){
scrUseCell(i, j, sprCross);
}
}
}
Code:
// Easy difficulty (or no move on other difficulties) forces the PC to place randomly
while(true){
var i = irandom(2);
var j = irandom(2);
if (!gameCell[i, j].occupied){
scrUseCell(i, j, sprCross);
exit; // <-- MISSING LINE
}
}
}
Code:
switch(scrCheckGameresult()){
case boardState.NoResult:
if gameTurn == gameTurnPlayer{
gameTurn = gameTurnPC;
}
else {
gameTurn = gameTurnPlayer;
}
break;
case boardState.Winner:
if gameTurn == gameTurnPlayer{
currentGameState = gameState.YouWin;
show_message_async("You WIN!");
}
else {
currentGameState = gameState.YouLose;
show_message_async("You LOSE!");
}
break;
case boardState.Stalemate:
currentGameState = gameState.StaleMate;
show_message_async("DRAW!");
break;
}