Камера

This commit is contained in:
DIvan2000 2024-12-08 15:37:58 +04:00
parent d9aff4fdc4
commit 2a597676e6
4 changed files with 44 additions and 10 deletions

View File

@ -4,6 +4,7 @@ extends Node2D
var id_path: Array[Vector2i] var id_path: Array[Vector2i]
var target: Vector2i var target: Vector2i
var speed: float = 1 var speed: float = 1
var oxygen: float = 100
func is_walking() -> bool: func is_walking() -> bool:

View File

@ -47,6 +47,16 @@ right_mouse={
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(277, 13),"global_position":Vector2(286, 59),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null) "events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(277, 13),"global_position":Vector2(286, 59),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
] ]
} }
zoom_in={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":61,"unicode":61,"location":0,"echo":false,"script":null)
]
}
zoom_out={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":0,"key_label":45,"unicode":45,"location":0,"echo":false,"script":null)
]
}
[rendering] [rendering]

View File

@ -61,10 +61,6 @@ func _physics_process(delta: float) -> void:
if Input.is_action_just_pressed("ui_cancel"): if Input.is_action_just_pressed("ui_cancel"):
change_instrument(instruments.NULL) change_instrument(instruments.NULL)
if Input.is_action_just_pressed("ui_right"):
change_instrument(selected_instrument+1)
if Input.is_action_just_pressed("ui_left"):
change_instrument(selected_instrument-1)
match selected_instrument: match selected_instrument:
instruments.NULL: instruments.NULL:
@ -107,5 +103,16 @@ func change_instrument(new: instruments):
lmb = false lmb = false
rmb = false rmb = false
func _input(event): func _process(delta: float) -> void:
pass if Input.is_action_pressed("ui_right"):
$Camera2D.translate(Vector2.RIGHT*320*delta/$Camera2D.zoom)
if Input.is_action_pressed("ui_left"):
$Camera2D.translate(Vector2.LEFT*320*delta/$Camera2D.zoom)
if Input.is_action_pressed("ui_up"):
$Camera2D.translate(Vector2.UP*320*delta/$Camera2D.zoom)
if Input.is_action_pressed("ui_down"):
$Camera2D.translate(Vector2.DOWN*320*delta/$Camera2D.zoom)
if Input.is_action_just_pressed("zoom_in"):
$Camera2D.zoom+=Vector2.ONE*0.25
if Input.is_action_just_pressed("zoom_out"):
$Camera2D.zoom-=Vector2.ONE*0.25

File diff suppressed because one or more lines are too long