anF
anF
CC#
Created by anF on 1/1/2024 in #help
tetromino is phasing through my grid in unity
aight thanks i will check out the discord
5 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
buy playing around with some stuff
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
I ended up fixing my problem
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
yeah
29 replies
CC#
Created by anF on 12/30/2023 in #help
C# Code Help
thanks
12 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
its kinda out dated tho cuz his code aint even working
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
I have been following this video serires and copying what the guy does
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
will look at that
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
my teacher is making me do a multimedia system where I gotta make a game its so dumb cuz she hasent even shown us how to use any programs its a big assighment
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
that must be it hmmm
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
i just started c sharp today
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
yeah
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
the two sides are fine its just this bottom part
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
so I am making a tetris game and my block is phasing through the bottom part of the grid I am trying to make boundrys that the block cant past
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
// using UnityEngine;

public class Tetromino : MonoBehaviour
{
float fall = 0;
public float fallSpeed = 1;

// Use this for initialization
void Start()
{

}

// Update is called once per frame
void Update()
{
CheckUserInput();
}

void CheckUserInput()
{
if (Input.GetKeyDown(KeyCode.RightArrow))
{
SafeMove(new Vector3(1, 0, 0));
}
else if (Input.GetKeyDown(KeyCode.LeftArrow))
{
SafeMove(new Vector3(-1, 0, 0));
}
else if (Input.GetKeyDown(KeyCode.UpArrow))
{
SafeRotate(90);
}
else if (Input.GetKeyDown(KeyCode.DownArrow) || Time.time - fall >= fallSpeed)
{
SafeMove(new Vector3(0, -1, 0));
fall = Time.time;
}
}

void SafeMove(Vector3 vec)
{
transform.position += vec;
if (!CheckIsValidPosition())
{
transform.position -= vec;
}
}

void SafeRotate(float degree)
{
transform.Rotate(0, 0, degree);
if (!CheckIsValidPosition())
{
transform.Rotate(0, 0, -degree);
}
}

bool CheckIsValidPosition()
{
foreach (Transform mino in transform)
{
Vector2 pos = FindObjectOfType<Game>().Round(mino.position);

if (!FindObjectOfType<Game>().CheckInsideGrid(pos))
{
return false;
}
}

return true;
}
}
// using UnityEngine;

public class Tetromino : MonoBehaviour
{
float fall = 0;
public float fallSpeed = 1;

// Use this for initialization
void Start()
{

}

// Update is called once per frame
void Update()
{
CheckUserInput();
}

void CheckUserInput()
{
if (Input.GetKeyDown(KeyCode.RightArrow))
{
SafeMove(new Vector3(1, 0, 0));
}
else if (Input.GetKeyDown(KeyCode.LeftArrow))
{
SafeMove(new Vector3(-1, 0, 0));
}
else if (Input.GetKeyDown(KeyCode.UpArrow))
{
SafeRotate(90);
}
else if (Input.GetKeyDown(KeyCode.DownArrow) || Time.time - fall >= fallSpeed)
{
SafeMove(new Vector3(0, -1, 0));
fall = Time.time;
}
}

void SafeMove(Vector3 vec)
{
transform.position += vec;
if (!CheckIsValidPosition())
{
transform.position -= vec;
}
}

void SafeRotate(float degree)
{
transform.Rotate(0, 0, degree);
if (!CheckIsValidPosition())
{
transform.Rotate(0, 0, -degree);
}
}

bool CheckIsValidPosition()
{
foreach (Transform mino in transform)
{
Vector2 pos = FindObjectOfType<Game>().Round(mino.position);

if (!FindObjectOfType<Game>().CheckInsideGrid(pos))
{
return false;
}
}

return true;
}
}
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
using UnityEngine; public class Tetromino : MonoBehaviour { float fall = 0; public float fallSpeed = 1; // Use this for initialization void Start() { } // Update is called once per frame void Update() { CheckUserInput(); } void CheckUserInput() { if (Input.GetKeyDown(KeyCode.RightArrow)) { SafeMove(new Vector3(1, 0, 0)); } else if (Input.GetKeyDown(KeyCode.LeftArrow)) { SafeMove(new Vector3(-1, 0, 0)); } else if (Input.GetKeyDown(KeyCode.UpArrow)) { SafeRotate(90); } else if (Input.GetKeyDown(KeyCode.DownArrow) || Time.time - fall >= fallSpeed) { SafeMove(new Vector3(0, -1, 0)); fall = Time.time; } } void SafeMove(Vector3 vec) { transform.position += vec; if (!CheckIsValidPosition()) { transform.position -= vec; } } void SafeRotate(float degree) { transform.Rotate(0, 0, degree); if (!CheckIsValidPosition()) { transform.Rotate(0, 0, -degree); } } bool CheckIsValidPosition() {
foreach (Transform mino in transform) { Vector2 pos = FindObjectOfType<Game>().Round(mino.position); if (!FindObjectOfType<Game>().CheckInsideGrid(pos)) { return false; } } return true; } }
29 replies
CC#
Created by anF on 12/30/2023 in #help
Tetris Block Phasing through grid
here is my current code
29 replies
CC#
Created by anF on 12/30/2023 in #help
C# Code Help
thanks I will try to do that
12 replies
CC#
Created by anF on 12/30/2023 in #help
C# Code Help
thats the code
12 replies