commit fb0930c3488793b2beadb28c252c26852c4bf3fa Author: Syntriax Date: Thu Sep 14 10:29:52 2023 +0300 Initial commit diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2585aa0 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +# Normalize EOL for all files that Git considers text files. +* text=auto eol=lf +Assets/** filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4709183 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Godot 4+ specific ignores +.godot/ diff --git a/Assets/Sprites/Arrow.png b/Assets/Sprites/Arrow.png new file mode 100644 index 0000000..d8457ea --- /dev/null +++ b/Assets/Sprites/Arrow.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3bb2c820e4c30383b0d891706dace83ffa645f84dfee070de73588d6aeb5977e +size 194 diff --git a/Assets/Sprites/Arrow.png.import b/Assets/Sprites/Arrow.png.import new file mode 100644 index 0000000..5345031 --- /dev/null +++ b/Assets/Sprites/Arrow.png.import @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6bd2175a7bc2b68c507af4f3016e974eb922bd6129c328315755b2db78720531 +size 764 diff --git a/Assets/Sprites/CandyRainS5E12.png b/Assets/Sprites/CandyRainS5E12.png new file mode 100644 index 0000000..efb9abc --- /dev/null +++ b/Assets/Sprites/CandyRainS5E12.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:16b88555336ae14069dd4a16f02fb6ec27049fe3f31b2e9da1afef292c450b0e +size 383642 diff --git a/Assets/Sprites/CandyRainS5E12.png.import b/Assets/Sprites/CandyRainS5E12.png.import new file mode 100644 index 0000000..a854067 --- /dev/null +++ b/Assets/Sprites/CandyRainS5E12.png.import @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6719bef3dd608de0b830023731d8f85be8d99292ff812b429cdb8a1629d43b24 +size 790 diff --git a/Assets/Sprites/Pillow.png b/Assets/Sprites/Pillow.png new file mode 100644 index 0000000..0a4fdea --- /dev/null +++ b/Assets/Sprites/Pillow.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e0001185fd2c94a4e59ac883b5ab69bb668033efbfffa3e1f5a0c6f9305f308b +size 245 diff --git a/Assets/Sprites/Pillow.png.import b/Assets/Sprites/Pillow.png.import new file mode 100644 index 0000000..52b1b14 --- /dev/null +++ b/Assets/Sprites/Pillow.png.import @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6db8b69a1b5b22662f20452694ba7aa9f7f5108ab1f4bb0363b84ed5c8041023 +size 767 diff --git a/Assets/Sprites/pony-town-Cushy Pillow-stand-head-4x.png b/Assets/Sprites/pony-town-Cushy Pillow-stand-head-4x.png new file mode 100644 index 0000000..460d8f6 --- /dev/null +++ b/Assets/Sprites/pony-town-Cushy Pillow-stand-head-4x.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:cb726a4b7646df6b45d032c834aec100f1eca9b22adbdf67cce8dc14821bd92e +size 2732 diff --git a/Assets/Sprites/pony-town-Cushy Pillow-stand-head-4x.png.import b/Assets/Sprites/pony-town-Cushy Pillow-stand-head-4x.png.import new file mode 100644 index 0000000..2b79615 --- /dev/null +++ b/Assets/Sprites/pony-town-Cushy Pillow-stand-head-4x.png.import @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:151031d81ba5bb9337fa03afbefdf372493d51d1d6c190849b1a14686aa21246 +size 857 diff --git a/Projects.csproj b/Projects.csproj new file mode 100644 index 0000000..8ee8c44 --- /dev/null +++ b/Projects.csproj @@ -0,0 +1,6 @@ + + + net6.0 + true + + \ No newline at end of file diff --git a/Projects.sln b/Projects.sln new file mode 100644 index 0000000..175d466 --- /dev/null +++ b/Projects.sln @@ -0,0 +1,19 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Projects", "Projects.csproj", "{0EA58A9B-56B0-460B-898B-9FA2D5955543}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + ExportDebug|Any CPU = ExportDebug|Any CPU + ExportRelease|Any CPU = ExportRelease|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {0EA58A9B-56B0-460B-898B-9FA2D5955543}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {0EA58A9B-56B0-460B-898B-9FA2D5955543}.Debug|Any CPU.Build.0 = Debug|Any CPU + {0EA58A9B-56B0-460B-898B-9FA2D5955543}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU + {0EA58A9B-56B0-460B-898B-9FA2D5955543}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU + {0EA58A9B-56B0-460B-898B-9FA2D5955543}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU + {0EA58A9B-56B0-460B-898B-9FA2D5955543}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU + EndGlobalSection +EndGlobal diff --git a/Scenes/Entities/arrow.tscn b/Scenes/Entities/arrow.tscn new file mode 100644 index 0000000..e6494cb --- /dev/null +++ b/Scenes/Entities/arrow.tscn @@ -0,0 +1,20 @@ +[gd_scene load_steps=4 format=3 uid="uid://bgvwjpxlr21qn"] + +[ext_resource type="Script" path="res://Scripts/Arrow.cs" id="1_jkpko"] +[ext_resource type="Texture2D" uid="uid://c8sf3phprsqb1" path="res://Assets/Sprites/Arrow.png" id="2_y5esr"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_r2lgg"] +size = Vector2(21, 92) + +[node name="Arrow" type="RigidBody2D"] +gravity_scale = 0.0 +max_contacts_reported = 5 +contact_monitor = true +script = ExtResource("1_jkpko") + +[node name="Arrow" type="Sprite2D" parent="."] +scale = Vector2(2.82, 2.82) +texture = ExtResource("2_y5esr") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +shape = SubResource("RectangleShape2D_r2lgg") diff --git a/Scenes/Entities/candy.tscn b/Scenes/Entities/candy.tscn new file mode 100644 index 0000000..5991826 --- /dev/null +++ b/Scenes/Entities/candy.tscn @@ -0,0 +1,38 @@ +[gd_scene load_steps=5 format=3 uid="uid://b56lg6dhura8f"] + +[ext_resource type="Texture2D" uid="uid://k0cnmh268s2e" path="res://Assets/Sprites/CandyRainS5E12.png" id="1_dc57j"] +[ext_resource type="Script" path="res://Scripts/MoveUpDown.cs" id="2_10e3l"] +[ext_resource type="Script" path="res://Scripts/Candy.cs" id="3_d4aun"] + +[sub_resource type="RectangleShape2D" id="RectangleShape2D_mfu86"] + +[node name="Candy" type="Node2D"] + +[node name="Candy" type="RigidBody2D" parent="." node_paths=PackedStringArray("Up", "Down")] +position = Vector2(1024, 318) +disable_mode = 2 +mass = 238.6 +gravity_scale = 0.0 +continuous_cd = 2 +max_contacts_reported = 4 +can_sleep = false +freeze_mode = 1 +script = ExtResource("2_10e3l") +Up = NodePath("../Candy Up") +Down = NodePath("../Candy Down") +speed = 1.215 + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Candy"] +scale = Vector2(8.83, 8.83) +shape = SubResource("RectangleShape2D_mfu86") + +[node name="CandyRainS5e12" type="Sprite2D" parent="Candy"] +scale = Vector2(0.07, 0.07) +texture = ExtResource("1_dc57j") +script = ExtResource("3_d4aun") + +[node name="Candy Up" type="Node2D" parent="."] +position = Vector2(1023, 106) + +[node name="Candy Down" type="Node2D" parent="."] +position = Vector2(1023, 522) diff --git a/Scenes/Entities/cushy.tscn b/Scenes/Entities/cushy.tscn new file mode 100644 index 0000000..55f9a99 --- /dev/null +++ b/Scenes/Entities/cushy.tscn @@ -0,0 +1,33 @@ +[gd_scene load_steps=5 format=3 uid="uid://b8ukoy7uiwtlo"] + +[ext_resource type="Script" path="res://Scripts/MoveUpDown.cs" id="2_4b64p"] +[ext_resource type="Texture2D" uid="uid://csrcr2nddcqtn" path="res://Assets/Sprites/pony-town-Cushy Pillow-stand-head-4x.png" id="2_gs3o8"] +[ext_resource type="Script" path="res://Scripts/ThrowPillow.cs" id="3_i37ey"] +[ext_resource type="PackedScene" uid="uid://bv0rugppux84g" path="res://Scenes/Entities/pillow.tscn" id="4_nkwti"] + +[node name="Cushy" type="Node2D"] + +[node name="RigidBody2D" type="RigidBody2D" parent="." node_paths=PackedStringArray("Up", "Down")] +position = Vector2(111, 322) +script = ExtResource("2_4b64p") +Up = NodePath("../Cushy Up") +Down = NodePath("../Cushy Down") +speed = 0.56 + +[node name="Pony-town-cushyPillow-stand-head-4x" type="Sprite2D" parent="RigidBody2D"] +texture = ExtResource("2_gs3o8") + +[node name="Pillow Spawner" type="Node2D" parent="RigidBody2D/Pony-town-cushyPillow-stand-head-4x" node_paths=PackedStringArray("pillowsNode")] +position = Vector2(127, 0) +script = ExtResource("3_i37ey") +pillow = ExtResource("4_nkwti") +pillowsNode = NodePath("../../../Pillows") +RPM = 25.0 + +[node name="Cushy Up" type="Node2D" parent="."] +position = Vector2(122, 106) + +[node name="Cushy Down" type="Node2D" parent="."] +position = Vector2(122, 522) + +[node name="Pillows" type="Node2D" parent="."] diff --git a/Scenes/Entities/pillow.tscn b/Scenes/Entities/pillow.tscn new file mode 100644 index 0000000..dc57e33 --- /dev/null +++ b/Scenes/Entities/pillow.tscn @@ -0,0 +1,29 @@ +[gd_scene load_steps=4 format=3 uid="uid://bv0rugppux84g"] + +[ext_resource type="Texture2D" uid="uid://d0ni8qvcxpti0" path="res://Assets/Sprites/Pillow.png" id="2_4eq0m"] +[ext_resource type="Script" path="res://Scripts/Pillow.cs" id="2_404kc"] + +[sub_resource type="CircleShape2D" id="CircleShape2D_mvy54"] +radius = 13.1476 + +[node name="Pillow" type="Node2D"] +texture_filter = 1 + +[node name="RigidBody2D" type="RigidBody2D" parent="."] +gravity_scale = 0.0 +continuous_cd = 2 +max_contacts_reported = 11 +contact_monitor = true +can_sleep = false +angular_damp = -1.0 +script = ExtResource("2_404kc") +angularSpeed = 5.0 +velocity = Vector2(250, 0) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="RigidBody2D"] +scale = Vector2(6.52, 6.52) +shape = SubResource("CircleShape2D_mvy54") + +[node name="Pillow" type="Sprite2D" parent="RigidBody2D"] +scale = Vector2(6.04, 6.04) +texture = ExtResource("2_4eq0m") diff --git a/Scenes/Levels/main_level.tscn b/Scenes/Levels/main_level.tscn new file mode 100644 index 0000000..548f382 --- /dev/null +++ b/Scenes/Levels/main_level.tscn @@ -0,0 +1,28 @@ +[gd_scene load_steps=6 format=3 uid="uid://bms4asboep1fd"] + +[ext_resource type="PackedScene" uid="uid://b56lg6dhura8f" path="res://Scenes/Entities/candy.tscn" id="1_v4hjh"] +[ext_resource type="PackedScene" uid="uid://b8ukoy7uiwtlo" path="res://Scenes/Entities/cushy.tscn" id="2_kyhwt"] +[ext_resource type="PackedScene" uid="uid://bgvwjpxlr21qn" path="res://Scenes/Entities/arrow.tscn" id="3_dxffe"] +[ext_resource type="Script" path="res://Scripts/MouseInput.cs" id="3_sv1u3"] +[ext_resource type="Script" path="res://Scripts/ArrowThrower.cs" id="4_lbe3i"] + +[node name="Main Level" type="Node2D"] +texture_filter = 1 + +[node name="Cushy" parent="." instance=ExtResource("2_kyhwt")] + +[node name="Candy" parent="." instance=ExtResource("1_v4hjh")] + +[node name="Mouse Input" type="Node2D" parent="."] +script = ExtResource("3_sv1u3") + +[node name="Arrow Thrower" type="Node2D" parent="Mouse Input" node_paths=PackedStringArray("ArrowsNode")] +position = Vector2(574, 529) +script = ExtResource("4_lbe3i") +ArrowsNode = NodePath("Arrows") + +[node name="Arrow" parent="Mouse Input/Arrow Thrower" instance=ExtResource("3_dxffe")] +visible = false +position = Vector2(-8, 8) + +[node name="Arrows" type="Node2D" parent="Mouse Input/Arrow Thrower"] diff --git a/Scripts/Arrow.cs b/Scripts/Arrow.cs new file mode 100644 index 0000000..8fa0126 --- /dev/null +++ b/Scripts/Arrow.cs @@ -0,0 +1,28 @@ +using Godot; +using System; + +public partial class Arrow : RigidBody2D +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + } + public override void _PhysicsProcess(double delta) + { + base._PhysicsProcess(delta); + + Godot.Collections.Array node2Ds = GetCollidingBodies(); + + if (node2Ds.Count == 0) + return; + + foreach (var node2D in node2Ds) + node2D.QueueFree(); + QueueFree(); + } +} diff --git a/Scripts/ArrowThrower.cs b/Scripts/ArrowThrower.cs new file mode 100644 index 0000000..1c20522 --- /dev/null +++ b/Scripts/ArrowThrower.cs @@ -0,0 +1,53 @@ +using System; +using Godot; + +public partial class ArrowThrower : Node2D +{ + [Export] public Node2D ArrowsNode; + + private bool isAiming = false; + private Vector2 initialPosition; + + private PackedScene arrowRef = null; + private RigidBody2D arrow = null; + + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + arrowRef = GD.Load("res://Scenes/Entities/arrow.tscn"); + + MouseInput mouseInput = FindParent("Mouse Input") as MouseInput; + mouseInput.OnMouseDown += OnMouseDown; + mouseInput.OnMouseUp += OnMouseUp; + } + + private void OnMouseUp() + { + isAiming = false; + Vector2 direction = (initialPosition - GetGlobalMousePosition()).Normalized(); + Vector2 vector2 = GetGlobalMousePosition() - initialPosition; + arrow.Rotation = Mathf.Atan2(-vector2.X, vector2.Y); + arrow.LinearVelocity = direction * 500f; + } + + private void OnMouseDown() + { + isAiming = true; + initialPosition = GetGlobalMousePosition(); + + arrow = arrowRef.Instantiate() as RigidBody2D; + + ArrowsNode.AddChild(arrow); + arrow.GlobalPosition = initialPosition; + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + if (!isAiming) + return; + + Vector2 vector2 = GetGlobalMousePosition() - initialPosition; + arrow.Rotation = Mathf.Atan2(-vector2.X, vector2.Y); + } +} diff --git a/Scripts/Candy.cs b/Scripts/Candy.cs new file mode 100644 index 0000000..4446a7e --- /dev/null +++ b/Scripts/Candy.cs @@ -0,0 +1,15 @@ +using Godot; +using System; + +public partial class Candy : Node2D +{ + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + } +} diff --git a/Scripts/MouseInput.cs b/Scripts/MouseInput.cs new file mode 100644 index 0000000..6333597 --- /dev/null +++ b/Scripts/MouseInput.cs @@ -0,0 +1,22 @@ +using Godot; +using System; + +public partial class MouseInput : Node +{ + public Action OnMouseDown = null; + public Action OnMouseUp = null; + + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + if (Input.IsActionJustPressed("Mouse Left")) + OnMouseDown?.Invoke(); + if (Input.IsActionJustReleased("Mouse Left")) + OnMouseUp?.Invoke(); + } +} diff --git a/Scripts/MoveUpDown.cs b/Scripts/MoveUpDown.cs new file mode 100644 index 0000000..bf88300 --- /dev/null +++ b/Scripts/MoveUpDown.cs @@ -0,0 +1,31 @@ +using System; +using Godot; + +public partial class MoveUpDown : RigidBody2D +{ + [Export] public Node2D Up; + [Export] public Node2D Down; + + [Export] private double speed = 1f; + + private double t = 0f; + + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + t += delta * speed; + t = t % 2f; + + double posT = Math.Abs(t - 1f); + + MoveAndCollide(new Vector2( + (float)Mathf.Lerp(Up.Position.X, Down.Position.X, posT), + (float)Mathf.Lerp(Up.Position.Y, Down.Position.Y, posT) + ) - Position); + } +} diff --git a/Scripts/Pillow.cs b/Scripts/Pillow.cs new file mode 100644 index 0000000..02a2b63 --- /dev/null +++ b/Scripts/Pillow.cs @@ -0,0 +1,45 @@ +using Godot; +using System; + +public partial class Pillow : RigidBody2D +{ + [Export] public float angularSpeed = 1f; + [Export] public Vector2 velocity = new Vector2(1, 0); + + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + Rotation = (float)Random.Shared.NextDouble(); + AngularVelocity = ((float)Random.Shared.NextDouble() + .5f) * angularSpeed; + LinearVelocity = velocity; + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + + } + + public override void _PhysicsProcess(double delta) + { + base._PhysicsProcess(delta); + + Godot.Collections.Array node2Ds = GetCollidingBodies(); + + Node2D candy = null; + foreach (var node2D in node2Ds) + { + if (node2D.Name != "Candy") + continue; + + candy = node2D; + break; + } + + if (candy == null) + return; + + candy.Visible = false; + Visible = false; + } +} diff --git a/Scripts/ThrowPillow.cs b/Scripts/ThrowPillow.cs new file mode 100644 index 0000000..5f5cc01 --- /dev/null +++ b/Scripts/ThrowPillow.cs @@ -0,0 +1,35 @@ +using Godot; + +public partial class ThrowPillow : Node2D +{ + [Export] public PackedScene pillow; + [Export] public Node pillowsNode; + [Export] public float RPM = 30f; + + private float countdown = 0f; + + // Called when the node enters the scene tree for the first time. + public override void _Ready() + { + pillow = GD.Load("res://Scenes/Entities/pillow.tscn"); + } + + // Called every frame. 'delta' is the elapsed time since the previous frame. + public override void _Process(double delta) + { + countdown -= (float)delta; + + if (countdown > 0f) + return; + + ShootPillow(); + countdown = 60f / RPM; + } + + private void ShootPillow() + { + var instance = pillow.Instantiate(); + instance.GlobalPosition = GlobalPosition; + pillowsNode.AddChild(instance); + } +} diff --git a/project.godot b/project.godot new file mode 100644 index 0000000..d474fdb --- /dev/null +++ b/project.godot @@ -0,0 +1,32 @@ +; Engine configuration file. +; It's best edited using the editor UI and not directly, +; since the parameters that go here are not all obvious. +; +; Format: +; [section] ; section goes between [] +; param=value ; assign values to parameters + +config_version=5 + +[application] + +config/name="Morning Murder" +run/main_scene="res://Scenes/Levels/main_level.tscn" +config/features=PackedStringArray("4.1", "C#", "Forward Plus") + +[dotnet] + +project/assembly_name="Projects" + +[input] + +"Mouse Left"={ +"deadzone": 0.5, +"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":1,"position":Vector2(247, 18),"global_position":Vector2(251, 61),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null) +] +} +"Mouse Right"={ +"deadzone": 0.5, +"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":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":2,"canceled":false,"pressed":false,"double_click":false,"script":null) +] +}