mirror of
https://git.kittycat.homes/zoe/codename-routes.git
synced 2024-08-15 03:18:26 +00:00
tilemaps!
This commit is contained in:
parent
f5f66b5918
commit
b38a39e127
15 changed files with 146 additions and 6 deletions
21
godot/world/worldcam.gd
Normal file
21
godot/world/worldcam.gd
Normal file
|
@ -0,0 +1,21 @@
|
|||
extends Camera2D
|
||||
export var min_zoom = 0.4
|
||||
export var speed = 200
|
||||
var zoomlevel = 0.4
|
||||
|
||||
func _process(delta):
|
||||
move_around(delta)
|
||||
handle_zoom()
|
||||
|
||||
func move_around(delta):
|
||||
var xdirection = Input.get_action_strength("camera_right") - Input.get_action_strength("camera_left")
|
||||
var ydirection = Input.get_action_strength("camera_down") - Input.get_action_strength("camera_up")
|
||||
var direction = Vector2(xdirection, ydirection).normalized() * delta * speed * zoom
|
||||
position = lerp(position, position + direction, 2)
|
||||
|
||||
func handle_zoom():
|
||||
if Input.is_action_just_pressed("zoom_in"):
|
||||
zoomlevel = clamp(zoomlevel - 0.1, 0.1, 2)
|
||||
if Input.is_action_just_pressed("zoom_out"):
|
||||
zoomlevel = clamp(zoomlevel + 0.1, 0.1, 2)
|
||||
zoom = Vector2(zoomlevel, zoomlevel)
|
Loading…
Add table
Add a link
Reference in a new issue