1
Fork 0
mirror of https://github.com/Steffo99/hella-farm.git synced 2024-11-25 09:34:24 +00:00

Update physics and add some sounds

This commit is contained in:
Steffo 2024-04-22 00:56:35 +02:00
parent 3a3340a18c
commit c4775d327b
Signed by: steffo
GPG key ID: 5ADA3868646C3FC0
13 changed files with 103 additions and 65 deletions

View file

@ -10,7 +10,7 @@ This project uses the following external assets:
| `./temp/click&pop.wav` | https://freesound.org/people/GammaGool/sounds/730488/ | CC0 | | `./temp/click&pop.wav` | https://freesound.org/people/GammaGool/sounds/730488/ | CC0 |
| `./temp/pop.wav` | https://freesound.org/people/NovaSoundTechnology/sounds/727104/ | CC0 | | `./temp/pop.wav` | https://freesound.org/people/NovaSoundTechnology/sounds/727104/ | CC0 |
| `./temp/mouth_pop.wav` | https://freesound.org/people/igaopuromalte/sounds/725453/ | Attribution 4 | | `./temp/mouth_pop.wav` | https://freesound.org/people/igaopuromalte/sounds/725453/ | Attribution 4 |
| `./temp/puff.wav` | https://freesound.org/people/JustInvoke/sounds/446124/ | Attribution 4 | | `./entities/fall.ogg` | https://freesound.org/people/JustInvoke/sounds/446124/ | Attribution 4 |
| `./temp/place.wav` | https://freesound.org/people/Planman/sounds/208111/ | CC0 | | `./temp/place.wav` | https://freesound.org/people/Planman/sounds/208111/ | CC0 |
| `./temp/gore.wav` | https://freesound.org/people/MinecraftGamerLR/sounds/728695/ | Attribution 4 | | `./temp/gore.wav` | https://freesound.org/people/MinecraftGamerLR/sounds/728695/ | Attribution 4 |
| `./entities/skull_pickup.wav` | https://freesound.org/people/cliftonmcarlson/sounds/392883/ | CC0 | | `./entities/skull_pickup.wav` | https://freesound.org/people/cliftonmcarlson/sounds/392883/ | CC0 |

View file

@ -7,15 +7,16 @@ signal dropped
signal fallen signal fallen
@export var acceleration = 650.0 @export var acceleration = 1250.0
@export var linear_damp = 18.0 @export var drag_damp = 0.4
@export var drop_damp = 0.05
@export var drop_epsilon = 16.0
var cursor: Cursor = null var cursor: Cursor = null
var falling: bool = false
var velocity := Vector2.ZERO var velocity := Vector2.ZERO
@onready var ticks_per_second = ProjectSettings.get_setting("physics/common/physics_ticks_per_second")
func drag(value: Cursor) -> void: func drag(value: Cursor) -> void:
cursor = value cursor = value
@ -23,10 +24,12 @@ func drag(value: Cursor) -> void:
func drop() -> void: func drop() -> void:
cursor = null cursor = null
falling = true
dropped.emit() dropped.emit()
func fall() -> void: func fall() -> void:
velocity = Vector2.ZERO velocity = Vector2.ZERO
falling = false
fallen.emit() fallen.emit()
@ -35,5 +38,9 @@ func _physics_process(delta: float) -> void:
if cursor: if cursor:
var gap = cursor.global_position - global_position var gap = cursor.global_position - global_position
velocity += gap * delta * acceleration velocity += gap * delta * acceleration
velocity *= 1.0 - linear_damp / ticks_per_second velocity *= 1.0 - drag_damp
else:
velocity *= 1.0 - drop_damp
if falling and velocity.length() < drop_epsilon:
fall()
move.emit(velocity * delta) move.emit(velocity * delta)

BIN
entities/fall.ogg (Stored with Git LFS) Normal file

Binary file not shown.

19
entities/fall.ogg.import Normal file
View file

