diff --git a/1bit-game-jam.csproj b/1bit-game-jam.csproj index d31daf9..c627206 100644 --- a/1bit-game-jam.csproj +++ b/1bit-game-jam.csproj @@ -1,4 +1,4 @@ - + net6.0 true diff --git a/1bit-game-jam.csproj.old.1 b/1bit-game-jam.csproj.old.1 new file mode 100644 index 0000000..d31daf9 --- /dev/null +++ b/1bit-game-jam.csproj.old.1 @@ -0,0 +1,7 @@ + + + net6.0 + true + bitgamejam + + \ No newline at end of file diff --git a/prefabs/virtual_cursor.tscn b/prefabs/virtual_cursor.tscn new file mode 100644 index 0000000..9881490 --- /dev/null +++ b/prefabs/virtual_cursor.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=3 format=3 uid="uid://4d6fhm87mn55"] + +[ext_resource type="Script" path="res://scripts/VirtualCursor.cs" id="1_va4ba"] +[ext_resource type="Texture2D" uid="uid://up1nl3dnhadr" path="res://sprites/cursor.png" id="2_k2bth"] + +[node name="VirtualCursor" type="Node2D"] +script = ExtResource("1_va4ba") + +[node name="CursorSprite" type="Sprite2D" parent="."] +texture = ExtResource("2_k2bth") diff --git a/project.godot b/project.godot index f7cb697..1bc57cd 100644 --- a/project.godot +++ b/project.godot @@ -30,7 +30,7 @@ project/assembly_name="1bit-game-jam" character_up={ "deadzone": 0.5, -"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"echo":false,"script":null) +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":87,"physical_keycode":87,"key_label":87,"unicode":0,"echo":false,"script":null) , null, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null) , Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null) , 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":4194320,"key_label":0,"unicode":0,"echo":false,"script":null) @@ -78,6 +78,26 @@ ui_change_language={ , Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"button_index":0,"pressure":0.0,"pressed":false,"script":null) ] } +cursor_up={ +"deadzone": 0.5, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":-1.0,"script":null) +] +} +cursor_down={ +"deadzone": 0.5, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":3,"axis_value":1.0,"script":null) +] +} +cursor_left={ +"deadzone": 0.5, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":-1.0,"script":null) +] +} +cursor_right={ +"deadzone": 0.5, +"events": [Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":-1,"axis":2,"axis_value":1.0,"script":null) +] +} [internationalization] diff --git a/scenes/level.tscn b/scenes/level.tscn index aa9f8bc..6d09561 100644 --- a/scenes/level.tscn +++ b/scenes/level.tscn @@ -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") diff --git a/scenes/main_scene.tscn b/scenes/main_scene.tscn index 6d3771f..1cb9bc6 100644 --- a/scenes/main_scene.tscn +++ b/scenes/main_scene.tscn @@ -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") diff --git a/scripts/Flashlight.cs b/scripts/Flashlight.cs index c506ab2..6dd8fa8 100644 --- a/scripts/Flashlight.cs +++ b/scripts/Flashlight.cs @@ -1,4 +1,5 @@ using System; +using System.Diagnostics; using Godot; public partial class Flashlight : Node @@ -23,7 +24,7 @@ public partial class Flashlight : Node [Export] public Curve BrightnessCurve; [Export] public AudioStreamPlayer CrankSoundPlayer; - + private float FlashlightRadius = Constants.MaxFlashlightRadius; private float FlashlightEnergy = 0; private float FlashlightChargeTimeout = 1; diff --git a/scripts/GameCamera.cs b/scripts/GameCamera.cs index 52f7e7b..8be510d 100644 --- a/scripts/GameCamera.cs +++ b/scripts/GameCamera.cs @@ -1,3 +1,4 @@ +using System.Diagnostics; using Godot; public partial class GameCamera : Camera2D @@ -6,7 +7,10 @@ public partial class GameCamera : Camera2D [Export] public Vector2 CameraBounds = new(40, 30); [Export] public Vector2 CameraFollowBounds = new(20, 10); [Export] public float Speed = 0.5f; - + + [Export] public VirtualCursor Cursor; + [Export] public const float CursorSpeed = 2.0f; + /// /// World position of the flashlight /// @@ -14,6 +18,12 @@ public partial class GameCamera : Camera2D public override void _PhysicsProcess(double delta) { + Vector2 direction = Input.GetVector("cursor_left", "cursor_right", "cursor_up", "cursor_down"); + if (direction != Vector2.Zero) + { + FlashlightPosition += direction * CursorSpeed; + } + var difference = Vector2.Zero; var relativePlayerPosition = Player.Position - Position; @@ -39,6 +49,8 @@ public partial class GameCamera : Camera2D Position = (Position + difference).Round(); FlashlightPosition = (FlashlightPosition + difference).Round(); + Cursor.Position = FlashlightPosition; + } public override void _Input(InputEvent @event) @@ -48,6 +60,7 @@ public partial class GameCamera : Camera2D if (@event is InputEventMouseMotion eventMouseMotion) { FlashlightPosition = eventMouseMotion.Position - Constants.HalfScreenSize + Position; + //Cursor.Position = eventMouseMotion.Position - Constants.HalfScreenSize + Position; } } } diff --git a/scripts/Menu.cs b/scripts/Menu.cs index 6b0a388..9fc4132 100644 --- a/scripts/Menu.cs +++ b/scripts/Menu.cs @@ -10,6 +10,7 @@ public partial class Menu : Node2D private Array _translations = new Array{"en", "ru"}; private int _languagesCount; private int _currentLanguage = 0; + private Resource _cursorTexture; public override void _Ready() { @@ -31,6 +32,7 @@ public partial class Menu : Node2D _animationPlayer.Play("thunder"); _thunderclap.Play(); _timer.Start(); + DisplayServer.MouseSetMode(DisplayServer.MouseMode.Hidden); } else if (@event.IsActionPressed("ui_change_language")) { diff --git a/scripts/VirtualCursor.cs b/scripts/VirtualCursor.cs new file mode 100644 index 0000000..386faeb --- /dev/null +++ b/scripts/VirtualCursor.cs @@ -0,0 +1,30 @@ +using Godot; +using System; + +public partial class VirtualCursor : Node2D +{ + //[Export] public Node2D Cursor; + + protected Sprite2D CursorSprite; + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + CursorSprite = (Sprite2D)FindChild("CursorSprite"); + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + + } + + public override void _Input(InputEvent @event) + { + // base._Input(@event); + // + // if (@event is InputEventMouseMotion eventMouseMotion) + // { + // CursorSprite.Position = eventMouseMotion.Position - Constants.HalfScreenSize + Position; + // } + } +} diff --git a/sprites/cursor.png b/sprites/cursor.png new file mode 100644 index 0000000..f7d1aca Binary files /dev/null and b/sprites/cursor.png differ diff --git a/sprites/cursor.png.import b/sprites/cursor.png.import new file mode 100644 index 0000000..3474851 --- /dev/null +++ b/sprites/cursor.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://up1nl3dnhadr" +path="res://.godot/imported/cursor.png-ab659432fe95e81e8963a978cc7193a5.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://sprites/cursor.png" +dest_files=["res://.godot/imported/cursor.png-ab659432fe95e81e8963a978cc7193a5.ctex"] + +[params] + +compress/mode=0 +compress/high_quality=false +compress/lossy_quality=0.7 +compress/hdr_compression=1 +compress/normal_map=0 +compress/channel_pack=0 +mipmaps/generate=false +mipmaps/limit=-1 +roughness/mode=0 +roughness/src_normal="" +process/fix_alpha_border=true +process/premult_alpha=false +process/normal_map_invert_y=false +process/hdr_as_srgb=false +process/hdr_clamp_exposure=false +process/size_limit=0 +detect_3d/compress_to=1