Game: Speed accelerates with time

parent 1e39ec4c
...@@ -8,6 +8,7 @@ namespace Assets.Scripts ...@@ -8,6 +8,7 @@ namespace Assets.Scripts
public class GameController : MonoBehaviour public class GameController : MonoBehaviour
{ {
public static int PoolSize = 256; public static int PoolSize = 256;
public static float Speed = 4f;
public GameObject Wall; public GameObject Wall;
public GameObject BG; public GameObject BG;
...@@ -27,7 +28,9 @@ namespace Assets.Scripts ...@@ -27,7 +28,9 @@ namespace Assets.Scripts
void Update() void Update()
{ {
Camera.main.transform.Translate(new Vector3(4f*Time.deltaTime, 0, 0)); if (Speed < 16f)
Speed += 0.0025f;
Camera.main.transform.Translate(new Vector3(Speed * Time.deltaTime, 0, 0));
var rightBorder = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width, var rightBorder = Camera.main.ScreenToWorldPoint(new Vector3(Screen.width,
Screen.height, 0)).x; Screen.height, 0)).x;
var leftBorder = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x; var leftBorder = Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x;
......
...@@ -31,7 +31,8 @@ public class UIController : MonoBehaviour ...@@ -31,7 +31,8 @@ public class UIController : MonoBehaviour
{ {
Distance.text = (int.Parse(Distance.text) + 1).ToString(); Distance.text = (int.Parse(Distance.text) + 1).ToString();
_player.Score += 1; _player.Score += Mathf.RoundToInt(
1f * (GameController.Speed / 4f));
Score.text = _player.Score.ToString(); Score.text = _player.Score.ToString();
NbVials.text = _player.NbVials.ToString(); NbVials.text = _player.NbVials.ToString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment