Basic rotation and drop controls.

This commit is contained in:
Kaj Forney 2021-10-14 12:56:24 -06:00
parent 73f470a968
commit 83ab22c965
Signed by: kforney
GPG key ID: 3AB4E2E04CEF656F
3 changed files with 28 additions and 8 deletions

View file

@ -837,7 +837,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: -131, y: -53.90451}
m_AnchoredPosition: {x: -130.2, y: 190.6}
m_SizeDelta: {x: 437.3, y: 37.9045}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1386772421
@ -861,7 +861,7 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 12800000, guid: d10c7dd6930d6abde8068075ad403ff3, type: 3}
m_Font: {fileID: 12800000, guid: 10c39188eb0dddbd68a1ed308d740cd6, type: 3}
m_FontSize: 36
m_FontStyle: 0
m_BestFit: 0
@ -873,7 +873,7 @@ MonoBehaviour:
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: 0
m_Text: 'SCORE:'
--- !u!222 &1386772422
CanvasRenderer:
m_ObjectHideFlags: 0
@ -1168,12 +1168,16 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
spawnPoint: {x: 0, y: 0, z: 0}
tetrominoSquare: {fileID: 0}
tetrominoLine: {fileID: 0}
tetrominoSquare: {fileID: 7091960356501607795, guid: 8574b49e2210b483382f987b86d1d3af,
type: 3}
tetrominoLine: {fileID: 7091960356501607795, guid: d6ec5fab3480e3ba59d1fa2a9ebfa993,
type: 3}
tetrominoL: {fileID: 0}
tetrominoR: {fileID: 0}
tetrominoS: {fileID: 0}
tetrominoT: {fileID: 0}
tetrominoT: {fileID: 7091960356501607795, guid: ee7d3b3fab5b29b2fadfed207dd6b211,
type: 3}
tetrominoZ: {fileID: 0}
--- !u!4 &1955489875
Transform:
m_ObjectHideFlags: 0

View file

@ -13,6 +13,7 @@ public class tetrominoSpawnManager : MonoBehaviour
public GameObject tetrominoR;
public GameObject tetrominoS;
public GameObject tetrominoT;
public GameObject tetrominoZ;
private int nextTetromino = 0;
@ -34,7 +35,7 @@ public class tetrominoSpawnManager : MonoBehaviour
void spawnTetromino()
{
nextTetromino = Random.Range(1, 6);
nextTetromino = Random.Range(1, 7);
switch (nextTetromino)
{
case 0: //Square
@ -46,7 +47,7 @@ public class tetrominoSpawnManager : MonoBehaviour
case 2: //T-piece
Instantiate(tetrominoT, spawnPoint, Quaternion.identity);
break;
default:
default: //if it's not a piece I have a prefab for yet, default to square
Instantiate(tetrominoSquare, spawnPoint, Quaternion.identity);
break;
}

View file

@ -24,6 +24,21 @@ public class tetrominoUserControl : MonoBehaviour
{
activeTetromino.gameObject.transform.position += Vector3.right * 1.0f;
}
if (Input.GetButtonDown("tetrisDrop") && activeTetromino != null)
{
activeTetromino.gameObject.transform.position += Vector3.down * 1.0f;
}
if (Input.GetButtonDown("tetrisRotateLeft") && activeTetromino != null)
{
activeTetromino.gameObject.transform.Rotate(0,0,90,Space.World);
}
if (Input.GetButtonDown("tetrisRotateRight") && activeTetromino != null)
{
activeTetromino.gameObject.transform.Rotate(0,0,-90,Space.World);
}
}
public void setActiveTetromino(GameObject tetromino)