I am trying to add code to allow the user to hit space and have the block move to the bottom of the screen, like a lot of tetris games have.
I know how to make this work but I’m having some problems.
// QuickFall
else if (Input.GetKeyDown(KeyCode.Space)) {
// Modify position
// See if valid
while (isValidGridPos ()) {
// It's valid. Update grid.
updateGrid ();
transform.position += new Vector3 (0, -1, 0);
Grid.deleteFullRows ();
}
else
{
transform.position += new Vector3 (0, 1, 0);
Grid.deleteFullRows ();
}
}
If you can see the while part:
while (isValidGridPos ()) {
This is checking that the position it is moving the block to is still within the game area.
However I don’t know how to check if it isnt (such as isNotValidGridPos ()) )
Does anyone have any ideas?
Thankyou