Виртуальный курсор (для управления с геймпада)

This commit is contained in:
Евгений Титаренко 2024-08-09 19:07:35 +03:00
parent d42bd00c3d
commit bbb66a5273
12 changed files with 135 additions and 8 deletions

View file

@ -28,26 +28,31 @@
vertices = PackedVector2Array(312, -944, 192, -944, 40, -984, 96, -984, 320, -816, 200, -816, 48, -888, 56, -888, 40, -760, 56, -760, 440, -584, -120, -584, -120, -720, 312, -888, 440, -1080, 280, -984, 280, -1032, -72, -760, -120, -1080, 224, -1032, 224, -984, 144, -984, 144, -1032, 96, -1032, 192, -888, 176, -888, 176, -944, 56, -944, -8, -984, 200, -760, 176, -760, 176, -816, 56, -816, -72, -888, 440, -376, 440, -168, 168, -168, 168, -296, -232, -376, -408, -296, -408, -856, -232, -720, -120, -856, -80, -816, 320, -760, -72, -944, 40, -816, 48, -944, -8, -1032, 40, -1032)
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3), PackedInt32Array(4, 5, 6, 7), PackedInt32Array(8, 9, 10, 11, 12), PackedInt32Array(13, 0, 14, 10, 4), PackedInt32Array(14, 0, 15, 16), PackedInt32Array(17, 8, 12), PackedInt32Array(18, 14, 16, 19), PackedInt32Array(19, 20, 21, 22), PackedInt32Array(18, 19, 22), PackedInt32Array(18, 22, 23), PackedInt32Array(1, 24, 25, 26), PackedInt32Array(2, 1, 26), PackedInt32Array(2, 26, 27, 28), PackedInt32Array(5, 29, 30, 31), PackedInt32Array(6, 5, 31), PackedInt32Array(6, 31, 32, 33), PackedInt32Array(34, 35, 36, 37), PackedInt32Array(38, 34, 37, 39), PackedInt32Array(38, 39, 40, 41), PackedInt32Array(17, 12, 41, 40, 42, 43), PackedInt32Array(29, 44, 10), PackedInt32Array(20, 15, 0), PackedInt32Array(33, 43, 42, 18, 45), PackedInt32Array(30, 29, 10), PackedInt32Array(10, 44, 4), PackedInt32Array(24, 13, 4), PackedInt32Array(9, 30, 10), PackedInt32Array(32, 9, 8, 46), PackedInt32Array(33, 32, 46), PackedInt32Array(33, 46, 43), PackedInt32Array(25, 24, 4), PackedInt32Array(7, 25, 4), PackedInt32Array(27, 7, 6, 47), PackedInt32Array(28, 27, 47), PackedInt32Array(28, 47, 45), PackedInt32Array(28, 45, 18, 48), PackedInt32Array(21, 20, 0), PackedInt32Array(49, 48, 18), PackedInt32Array(49, 18, 23), PackedInt32Array(49, 23, 3, 2), PackedInt32Array(0, 3, 21)])
outlines = Array[PackedVector2Array]([PackedVector2Array(168, -168, 440, -168, 440, -376, -232, -376, -232, -720, -120, -720, -120, -584, 440, -584, 440, -1080, -120, -1080, -120, -856, -408, -856, -408, -296, 168, -296), PackedVector2Array(-72, -760, 40, -760, 40, -816, -80, -816), PackedVector2Array(56, -816, 56, -760, 176, -760, 176, -816), PackedVector2Array(200, -760, 320, -760, 320, -816, 200, -816), PackedVector2Array(-72, -888, 48, -888, 48, -944, -72, -944), PackedVector2Array(56, -944, 56, -888, 176, -888, 176, -944), PackedVector2Array(192, -888, 312, -888, 312, -944, 192, -944), PackedVector2Array(-8, -984, 40, -984, 40, -1032, -8, -1032), PackedVector2Array(96, -984, 144, -984, 144, -1032, 96, -1032), PackedVector2Array(224, -1032, 224, -984, 280, -984, 280, -1032)])
source_geometry_group_name = &"navigation_polygon_source_group"
[sub_resource type="NavigationPolygon" id="NavigationPolygon_v2a1f"]
vertices = PackedVector2Array(897, -96, 897, 129, 607, 129, 607, -96)
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3)])
outlines = Array[PackedVector2Array]([PackedVector2Array(607, -96, 607, 129, 897, 129, 897, -96)])
source_geometry_group_name = &"navigation_polygon_source_group"
[sub_resource type="NavigationPolygon" id="NavigationPolygon_2d3fn"]
vertices = PackedVector2Array(897, -512, 897, -287, 607, -287, 607, -512)
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3)])
outlines = Array[PackedVector2Array]([PackedVector2Array(607, -512, 607, -287, 897, -287, 897, -512)])
source_geometry_group_name = &"navigation_polygon_source_group"
[sub_resource type="NavigationPolygon" id="NavigationPolygon_ackae"]
vertices = PackedVector2Array(447, 832, 865, 832, 865, 1153, 447, 1153)
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3)])
outlines = Array[PackedVector2Array]([PackedVector2Array(447, 1153, 865, 1153, 865, 832, 447, 832)])
source_geometry_group_name = &"navigation_polygon_source_group"
[sub_resource type="NavigationPolygon" id="NavigationPolygon_wwnnq"]
vertices = PackedVector2Array(-48, -1870, 242, -1870, 242, -1645, -48, -1645)
polygons = Array[PackedInt32Array]([PackedInt32Array(0, 1, 2, 3)])
outlines = Array[PackedVector2Array]([PackedVector2Array(-48, -1645, 242, -1645, 242, -1870, -48, -1870)])
source_geometry_group_name = &"navigation_polygon_source_group"
[node name="level" type="Node2D"]
script = ExtResource("1_cxv3e")

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=23 format=3 uid="uid://dhn7yt46fyac8"]
[gd_scene load_steps=24 format=3 uid="uid://dhn7yt46fyac8"]
[ext_resource type="PackedScene" uid="uid://bhulqhxesd5gc" path="res://prefabs/player.tscn" id="1_65a7v"]
[ext_resource type="AudioStream" uid="uid://bsy2d0bl3lgg0" path="res://sounds/crank.ogg" id="1_cweq4"]
@ -11,6 +11,7 @@
[ext_resource type="PackedScene" uid="uid://cn0rwyjern2vx" path="res://scenes/level.tscn" id="5_skctj"]
[ext_resource type="Script" path="res://scripts/GameCamera.cs" id="6_quua3"]
[ext_resource type="Script" path="res://scripts/PointLight2DWorkaround.cs" id="6_slohe"]
[ext_resource type="PackedScene" uid="uid://4d6fhm87mn55" path="res://prefabs/virtual_cursor.tscn" id="11_xqdcm"]
[ext_resource type="Script" path="res://scripts/WinScreen.cs" id="13_prax6"]
[ext_resource type="Theme" uid="uid://daxgxg7c8v0ih" path="res://themes/zx_theme.tres" id="14_g1c0r"]
[ext_resource type="Script" path="res://scripts/DeathScreen.cs" id="15_12mhe"]
@ -22,7 +23,7 @@ point_count = 2
[sub_resource type="ShaderMaterial" id="ShaderMaterial_m680d"]
shader = ExtResource("5_64d71")
[sub_resource type="ViewportTexture" id="ViewportTexture_kr1ga"]
[sub_resource type="ViewportTexture" id="ViewportTexture_meb87"]
viewport_path = NodePath("FlashlightViewport")
[sub_resource type="CircleShape2D" id="CircleShape2D_prnh4"]
@ -46,6 +47,9 @@ height = 192
[node name="Root" type="Node2D"]
y_sort_enabled = true
[node name="VirtualCursor" parent="." instance=ExtResource("11_xqdcm")]
position = Vector2(169.203, 958.57)
[node name="GameManager" type="Node" parent="." node_paths=PackedStringArray("FirstZone", "Player")]
script = ExtResource("1_ij566")
FirstZone = NodePath("../Zones/PlayZone1")
@ -235,15 +239,16 @@ texture = ExtResource("3_8o315")
[node name="Triangle" type="Polygon2D" parent="FlashlightViewport/CanvasGroup"]
polygon = PackedVector2Array(-21, -25, 31, 29, -42, 31)
[node name="PlayerCamera" type="Camera2D" parent="." node_paths=PackedStringArray("Player")]
[node name="PlayerCamera" type="Camera2D" parent="." node_paths=PackedStringArray("Player", "Cursor")]
script = ExtResource("6_quua3")
Player = NodePath("../Player")
CameraBounds = Vector2(30, 20)
Cursor = NodePath("../VirtualCursor")
[node name="PointLight2D" type="PointLight2D" parent="PlayerCamera" node_paths=PackedStringArray("LightViewport")]
blend_mode = 2
range_item_cull_mask = 2
texture = SubResource("ViewportTexture_kr1ga")
texture = SubResource("ViewportTexture_meb87")
script = ExtResource("6_slohe")
LightViewport = NodePath("../../FlashlightViewport")