@ -0,0 +1,19 @@
[remap]
importer="oggvorbisstr"
type="AudioStreamOggVorbis"
uid="uid://cwsg776c11xfc"
path="res://.godot/imported/fall.ogg-ba2036bd4382e626c27cc3d1d5eb69f1.oggvorbisstr"
[deps]
source_file="res://entities/fall.ogg"
dest_files=["res://.godot/imported/fall.ogg-ba2036bd4382e626c27cc3d1d5eb69f1.oggvorbisstr"]
[params]
loop=false
loop_offset=0
bpm=0
beat_count=0
bar_beats=4

BIN
entities/fall.wav (Stored with Git LFS)

Binary file not shown.

View file

@ -1,24 +0,0 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://buxgivpkh8dyl"
path="res://.godot/imported/fall.wav-db08e68086e6fbfdfcb891d3b1804e1e.sample"
[deps]
source_file="res://entities/fall.wav"
dest_files=["res://.godot/imported/fall.wav-db08e68086e6fbfdfcb891d3b1804e1e.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=0

View file

@ -4,3 +4,13 @@ class_name Monocle
func _on_move(movement: Vector2) -> void: func _on_move(movement: Vector2) -> void:
move_and_collide(movement) move_and_collide(movement)
func _on_dragged(_cursor: Cursor) -> void:
collision_layer = 16
collision_mask = 18
z_index = 1
func _on_fallen() -> void:
collision_layer = 8
collision_mask = 14
z_index = 0

View file

@ -1,9 +1,10 @@
[gd_scene load_steps=7 format=3 uid="uid://b04xhv32ypi42"] [gd_scene load_steps=8 format=3 uid="uid://b04xhv32ypi42"]
[ext_resource type="Script" path="res://entities/monocle.gd" id="1_ehpfj"] [ext_resource type="Script" path="res://entities/monocle.gd" id="1_ehpfj"]
[ext_resource type="Texture2D" uid="uid://d3tb6ypb36v8e" path="res://entities/monocle.png" id="1_omrit"] [ext_resource type="Texture2D" uid="uid://d3tb6ypb36v8e" path="res://entities/monocle.png" id="1_omrit"]
[ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="2_jgnsw"] [ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="2_jgnsw"]
[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_e0ni5"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="3_e0ni5"]
[ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="5_grwug"]
[sub_resource type="CircleShape2D" id="CircleShape2D_o7chm"] [sub_resource type="CircleShape2D" id="CircleShape2D_o7chm"]
radius = 12.0 radius = 12.0
@ -12,8 +13,9 @@ radius = 12.0
radius = 24.0 radius = 24.0
[node name="Monocle" type="CharacterBody2D"] [node name="Monocle" type="CharacterBody2D"]
collision_layer = 32 collision_layer = 8
collision_mask = 38 collision_mask = 14
motion_mode = 1
script = ExtResource("1_ehpfj") script = ExtResource("1_ehpfj")
[node name="Sprite" type="Sprite2D" parent="."] [node name="Sprite" type="Sprite2D" parent="."]
@ -26,18 +28,20 @@ shape = SubResource("CircleShape2D_o7chm")
[node name="MovementDrag" parent="." instance=ExtResource("2_jgnsw")] [node name="MovementDrag" parent="." instance=ExtResource("2_jgnsw")]
[node name="Draggable" parent="MovementDrag" instance=ExtResource("3_e0ni5")] [node name="Draggable" parent="MovementDrag" instance=ExtResource("3_e0ni5")]
collision_layer = 32
[node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"] [node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"]
shape = SubResource("CircleShape2D_juisb") shape = SubResource("CircleShape2D_juisb")
debug_color = Color(1, 1, 1, 0) debug_color = Color(1, 1, 1, 0)
[node name="FallTimer" type="Timer" parent="MovementDrag"] [node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag"]
wait_time = 0.5
one_shot = true
[connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"] [node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag"]
stream = ExtResource("5_grwug")
[connection signal="dragged" from="MovementDrag" to="." method="_on_dragged"]
[connection signal="dragged" from="MovementDrag" to="MovementDrag/DragSound" method="play" unbinds=1]
[connection signal="fallen" from="MovementDrag" to="." method="_on_fallen"]
[connection signal="fallen" from="MovementDrag" to="MovementDrag/FallSound" method="play"]
[connection signal="move" from="MovementDrag" to="." method="_on_move"] [connection signal="move" from="MovementDrag" to="." method="_on_move"]
[connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] [connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"]
[connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] [connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"]
[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"]

View file

@ -4,3 +4,13 @@ class_name Skull
func _on_move(movement: Vector2) -> void: func _on_move(movement: Vector2) -> void:
move_and_collide(movement) move_and_collide(movement)
func _on_dragged(_cursor: Cursor) -> void:
collision_layer = 16
collision_mask = 18
z_index = 1
func _on_fallen() -> void:
collision_layer = 8
collision_mask = 14
z_index = 0

View file

@ -5,7 +5,7 @@
[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="2_h0icd"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="2_h0icd"]
[ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="3_83m1a"] [ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="3_83m1a"]
[ext_resource type="AudioStream" uid="uid://dq3xf4i2wpt50" path="res://entities/skull_drag.wav" id="5_duqrf"] [ext_resource type="AudioStream" uid="uid://dq3xf4i2wpt50" path="res://entities/skull_drag.wav" id="5_duqrf"]
[ext_resource type="AudioStream" uid="uid://buxgivpkh8dyl" path="res://entities/fall.wav" id="6_b7mxf"] [ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="6_7yx26"]
[sub_resource type="CircleShape2D" id="CircleShape2D_ypibs"] [sub_resource type="CircleShape2D" id="CircleShape2D_ypibs"]
radius = 12.0 radius = 12.0
@ -14,8 +14,9 @@ radius = 12.0
radius = 24.0 radius = 24.0
[node name="Skull" type="CharacterBody2D"] [node name="Skull" type="CharacterBody2D"]
collision_layer = 32 collision_layer = 8
collision_mask = 38 collision_mask = 14
motion_mode = 1
script = ExtResource("1_7g8bu") script = ExtResource("1_7g8bu")
[node name="Sprite" type="Sprite2D" parent="."] [node name="Sprite" type="Sprite2D" parent="."]
@ -28,26 +29,21 @@ shape = SubResource("CircleShape2D_ypibs")
[node name="MovementDrag" parent="." instance=ExtResource("3_83m1a")] [node name="MovementDrag" parent="." instance=ExtResource("3_83m1a")]
[node name="Draggable" parent="MovementDrag" instance=ExtResource("2_h0icd")] [node name="Draggable" parent="MovementDrag" instance=ExtResource("2_h0icd")]
collision_layer = 32
[node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"] [node name="Shape" type="CollisionShape2D" parent="MovementDrag/Draggable"]
shape = SubResource("CircleShape2D_1c7gd") shape = SubResource("CircleShape2D_1c7gd")
debug_color = Color(1, 1, 1, 0) debug_color = Color(1, 1, 1, 0)
[node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag/Draggable"] [node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag"]
stream = ExtResource("5_duqrf") stream = ExtResource("5_duqrf")
[node name="FallTimer" type="Timer" parent="MovementDrag"] [node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag"]
wait_time = 0.5 stream = ExtResource("6_7yx26")
one_shot = true
[node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag/FallTimer"] [connection signal="dragged" from="MovementDrag" to="." method="_on_dragged"]
stream = ExtResource("6_b7mxf") [connection signal="dragged" from="MovementDrag" to="MovementDrag/DragSound" method="play" unbinds=1]
[connection signal="fallen" from="MovementDrag" to="." method="_on_fallen"]
[connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"] [connection signal="fallen" from="MovementDrag" to="MovementDrag/FallSound" method="play"]
[connection signal="move" from="MovementDrag" to="." method="_on_move"] [connection signal="move" from="MovementDrag" to="." method="_on_move"]
[connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] [connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"]
[connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag/Draggable/DragSound" method="play" unbinds=1]
[connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] [connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"]
[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"]
[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag/FallTimer/FallSound" method="play"]

View file

@ -4,3 +4,13 @@ class_name TopHat
func _on_move(movement: Vector2) -> void: func _on_move(movement: Vector2) -> void:
move_and_collide(movement) move_and_collide(movement)
func _on_dragged(_cursor: Cursor) -> void:
collision_layer = 16
collision_mask = 18
z_index = 1
func _on_fallen() -> void:
collision_layer = 8
collision_mask = 14
z_index = 0

View file

@ -1,9 +1,10 @@
[gd_scene load_steps=7 format=3 uid="uid://8ejgwtkpaa44"] [gd_scene load_steps=8 format=3 uid="uid://8ejgwtkpaa44"]
[ext_resource type="Script" path="res://entities/top_hat.gd" id="1_0eh11"] [ext_resource type="Script" path="res://entities/top_hat.gd" id="1_0eh11"]
[ext_resource type="Texture2D" uid="uid://deqvgvf66grr4" path="res://entities/top_hat.png" id="1_gbqic"] [ext_resource type="Texture2D" uid="uid://deqvgvf66grr4" path="res://entities/top_hat.png" id="1_gbqic"]
[ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="3_gy414"] [ext_resource type="PackedScene" uid="uid://rx24bppccih7" path="res://behaviours/move_physics.tscn" id="3_gy414"]
[ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="4_fcvjo"] [ext_resource type="PackedScene" uid="uid://dijcjahkddudv" path="res://behaviours/draggable.tscn" id="4_fcvjo"]
[ext_resource type="AudioStream" uid="uid://cwsg776c11xfc" path="res://entities/fall.ogg" id="6_6tpnh"]
[sub_resource type="CircleShape2D" id="CircleShape2D_o7chm"] [sub_resource type="CircleShape2D" id="CircleShape2D_o7chm"]
radius = 12.0 radius = 12.0
@ -12,8 +13,9 @@ radius = 12.0
radius = 24.0 radius = 24.0
[node name="TopHat" type="CharacterBody2D"] [node name="TopHat" type="CharacterBody2D"]
collision_layer = 32 collision_layer = 8
collision_mask = 38 collision_mask = 14
motion_mode = 1
script = ExtResource("1_0eh11") script = ExtResource("1_0eh11")
[node name="Sprite" type="Sprite2D" parent="."] [node name="Sprite" type="Sprite2D" parent="."]
@ -32,12 +34,15 @@ collision_layer = 32
shape = SubResource("CircleShape2D_juisb") shape = SubResource("CircleShape2D_juisb")
debug_color = Color(1, 1, 1, 0) debug_color = Color(1, 1, 1, 0)
[node name="FallTimer" type="Timer" parent="MovementDrag"] [node name="DragSound" type="AudioStreamPlayer2D" parent="MovementDrag"]
wait_time = 0.5
one_shot = true
[connection signal="dropped" from="MovementDrag" to="MovementDrag/FallTimer" method="start"] [node name="FallSound" type="AudioStreamPlayer2D" parent="MovementDrag"]
stream = ExtResource("6_6tpnh")
[connection signal="dragged" from="MovementDrag" to="." method="_on_dragged"]
[connection signal="dragged" from="MovementDrag" to="MovementDrag/DragSound" method="play" unbinds=1]
[connection signal="fallen" from="MovementDrag" to="." method="_on_fallen"]
[connection signal="fallen" from="MovementDrag" to="MovementDrag/FallSound" method="play"]
[connection signal="move" from="MovementDrag" to="." method="_on_move"] [connection signal="move" from="MovementDrag" to="." method="_on_move"]
[connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"] [connection signal="dragged" from="MovementDrag/Draggable" to="MovementDrag" method="drag"]
[connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"] [connection signal="dropped" from="MovementDrag/Draggable" to="MovementDrag" method="drop"]
[connection signal="timeout" from="MovementDrag/FallTimer" to="MovementDrag" method="fall"]

View file

@ -6,6 +6,7 @@
radius = 4.0 radius = 4.0
[node name="Cursor" type="Area2D" groups=["cursor"]] [node name="Cursor" type="Area2D" groups=["cursor"]]
z_index = 100
collision_layer = 64 collision_layer = 64
collision_mask = 40 collision_mask = 40
script = ExtResource("1_1og6v") script = ExtResource("1_1og6v")