mirror of
https://github.com/boudji-ludwig-pett/cnam-geometry-dash.git
synced 2025-06-10 22:20:40 +02:00
fea: add bonus boost (#50)
Co-authored-by: Djelal BOUDJI <djelal@gmail.com>
This commit is contained in:
@ -9,7 +9,7 @@ public class NormalGameMode : IGameMode
|
||||
|
||||
public void Update(Player player)
|
||||
{
|
||||
player.RigidBody.linearVelocity = new Vector2(HorizontalSpeed, player.RigidBody.linearVelocity.y);
|
||||
player.RigidBody.linearVelocity = new Vector2(HorizontalSpeed * player.SpeedMultiplier, player.RigidBody.linearVelocity.y);
|
||||
|
||||
if (player.HasStarted && player.IsColliding && Input.GetKey(JumpKey) && player.CanJump)
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ public class ShipGameMode : IGameMode
|
||||
|
||||
public void Update(Player player)
|
||||
{
|
||||
player.RigidBody.linearVelocity = new Vector2(HorizontalSpeed, player.RigidBody.linearVelocity.y);
|
||||
player.RigidBody.linearVelocity = new Vector2(HorizontalSpeed * player.SpeedMultiplier, player.RigidBody.linearVelocity.y);
|
||||
|
||||
bool jumpPressed = Input.GetKey(JumpKey);
|
||||
|
||||
|
@ -13,6 +13,7 @@ public class Player : MonoBehaviour
|
||||
public bool CanJump { get; set; } = true;
|
||||
|
||||
public IGameMode CurrentGameMode { get; set; }
|
||||
public float SpeedMultiplier = 1f;
|
||||
|
||||
public void Awake()
|
||||
{
|
||||
@ -67,6 +68,16 @@ public class Player : MonoBehaviour
|
||||
SpriteRenderer.sprite = Resources.Load<Sprite>("Shapes/BaseSquare");
|
||||
ChangeGameMode(new NormalGameMode());
|
||||
}
|
||||
else if (collision.CompareTag("BonusBoostSpeed"))
|
||||
{
|
||||
SpeedMultiplier *= 1.5f;
|
||||
Destroy(collision.gameObject);
|
||||
}
|
||||
else if (collision.CompareTag("BonusSlowSpeed"))
|
||||
{
|
||||
SpeedMultiplier /= 1.5f;
|
||||
Destroy(collision.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeGameMode(IGameMode newMode)
|
||||
|
Reference in New Issue
Block a user