Basically my game is like dance dance revolution where a random arrow from the 4 arrows light up and the user must enter the corresponding direction, either by WASD or arrow keys. But I want to add a scenario where the game deducts points when the user enter the wrong input. Below is a sample of what I wrote for the up arrow showing up.
if (RandomID == 0)
{
sprites[RandomID].GetComponent<SpriteRenderer>().color = new Color(1, 0.61f, 0, 1);
if (Input.GetKeyDown(KeyCode.UpArrow))
{
score = score + 10;
//Debug.Log(score);
//scoreBoard = score.ToString("0");
sprites[RandomID].GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1);
RandomID = Random.Range(0, sprites.Length);
Debug.Log(RandomID);
yield return new WaitForSeconds(sleepTime);
}
else if (Input.GetKeyDown(KeyCode.W))
{
score = score + 10;
//Debug.Log(score);
//scoreBoard = score.ToString("0");
sprites[RandomID].GetComponent<SpriteRenderer>().color = new Color(1, 1, 1, 1);
RandomID = Random.Range(0, sprites.Length);
Debug.Log(RandomID);
yield return new WaitForSeconds(sleepTime);
}else
{
score = score - 10;
}
}
}