Game Programmer
This is a 2d platform game where you have to clear obstacles to complete the levels but you are not alone in your journey.
You can anywhere switch between your second view to help your first view to clear the level but you have to be quick, you have limited time to clear a level or the level will reset.
This game was made for BYOG GameJam 2021, I mostly focused on character movement and character switching while the other teammate done the dialoag system and maintain GameManager and UIManager.
While working on this project my main focuse is to create the player movenemt feels fun. To look player movement good we changed few things like while jumping we shrinked the scale in Y axis and while going left amd right we tilted(changed rotation) the player in Z axis
The idea of two players comes with the theme of the game jam which is Two Views, While making the two players playable in their own space we faced many problems.
private void FixedUpdate()
{
SlowDown();
if (!Input.GetKey(KeyCode.A) && !Input.GetKey(KeyCode.D))
{
moving = false;
rb.gameObject.transform.rotation = Quaternion.Euler(0, 0, 0);
if (winding)
Move(0);
}
if (Input.GetKey(KeyCode.Space) && (GameManager.instance.gameState == GameManager.GameState.Playing || GameManager.instance.gameState == GameManager.GameState.Player2))
Jump();
if (Input.GetKey(KeyCode.A) && (GameManager.instance.gameState == GameManager.GameState.Playing || GameManager.instance.gameState == GameManager.GameState.Player2))
{
Move(-1);
rb.gameObject.transform.rotation = Quaternion.Euler(0,0,15);
}
if (Input.GetKey(KeyCode.D) && (GameManager.instance.gameState == GameManager.GameState.Playing || GameManager.instance.gameState == GameManager.GameState.Player2))
{
Move(1);
rb.gameObject.transform.rotation = Quaternion.Euler(0, 0, -15);
}
}
public void Move(int dir)
{
moving = true;
float xVel = rb.velocity.x;
if (xVel < maxMoveSpeed && dir > 0)
{
rb.AddForce(moveSpeed * Time.deltaTime * Vector2.right * dir);
}
else if (xVel > -maxMoveSpeed && dir < 0)
{
rb.AddForce(moveSpeed * Time.deltaTime * Vector2.right * dir);
}
if (xVel > 0.2f && dir < 0)
rb.AddForce(moveSpeed * 3.2f * Time.deltaTime * -Vector2.right);
if (xVel < 0.2f && dir > 0)
rb.AddForce(moveSpeed * 3.2f * Time.deltaTime * Vector2.right);
}
private void Jump()
{
if (!grounded)
return;
grounded = false;
AudioManager.instance.play("Jump");
rb.velocity = new Vector2(rb.velocity.x, 0);
rb.AddForce(Vector2.up * jumpForce);
rb.gameObject.transform.localScale = new Vector3(transform.localScale.x, 2, 1f);
winding = false;
}
public void SlowDown()
{
if (moving) return;
//If no key pressed but still moving, slow down player
if (rb.velocity.x > 0.2f)
rb.AddForce(moveSpeed * Time.deltaTime * -Vector2.right);
else if (rb.velocity.x < -0.2f)
rb.AddForce(moveSpeed * Time.deltaTime * Vector2.right);
}
public void CheckWhichPlayerIsActive()
{
if (player1.active)
rb = player1.GetRb();
else
rb = player2.GetRb();
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.gameObject.layer == LayerMask.NameToLayer("Ground") || collision.gameObject.layer == LayerMask.NameToLayer("Player"))
{
PlayerController.instance.grounded = true;
}
}
public void UnActive()
{
rb.bodyType = RigidbodyType2D.Kinematic;
rb.velocity = Vector2.zero;
GetComponent().color = GameManager.instance.playerFadeColor;
active = false;
}
public void Active()
{
rb.bodyType = RigidbodyType2D.Dynamic;
rb.velocity = Vector2.zero;
GetComponent().color = new Color(255, 255, 255, 255);
CameraMovement.instance.target = gameObject.transform;
active = true;
}
I gained valuable skills in time management and improved my communication with team members during a 48-hour game development project. Specifically, when working on the player movement aspect, effective communication was crucial. Planning was essential, and we successfully executed our plan to meet the tight deadline. Overall, the experience taught me a lot.