summaryrefslogtreecommitdiff
path: root/Camera2D.gd
diff options
context:
space:
mode:
authorrom <romangraef@gmail.com>2021-04-24 16:16:53 +0200
committerrom <romangraef@gmail.com>2021-04-24 16:16:53 +0200
commite2974c3c46336f6818c576445d37203f37c70595 (patch)
tree449c36a0d5905f38c31ded9ce8753a92440e820c /Camera2D.gd
parent14ecd3faa074a97a80db8c314ad7fbd4f810c080 (diff)
downloadldjam48-e2974c3c46336f6818c576445d37203f37c70595.tar.gz
ldjam48-e2974c3c46336f6818c576445d37203f37c70595.tar.bz2
ldjam48-e2974c3c46336f6818c576445d37203f37c70595.zip
Speedup
Diffstat (limited to 'Camera2D.gd')
-rw-r--r--Camera2D.gd17
1 files changed, 10 insertions, 7 deletions
diff --git a/Camera2D.gd b/Camera2D.gd
index d994397..c58fa22 100644
--- a/Camera2D.gd
+++ b/Camera2D.gd
@@ -7,15 +7,16 @@ extends Camera2D
onready var path : Path2D = get_node(@"../Path2D")
onready var points = path.curve.get_baked_points()
-export var max_speed = 10
-
+export var speedup = 600
+export var speedup_time = 5
+export var initial_speed = 100
+onready var current_speed = initial_speed
var pidx = 0
+var t = 0
# Called when the node enters the scene tree for the first time.
func _ready():
pass
-func current_speed():
- return max_speed
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
@@ -23,14 +24,16 @@ func _process(delta):
return
var next_point = points[pidx]
var dist : Vector2 = next_point - position
- print(dist.length(),"\t", current_speed() * delta)
- if dist.length() - current_speed() * delta < 0.5:
+ if t < speedup_time:
+ current_speed += speedup * max(0, min(speedup_time-t, delta))
+ t += delta
+ if dist.length() - current_speed * delta < 0.5:
position = next_point
pidx += 1
if pidx >= points.size():
pidx = -1
return
- var velocity = dist.normalized() * current_speed() * delta
+ var velocity = dist.normalized() * current_speed * delta
position += velocity