How to make a CheckMate mechanic

I’m trying to make a game similar to chess, and I specifically am looking for help on how to make a mechanic similar to check mate.
When one type of piece is left, and it cannot make any valid move, in this case, anywhere it can go, it’d get attacked, I want the other player to win. I’m not sure how to do this.

I’ve been having issues on how to identify that all the moves that would’ve been valid, are now not valid, therefore the piece is stuck, and therefore lost.

1 Like

Damn i remember your game when you were starting it

Anyway i know the logic and i don’t know exact execution since i don’t understand your events

BUT core idea is
You need to split turns from 2 to 4
Now you have either its turn of red or blue pieces

What you need is buffer between turns
So it would be like number variable going 0 1 2 3
Where 1 and 3 are turns 1 of blue pieces and 3 of red pieces

So in 0 turn you check if BLUE pieces can make any turn

And how i went about it is adding value to some variable i call Timer
It goes like this
When turn 0 starts you just add 1 to Timer cosntantly
So it goes up AFTER it reaches some value for example 10 or 20 or whatever
You change turn to 1
Where if there is NO move blue pieces can perform then red wins
If there is you switch turn to 1 and set timer to 0
Timer can run only when there is turn 0 or 2

And that is basic concept
I did exactly that here

Where between each turn there is that buffer turn where all pieces can move and if nothing is moving (expanding)
Timer just count up
Where i set it back to 0 constantly if anything moves to reset timer
So 1st it lets expand all pieces and then checks if there are pieces left of each color before going to next turn

So your only concern now is to check if there is at least ONE move player can perform
And if so you simply start next turn