Dagoba
Member
Hello, long time no see!
I am currently programming a Texas Hold'Em online game, and I am encountering a problem.
There are turns for each player on the table, and it's running by for loop for each player.
I need to make a method that waits until the player has clicked either call, check, fold, raise or all-in button.
It is made like this:
I know, that I should use while(!turn_used), but everytime I use while loop in Game Maker, the game will freeze due to infinite loop.
Now the code doesn't work because it checks if player has clicked a button, it has not because the loop goes so fast, that it starts with another players turn.
Now how can I "stop" this for loop until the player has ran out of time (30 sec) OR has clicked any button?
Is there any way to make some kind of while loop without causing a freezing?
Thanks in advance!
I am currently programming a Texas Hold'Em online game, and I am encountering a problem.
There are turns for each player on the table, and it's running by for loop for each player.
I need to make a method that waits until the player has clicked either call, check, fold, raise or all-in button.
It is made like this:
Code:
for (var i = 0; i < tablecount; i++) {
/* Some code here that already works
*
*
*
*
*/
//Now the method to check if player has clicked a button
if (!turn_used) {
if (position_meeting(mouse_x, mouse_y, obj_btn_call) && mouse_check_button_pressed(mb_left)) {
turn_used = true;
}
if (position_meeting(mouse_x, mouse_y, obj_btn_fold) && mouse_check_button_pressed(mb_left)) {
turn_used = true;
}
// etc etc...
}
if (i == tablecount) {
alarm[0] = 30; // Now draw the cards to the table (3)
}
}
Now the code doesn't work because it checks if player has clicked a button, it has not because the loop goes so fast, that it starts with another players turn.
Now how can I "stop" this for loop until the player has ran out of time (30 sec) OR has clicked any button?
Is there any way to make some kind of while loop without causing a freezing?
Thanks in advance!