Added rain with terrain collision
This commit is contained in:
parent
471c496003
commit
335a082dae
4 changed files with 38 additions and 6 deletions
|
@ -1,10 +1,14 @@
|
|||
[gd_scene load_steps=2 format=3 uid="uid://cbynoofsjcl45"]
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cbynoofsjcl45"]
|
||||
|
||||
[ext_resource type="Script" path="res://core/dynamic_polygon.gd" id="1_2pai0"]
|
||||
|
||||
[sub_resource type="OccluderPolygon2D" id="OccluderPolygon2D_fkh4m"]
|
||||
|
||||
[node name="DynamicPolygon" type="CollisionPolygon2D"]
|
||||
script = ExtResource("1_2pai0")
|
||||
update = null
|
||||
|
||||
[node name="Polygon2D" type="Polygon2D" parent="."]
|
||||
color = Color(0, 0, 0, 1)
|
||||
|
||||
[node name="LightOccluder2D" type="LightOccluder2D" parent="."]
|
||||
editor_description = "For particle collisions"
|
||||
occluder = SubResource("OccluderPolygon2D_fkh4m")
|
||||
|
|
|
@ -13,8 +13,13 @@ extends CollisionPolygon2D
|
|||
update_polygon()
|
||||
|
||||
func update_polygon():
|
||||
# normal polygon
|
||||
$Polygon2D.polygon = polygon
|
||||
$Polygon2D.color = color
|
||||
# light occluder
|
||||
var lo_polygon = OccluderPolygon2D.new()
|
||||
lo_polygon.polygon = polygon
|
||||
$LightOccluder2D.occluder = lo_polygon
|
||||
|
||||
func _ready() -> void:
|
||||
update_polygon()
|
||||
|
|
|
@ -13,9 +13,7 @@ position = Vector2(400, 224)
|
|||
[node name="DynamicPolygon" parent="StaticBody2D" instance=ExtResource("2_83sm2")]
|
||||
polygon = PackedVector2Array(296, 288, 296, 368, 536, 368, 536, 336, 776, 336, 776, 400, 104, 400, 104, 360, 184, 360, 184, 304, 248, 304, 248, 288)
|
||||
color = Color(0.235294, 0.607843, 0.643137, 1)
|
||||
update = false
|
||||
|
||||
[node name="DynamicPolygon2" parent="StaticBody2D" instance=ExtResource("2_83sm2")]
|
||||
polygon = PackedVector2Array(520, 96, 520, 280, 552, 280, 552, 32, 632, 32, 632, -8, 520, -8)
|
||||
color = Color(0.236278, 0.606088, 0.644729, 1)
|
||||
update = false
|
||||
|
|
|
@ -1,7 +1,22 @@
|
|||
[gd_scene load_steps=3 format=3 uid="uid://ebb4pfxklatj"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://ebb4pfxklatj"]
|
||||
|
||||
[ext_resource type="Script" path="res://player/player.gd" id="1_fob34"]
|
||||
|
||||
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_v306m"]
|
||||
particle_flag_disable_z = true
|
||||
emission_shape_scale = Vector3(640, 300, 1)
|
||||
emission_shape = 3
|
||||
emission_box_extents = Vector3(1, 1, 1)
|
||||
direction = Vector3(0, 1, 0)
|
||||
spread = 0.0
|
||||
initial_velocity_min = 300.0
|
||||
initial_velocity_max = 400.0
|
||||
gravity = Vector3(0, 0, 0)
|
||||
scale_min = 2.0
|
||||
scale_max = 2.5
|
||||
color = Color(1, 1, 1, 0.75)
|
||||
collision_mode = 2
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_7cq61"]
|
||||
size = Vector2(16, 16)
|
||||
|
||||
|
@ -15,6 +30,16 @@ position_smoothing_enabled = true
|
|||
drag_horizontal_enabled = true
|
||||
drag_vertical_enabled = true
|
||||
|
||||
[node name="Rain" type="GPUParticles2D" parent="Camera2D"]
|
||||
position = Vector2(0, -640)
|
||||
amount = 2048
|
||||
amount_ratio = 0.5
|
||||
process_material = SubResource("ParticleProcessMaterial_v306m")
|
||||
lifetime = 3.0
|
||||
preprocess = 5.0
|
||||
fixed_fps = 0
|
||||
visibility_rect = Rect2(-512, 320, 1024, 640)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_7cq61")
|
||||
|
||||
|
|
Reference in a new issue