chore: restructured project
All checks were successful
Coding Quality / Build and analyze (pull_request) Successful in 2m10s
All checks were successful
Coding Quality / Build and analyze (pull_request) Successful in 2m10s
This commit is contained in:
52
Experiments/Recuration/Scripts/RecurionCamera.gd
Normal file
52
Experiments/Recuration/Scripts/RecurionCamera.gd
Normal file
@@ -0,0 +1,52 @@
|
||||
extends Camera2D
|
||||
|
||||
class_name RecurionCamera
|
||||
|
||||
@export var movement_speed: float = 1
|
||||
|
||||
var mouse_pos_a: Vector2 = Vector2.ZERO
|
||||
var mouse_pos_b: Vector2 = Vector2.ZERO
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
process_keyboard_input(delta)
|
||||
process_mouse_input()
|
||||
|
||||
|
||||
func process_keyboard_input(delta: float):
|
||||
var direction: Vector2 = Vector2.ZERO
|
||||
|
||||
if (Input.is_action_pressed("w")):
|
||||
direction += Vector2.UP
|
||||
if (Input.is_action_pressed("s")):
|
||||
direction += Vector2.DOWN
|
||||
if (Input.is_action_pressed("a")):
|
||||
direction += Vector2.LEFT
|
||||
if (Input.is_action_pressed("d")):
|
||||
direction += Vector2.RIGHT
|
||||
direction = direction.normalized() * movement_speed
|
||||
position += direction * delta * 100
|
||||
|
||||
|
||||
func process_mouse_input():
|
||||
if (Input.is_action_just_pressed("mouse_down")):
|
||||
mouse_pos_a = get_global_mouse_position()
|
||||
mouse_pos_b = mouse_pos_a
|
||||
|
||||
elif (Input.is_action_pressed("mouse_down")):
|
||||
mouse_pos_b = get_global_mouse_position()
|
||||
|
||||
position = mouse_pos_a - mouse_pos_b + position
|
||||
|
||||
elif (Input.is_action_just_released("mouse_down")):
|
||||
mouse_pos_a = Vector2.ZERO
|
||||
mouse_pos_b = Vector2.ZERO
|
||||
|
||||
mouse_pos_b = mouse_pos_a
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if (event is InputEventMouseButton):
|
||||
var zoom_value = Input.get_axis("scroll_down", "scroll_up")
|
||||
if (zoom.y + zoom_value > 0.0):
|
||||
zoom += Vector2.ONE * zoom_value
|
||||
Reference in New Issue
Block a user