Skip to content

Commit

Permalink
water movement
Browse files Browse the repository at this point in the history
  • Loading branch information
maggardJosh committed Apr 13, 2024
1 parent 094ff45 commit 9471633
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 12 deletions.
116 changes: 107 additions & 9 deletions main.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
[sub_resource type="ShaderMaterial" id="ShaderMaterial_sylxd"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_mb8yo"]
size = Vector2(800, 300)
size = Vector2(4927, 1943)

[sub_resource type="PlaceholderTexture2D" id="PlaceholderTexture2D_t5me4"]
size = Vector2(16, 16)
Expand Down Expand Up @@ -39,34 +39,132 @@ linear_damp = 0.5
script = ExtResource("3_58cow")

[node name="CollisionShape2D" type="CollisionShape2D" parent="WaterArea"]
position = Vector2(0, 150)
position = Vector2(493.5, 971.5)
shape = SubResource("RectangleShape2D_mb8yo")

[node name="Sprite2D" type="Sprite2D" parent="."]
[node name="UI" parent="." instance=ExtResource("3_0cdyn")]

[node name="Placeholder stuff" type="Node2D" parent="."]

[node name="Sprite2D" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-234, 25)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D2" type="Sprite2D" parent="."]
[node name="Sprite2D2" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-209, 72)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D3" type="Sprite2D" parent="."]
[node name="Sprite2D3" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(2, 60)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D4" type="Sprite2D" parent="."]
[node name="Sprite2D4" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-3, 12)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D5" type="Sprite2D" parent="."]
[node name="Sprite2D5" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-285, 94)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D6" type="Sprite2D" parent="."]
[node name="Sprite2D6" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-303, -1)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="UI" parent="." instance=ExtResource("3_0cdyn")]
[node name="Sprite2D7" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(183, 151)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D8" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(208, 198)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D9" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(419, 186)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D10" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(414, 138)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D11" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(132, 220)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D12" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(114, 125)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D13" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-51, 84)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D14" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-26, 131)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D15" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(185, 119)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D16" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(180, 71)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D17" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-102, 153)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D18" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-120, 58)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D19" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-522, 58)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D20" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-497, 105)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D21" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-286, 93)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D22" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-291, 45)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D23" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-573, 127)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D24" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-591, 32)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D25" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-348, 277)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D26" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-323, 324)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D27" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-112, 312)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D28" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-117, 264)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D29" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-399, 346)
texture = SubResource("PlaceholderTexture2D_t5me4")

[node name="Sprite2D30" type="Sprite2D" parent="Placeholder stuff"]
position = Vector2(-417, 251)
texture = SubResource("PlaceholderTexture2D_t5me4")

[connection signal="body_entered" from="WaterArea" to="WaterArea" method="_on_body_entered"]
[connection signal="body_exited" from="WaterArea" to="WaterArea" method="_on_body_exited"]
8 changes: 8 additions & 0 deletions player.gd
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ func exit_water():
is_in_water = false
velocity.y *= 2

var noise_count: float = 0
func _physics_process(delta):
GameEvents.add_debug_obj.emit("in_water", is_in_water)
GameEvents.add_debug_obj.emit("grounded", is_on_floor())
GameEvents.add_debug_obj.emit("pos", global_position)
if Input.is_action_just_pressed("exit"):
get_tree().quit()

Expand All @@ -60,6 +64,10 @@ func _physics_process(delta):
else:
velocity.x = move_toward(velocity.x, 0, air_friction_speed * delta)
else:
noise_count += delta
var x_disp = float_noise.noise.get_noise_2d(noise_count, 0) * float_effect_magnitude
var y_disp = float_noise.noise.get_noise_2d(0, noise_count) * float_effect_magnitude
sprite.position = Vector2(x_disp, y_disp)

var x_input = direction_input.x
var y_input = direction_input.y
Expand Down
18 changes: 15 additions & 3 deletions player.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@
[ext_resource type="Texture2D" uid="uid://c4etptninfkid" path="res://player.png" id="2_7u1va"]

[sub_resource type="FastNoiseLite" id="FastNoiseLite_4exyn"]
noise_type = 3
frequency = 0.2

[sub_resource type="NoiseTexture2D" id="NoiseTexture2D_eelr5"]
seamless = true
noise = SubResource("FastNoiseLite_4exyn")

[sub_resource type="CircleShape2D" id="CircleShape2D_rnvbg"]
Expand All @@ -22,13 +25,22 @@ water_accel = 175.0
water_speed = 150.0
water_friction_speed = 175.0
float_noise = SubResource("NoiseTexture2D_eelr5")
float_effect_magnitude = 8.0

[node name="Sprite" type="Sprite2D" parent="."]
unique_name_in_owner = true
texture = ExtResource("2_7u1va")

[node name="Camera2D" type="Camera2D" parent="Sprite"]
zoom = Vector2(2, 2)

[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_rnvbg")

[node name="Camera2D" type="Camera2D" parent="."]
zoom = Vector2(2, 2)
process_callback = 0
position_smoothing_enabled = true
drag_horizontal_enabled = true
drag_vertical_enabled = true
drag_left_margin = 0.05
drag_top_margin = 0.05
drag_right_margin = 0.05
drag_bottom_margin = 0.05

0 comments on commit 9471633

Please sign in to comment.