add more spacing between functions
This commit is contained in:
@@ -5,9 +5,11 @@ const CURSOR_HOTSPOT = Vector2(32, 32)
|
||||
var cursor_normal := load("res://assets/textures/gui/cursor.png")
|
||||
var cursor_click := load("res://assets/textures/gui/cursor_click.png")
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CONFINED
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseButton:
|
||||
if (event as InputEventMouseButton).pressed:
|
||||
@@ -15,5 +17,6 @@ func _input(event: InputEvent) -> void:
|
||||
else:
|
||||
_set_cursor(cursor_normal)
|
||||
|
||||
|
||||
func _set_cursor(image: Resource) -> void:
|
||||
Input.set_custom_mouse_cursor(image, Input.CURSOR_ARROW, CURSOR_HOTSPOT)
|
||||
|
||||
@@ -12,6 +12,7 @@ var vectors_to_draw: Array[Dictionary] = []
|
||||
var markers_to_draw: Array[Dictionary] = []
|
||||
var circles_to_draw: Array[Dictionary] = []
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
camera = get_viewport().get_camera_3d()
|
||||
layer = 999
|
||||
@@ -19,43 +20,51 @@ func _ready() -> void:
|
||||
control.draw.connect(_on_control_draw)
|
||||
add_child(control)
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if not visible:
|
||||
return
|
||||
control.queue_redraw()
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("toggle_debug"):
|
||||
visible = not visible
|
||||
vectors_to_draw.clear()
|
||||
|
||||
|
||||
func vector(from: Vector3, to: Vector3, color: Color = DEFAULT_COLOR) -> void:
|
||||
if not visible:
|
||||
return
|
||||
|
||||
vectors_to_draw.append({"from": from, "to": to, "color": color})
|
||||
|
||||
|
||||
func marker(pos: Vector3, radius: float = MARKER_RADIUS, color: Color = DEFAULT_COLOR) -> void:
|
||||
if not visible:
|
||||
return
|
||||
|
||||
markers_to_draw.append({"pos": pos, "radius": radius, "color": color})
|
||||
|
||||
|
||||
func circle(pos: Vector3, color: Color = DEFAULT_COLOR) -> void:
|
||||
if not visible:
|
||||
return
|
||||
|
||||
circles_to_draw.append({"pos": pos, "color": color})
|
||||
|
||||
|
||||
func _unproject(pos: Vector3) -> Vector2:
|
||||
return camera.unproject_position(pos)
|
||||
|
||||
|
||||
func _draw_vector(from: Vector3, to: Vector3, color: Color) -> void:
|
||||
var start := _unproject(from)
|
||||
var end := _unproject(to)
|
||||
control.draw_line(start, end, color, LINE_WIDTH)
|
||||
_draw_triangle(end, start.direction_to(end), 5, color)
|
||||
|
||||
|
||||
func _draw_triangle(pos: Vector2, dir: Vector2, size: float, color: Color) -> void:
|
||||
var a := pos + dir * size
|
||||
var b := pos + dir.rotated(2 * PI / 3) * size
|
||||
@@ -63,6 +72,7 @@ func _draw_triangle(pos: Vector2, dir: Vector2, size: float, color: Color) -> vo
|
||||
var points := PackedVector2Array([a, b, c])
|
||||
control.draw_polygon(points, PackedColorArray([color]))
|
||||
|
||||
|
||||
func _draw_marker(pos: Vector3, radius: float, color: Color) -> void:
|
||||
var x_start := _unproject(pos + (Vector3.LEFT * radius))
|
||||
var x_end := _unproject(pos + (Vector3.RIGHT * radius))
|
||||
@@ -76,10 +86,12 @@ func _draw_marker(pos: Vector3, radius: float, color: Color) -> void:
|
||||
var z_end := camera.unproject_position(pos + (Vector3.BACK * radius))
|
||||
control.draw_line(z_start, z_end, color, LINE_WIDTH)
|
||||
|
||||
|
||||
func _draw_circle(pos: Vector3, color: Color) -> void:
|
||||
var point := camera.unproject_position(pos)
|
||||
control.draw_circle(point, CIRCLE_RADIUS, color)
|
||||
|
||||
|
||||
func _on_control_draw() -> void:
|
||||
if not visible:
|
||||
return
|
||||
|
||||
@@ -2,10 +2,12 @@ extends Node
|
||||
|
||||
var is_fullscreen: bool = false
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_pressed("toggle_fullscreen"):
|
||||
_toggle_fullscreen()
|
||||
|
||||
|
||||
func _toggle_fullscreen() -> void:
|
||||
is_fullscreen = not is_fullscreen
|
||||
if is_fullscreen:
|
||||
|
||||
@@ -22,6 +22,7 @@ var mouse_position: Vector2 = Vector2()
|
||||
var zoom_value: float = 0.3
|
||||
var zoom_raw: float = zoom_value
|
||||
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
zoom_value = lerp(zoom_value, zoom_raw, delta * ZOOM_DAMP)
|
||||
|
||||
@@ -37,6 +38,7 @@ func _process(delta: float) -> void:
|
||||
|
||||
DebugDraw.marker(target_position, 0.05)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
mouse_position = (event as InputEventMouseMotion).position
|
||||
@@ -50,6 +52,7 @@ func _input(event: InputEvent) -> void:
|
||||
zoom_raw += ZOOM_SPEED
|
||||
zoom_raw = clamp(zoom_raw, 0, 1)
|
||||
|
||||
|
||||
func _handle_movement(delta: float) -> void:
|
||||
var viewport_size := get_viewport().get_visible_rect().size
|
||||
|
||||
|
||||
Reference in New Issue
Block a user