Initial commit

This commit is contained in:
Syntriax 2023-09-14 10:29:52 +03:00
commit fb0930c348
25 changed files with 463 additions and 0 deletions

3
.gitattributes vendored Normal file
View File

@ -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

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
# Godot 4+ specific ignores
.godot/

BIN
Assets/Sprites/Arrow.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/Sprites/Arrow.png.import (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/Sprites/CandyRainS5E12.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/Sprites/CandyRainS5E12.png.import (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/Sprites/Pillow.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/Sprites/Pillow.png.import (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Assets/Sprites/pony-town-Cushy Pillow-stand-head-4x.png (Stored with Git LFS) Normal file

Binary file not shown.

Binary file not shown.

6
Projects.csproj Normal file
View File

@ -0,0 +1,6 @@
<Project Sdk="Godot.NET.Sdk/4.1.1">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<EnableDynamicLoading>true</EnableDynamicLoading>
</PropertyGroup>
</Project>

19
Projects.sln Normal file
View File

@ -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

View File

@ -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")

View File

@ -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)

View File

@ -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="."]

View File

@ -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")

View File

@ -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"]

28
Scripts/Arrow.cs Normal file
View File

@ -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<Node2D> node2Ds = GetCollidingBodies();
if (node2Ds.Count == 0)
return;
foreach (var node2D in node2Ds)
node2D.QueueFree();
QueueFree();
}
}

53
Scripts/ArrowThrower.cs Normal file
View File

@ -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<PackedScene>("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);
}
}

15
Scripts/Candy.cs Normal file
View File

@ -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)
{
}
}

22
Scripts/MouseInput.cs Normal file
View File

@ -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();
}
}

31
Scripts/MoveUpDown.cs Normal file
View File

@ -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);
}
}

45
Scripts/Pillow.cs Normal file
View File

@ -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<Node2D> 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;
}
}

35
Scripts/ThrowPillow.cs Normal file
View File

@ -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<PackedScene>("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<Node2D>();
instance.GlobalPosition = GlobalPosition;
pillowsNode.AddChild(instance);
}
}

32
project.godot Normal file
View File

@ -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)
]
}