everything_has_a_price_jam/CameraMove.gd
2026-09-26 21:13:20 -06:00

41 lines
900 B
GDScript

extends Camera2D
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
var mouse: = get_viewport().get_mouse_position()
var size: = get_viewport().get_visible_rect().size
if (mouse.x < (0.10*size.x)):
position.x -= 3
elif (mouse.x > (0.90*size.x)):
position.x += 3
if (mouse.y < (0.10*size.y)):
position.y -= 3
elif (mouse.y > (0.90*size.y)):
position.y += 3
func _input(event):
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_WHEEL_UP and event.pressed:
zoom.x +=1
zoom.y +=1
elif event.button_index == MOUSE_BUTTON_WHEEL_DOWN and event.pressed:
if zoom.x - 1 < 1:
zoom.x = 1
else:
zoom.x -= 1
if zoom.y - 1 < 1:
zoom.y = 1
else:
zoom.y -= 1