Score (First Devlog)
Tetris » Devlog
Small Update
I Have Successfully Made An Score, Makes The Game More Interesting And Fun
Code For It:
public class Board : MonoBehaviour { public int AddedPoints = 1; public int scoreOneLine = 100; public int scoreTwoLine = 300; public int scoreThreeLine = 300; public int scoreFourLine = 1200; public Text HUD_text; private int numberOfRowsThisTurn = 0; private int currentScore = 0; void Update () { UpdateScore (); UpdateUI (); } public void UpdateUI () { HUD_text.text = currentScore.ToString(); } public void UpdateScore () { if (Input.GetKey(KeyCode.DownArrow)) { PlacedOneShape (); } if (numberOfRowsThisTurn > 0) { if (numberOfRowsThisTurn == 1) { ClearedOneLine (); } else if (numberOfRowsThisTurn == 2) { ClearedTwoLines (); } else if (numberOfRowsThisTurn == 3) { ClearedThreeLines (); } else if (numberOfRowsThisTurn == 4) { ClearedFourLines (); } numberOfRowsThisTurn = 0; } } public void PlacedOneShape () { currentScore += 1; } public void ClearedOneLine () { currentScore += scoreOneLine; } public void ClearedTwoLines () { currentScore += scoreTwoLine; } public void ClearedThreeLines () { currentScore += scoreThreeLine; } public void ClearedFourLines () { currentScore += scoreFourLine; } //If Your Reading This, This is Later Down In My Code Where I Programmed How The Lines Disappear. Everything Under This Message Isn't In The Right Order!! public void LineClear(int row) { RectInt bounds = this.Bounds; // Clear all tiles in the row for (int col = bounds.xMin; col < bounds.xMax; col++) { Vector3Int position = new Vector3Int(col, row, 0); this.tilemap.SetTile(position, null); } numberOfRowsThisTurn++;
Files
Tetris.rar 17 MB
Dec 11, 2021
Leave a comment
Log in with itch.io to leave a comment.