Hi guys,
I made a Tetris game and want to make the key for rotating the blocks change randomly after each keypress.
For example: first time using the “R” button in order to rotate the block but if I want to rotate the same block again, then I need to try another button…
void Update() {
if (State != TetrimoState.Fixed && State != TetrimoState.Preview && State != TetrimoState.Spawning) {
if (State != TetrimoState.Landed && Input.GetAxis("Vertical") < 0)
StartCoroutine(FallingDown());
if (Input.GetButtonDown("Horizontal"))
StartCoroutine(MoveHorizontal());
// Set "up" as alternative button for Jump (Project => Input)
if ((Input.GetButton("Jump")) && Time.time > NextSwap) {
if (this.CanRotate) {
StartCoroutine(RotateTetrimo());
NextSwap = Time.time + SwapCooldown;
}
}
// Automatic falling down
if (NextFall < 0) {
StartCoroutine(FallingDown());
NextFall = FallingCooldown;
}
NextFall -= FallingSpeed * Time.deltaTime;
}
if (State == TetrimoState.Preview) {
transform.Rotate(0, 1f, 0, Space.World);
}