Skip to content

Commit

Permalink
commenting my code
Browse files Browse the repository at this point in the history
  • Loading branch information
NervousGentleman committed Apr 22, 2024
1 parent 5b2be1e commit 6503a02
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
6 changes: 5 additions & 1 deletion Assets/Scripts/CheatCodes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void Start()
timeDif = maxTimeDif;
}

// Update is called once per frame
// checks for the inputing of codes
void Update()
{
timeDif -= Time.deltaTime;
Expand Down Expand Up @@ -51,12 +51,14 @@ void Update()
if(!cheatOnCooldown) checkPatterns();
}

// adds inputs to code buffer, increases max time allowed with every correct letter inputed
void addToBuffer(string c)
{
timeDif = maxTimeDif;
Buffer += c;
}

// checks if current buffer matches a valid code and activates the coresponding cheat
void checkPatterns()
{
if (Buffer.EndsWith(validPatterns[0]))
Expand All @@ -73,11 +75,13 @@ void checkPatterns()
}
}

// disabler for invincibility text
void QuickDisable()
{
TextActivator.en = false;
}

// resets cooldown on invincibility cheat input
private IEnumerator CheatCooldown()
{
yield return new WaitForSeconds(maxTimeDif);
Expand Down
4 changes: 4 additions & 0 deletions Assets/Scripts/EthanMinigame/BallBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@ public class Ballbehavior : MonoBehaviour
Rigidbody2D rb;
public GameObject[] LivesImage;

// sets ball velocity, grabs a reference to the generator
void Start()
{
generator = FindObjectOfType<Generator>();
rb = GetComponent<Rigidbody2D>();
rb.velocity = Vector2.down * 3f;
}

// main game logic, controlls game over, lives lost, and ball respawning
void Update()
{
if(transform.position.y < minY)
Expand All @@ -44,6 +46,7 @@ void Update()
rb.velocity = Vector3.ClampMagnitude(rb.velocity, maxV);
}
}
// destroys "bricks" when ball colides with them
private void OnCollisionEnter2D(Collision2D collision)
{
if(collision.gameObject.CompareTag("brick"))
Expand All @@ -53,6 +56,7 @@ private void OnCollisionEnter2D(Collision2D collision)
}
}

// loads gameover scene if player fails
void GameOver()
{
SceneManager.LoadScene(FailScene);
Expand Down
5 changes: 5 additions & 0 deletions Assets/Scripts/EthanMinigame/Generator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class Generator : MonoBehaviour
private int bc;
public int WinScene;

// populates the screen with "bricks"
private void Awake()
{
for (int i = 0; i< size.x; i++)
Expand All @@ -24,6 +25,8 @@ private void Awake()
}
}
}

// tallys the total bricks and loads new scene when they are all gone.
public void DestroyBrick()
{
bc--;
Expand All @@ -32,6 +35,8 @@ public void DestroyBrick()
LoadNewScene();
}
}

// loads next scene on game win
private void LoadNewScene()
{
UnityEngine.SceneManagement.SceneManager.LoadScene(WinScene);
Expand Down
1 change: 1 addition & 0 deletions Assets/Scripts/EthanMinigame/PaddleMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ void Start()
// Update is called once per frame
void Update()
{
// Player Controls for Paddle
movementHorizontal = Input.GetAxis("Horizontal");
if ((movementHorizontal > 0 && transform.position.x < maxX) || (movementHorizontal<0 && transform.position.x > -maxX))
{
Expand Down
3 changes: 2 additions & 1 deletion Assets/Scripts/TextActivator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ public class TextActivator : MonoBehaviour
public static bool en = false;
private TMP_Text m_TextComponent;

// reference to TMP component
void Awake()
{
m_TextComponent = GetComponent<TMP_Text>();
}

// Update is called once per frame
// checks if en is true every frame, and displays text if so
void Update()
{
if (en)
Expand Down

0 comments on commit 6503a02

Please sign in to comment.