Skip to content

Commit

Permalink
Added comments
Browse files Browse the repository at this point in the history
  • Loading branch information
CMartin2288 committed Apr 21, 2024
1 parent aa8ed5f commit bfa4904
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
3 changes: 2 additions & 1 deletion Assets/Scripts/PlayerControl_NoGrav.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ void Update()
{
//Get how far left or right to move, apply it as a velocity
hori = Input.GetAxis("Horizontal");
//Rotate
rb.rotation += -hori*speed*Time.deltaTime;

//When pressing the gravity button, switch the gravity scale and jump direction
//When pressing the gravity button, add an upwards force from the player perspective
if(Input.GetButton("Jump"))
{
rb.AddForce(Quaternion.Euler(0,0,rb.rotation)*Vector3.up*force*Time.deltaTime);
Expand Down
21 changes: 18 additions & 3 deletions Assets/Scripts/PoseMinigame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ public class PoseMinigame : MonoBehaviour
// Start is called before the first frame update
void Start()
{
//Get reference
rb = GetComponent<Rigidbody2D>();

//Start on pose 0
currentPose = 0;

//Get components
Expand All @@ -68,16 +70,18 @@ void Update()
if(Input.GetButtonDown("Vertical"))
{
float vert = Input.GetAxis("Vertical");
//Flip
//Flip if minigame allows
if(requireFlip && vert > 0)
{
SR.flipX = !SR.flipX;
}
//Pose
//Pose if minigame allows
if(requirePose && vert < 0)
{
//Increment current pose, which cycles between 0, 1, and 2
currentPose = (currentPose+1) % 3;

//Display the correct pose
switch(currentPose)
{
case 0:
Expand Down Expand Up @@ -161,6 +165,7 @@ public IEnumerator PlayMinigame()
//Emergency correct
hasFailed = false;

//Wait a bit between the completion of each phase
yield return new WaitForSeconds(0.5f);
}

Expand All @@ -170,29 +175,39 @@ public IEnumerator PlayMinigame()

public void FailMinigame()
{
animator.enabled = true;
//Do nothing if invincibility cheat is active
if (invincibility == true)
{
return;
}

//Start animating
animator.enabled = true;

//Stop movement
rb.bodyType = RigidbodyType2D.Static;
rb.velocity = Vector3.zero;
animator.SetBool("isElectrocuted", true);

if (!hasDied)
{
//Play death sound
hurt.PlayOneShot(hurt.clip);
hasDied = true;
}

//Start to respawn
StartCoroutine(PlayerRespawn());
}

public IEnumerator PlayerRespawn()
{
//Give time for death animation to play
yield return new WaitForSeconds(1);
//Fade out of scene
SceneTransition.SetBool("isDead", true);
yield return new WaitForSeconds(3);
//Reload level
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
}
8 changes: 7 additions & 1 deletion Assets/Scripts/SceneChanger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,31 +25,37 @@ void Update()

}

//Transition to a scene by a given index number
public void toScene(int index)
{
SceneManager.LoadSceneAsync(index);
}

//Transition to a scene by a given scene name
public void toScene(string name)
{
SceneManager.LoadSceneAsync(name);
}


//Transition to the next scene in build order
public void NextLevel()
{
SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().buildIndex + 1);
}

//Reload the current scene
public void Reload()
{
SceneManager.LoadSceneAsync(SceneManager.GetActiveScene().name);
}

//Quit the game
public void Quit()
{
Application.Quit();
}

//After a specified number of seconds, transition to the given scene by ID
public IEnumerator AutoLoad(float seconds, int ID)
{
yield return new WaitForSeconds(seconds);
Expand Down
4 changes: 4 additions & 0 deletions Assets/Scripts/TrackObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@

public class TrackObject : MonoBehaviour
{
//The object to track
public GameObject trackedObject;
//Whether to copy the object's X position
public bool trackX;
//Whether to copy the object's Y position
public bool trackY;
//The Z position for this object
public float z;

// Start is called before the first frame update
Expand Down

0 comments on commit bfa4904

Please sign in to comment.