rain and snow! small chance for rain <3 (=

This commit is contained in:
Harmony Honey 2023-03-11 16:08:33 -05:00
parent df7c72ab37
commit 903acc41df
6 changed files with 145 additions and 23 deletions

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(-1.66667,-7.67615e-16,-9.1073e-16,1.97368,145.833,-40.1316)">
<path d="M57.5,20.333C57.5,20.333 80,41.514 80,52C80,62.486 69.918,71 57.5,71C45.082,71 35,62.486 35,52C35,41.514 57.5,20.333 57.5,20.333Z" style="fill:white;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 718 B

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/raindrop.svg-57214b1845cff404066213ac96ff960b.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://media/image/details/raindrop.svg"
dest_files=[ "res://.import/raindrop.svg-57214b1845cff404066213ac96ff960b.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="100%" height="100%" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xml:space="preserve" xmlns:serif="http://www.serif.com/" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2;">
<g transform="matrix(-1.11111,-5.11743e-16,-6.07153e-16,1.31579,113.889,6.57895)">
<path d="M57.5,-5C57.5,-5 80,41.514 80,52C80,62.486 69.918,71 57.5,71C45.082,71 35,62.486 35,52C35,41.514 57.5,-5 57.5,-5Z" style="fill:white;"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 702 B

View file

@ -0,0 +1,35 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/raindrop2.svg-971c87139cbd54c1ad38154d2967305a.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://media/image/details/raindrop2.svg"
dest_files=[ "res://.import/raindrop2.svg-971c87139cbd54c1ad38154d2967305a.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0

View file

@ -10,7 +10,7 @@ onready var clouds := $Center/Clouds
onready var stars := $Center/Stars
onready var sun := $Center/Stars/Sun
onready var moon := $Center/Stars/Moon
onready var snow := $Center/Snow
onready var precip := $Center/Fall
export var cloud_speed := 1.0
export var star_speed := 0.5
@ -24,11 +24,18 @@ var speed_mod := 1.0
var clock := 0.0
var step := 1.0
export var snow_mat : ParticlesMaterial
export var snow_tex : Texture
export var rain_mat : ParticlesMaterial
export var rain_tex : Texture
func _enter_tree():
Shared.connect("scene_changed", self, "scene")
func _ready():
hide.visible = false
particles.emitting = false
particles.visible = false
func scene():
var start = Vector2.ONE * 900
@ -60,26 +67,29 @@ func scene():
#speed_mod = rand_range(0.6, 1.0) * dir
create_clouds()
yield(get_tree(), "physics_frame")
solve_snow()
solve_fall()
func _physics_process(delta):
clouds.rotate(deg2rad(cloud_speed * delta * cloud_dir))
snow.rotation = clouds.rotation
precip.rotation = clouds.rotation
stars.rotate(deg2rad(star_speed * delta * -star_dir))
clock += delta
if clock > step:
clock -= step
solve_snow()
solve_fall()
func create_clouds():
var ci = -1
var pi = -1
var gc = clouds.get_children()
var gcs = gc.size()
var pc = snow.get_children()
var pc = precip.get_children()
var pcs = pc.size()
var is_snow = "2A/" in Shared.csfn or "3B" in Shared.csfn
var is_rain = (randf() > 0.8) and (Shared.map_name != "")
print("smn: ", Shared.map_name, " is_rain: ", is_rain, " is_snow: ", is_snow)
for x in (length / 50.0) + 5:
for y in max(3, x):
@ -104,37 +114,44 @@ func create_clouds():
#c.color.a = lerp(c.color.a, 1.0, clamp((cpl - (length + 700)) / 500.0, 0, 1))
c.color.a = 0.8
if is_snow and cpl < length + 1000:
if cpl < length + 1000:
pi += 1
var p = null
if pi < pcs:
p = pc[pi]
else:
p = particles.duplicate()
snow.add_child(p)
p.owner = snow
p.process_material = p.process_material.duplicate()
precip.add_child(p)
p.owner = precip
#p.process_material = p.process_material.duplicate()
p.process_material = (snow_mat if is_snow else rain_mat).duplicate()
p.texture = snow_tex if is_snow else rain_tex
p.amount = c.scale.x * (200 if is_snow else 100)
p.lifetime = 9.0 if is_snow else 3.0
p.position = c.position
p.rotation = angle + (PI/2.0)
p.process_material.emission_sphere_radius = c.scale.x * 150.0
p.amount = c.scale.x * 200
p.visible = true
p.emitting = true
p.visible = is_snow or is_rain
p.emitting = is_snow or is_rain
# clouds
if ci < gcs:
for a in range(max(ci, 0), gcs):
gc[a].visible = false
# particles
if pi < pcs:
for a in range(max(pi, 0), pcs):
pc[a].visible = false
pc[a].emitting = false
func solve_snow():
for i in snow.get_children():
func solve_fall():
for i in precip.get_children():
var r = i.get_child(0)
var rp = r.get_collision_point()
var d = r.global_position.distance_to(rp)
#print(i.name, " ", d)
i.lifetime = (d / 50.0)
i.lifetime = (d / i.process_material.initial_velocity)

View file

@ -1,14 +1,12 @@
[gd_scene load_steps=15 format=2]
[gd_scene load_steps=17 format=2]
[ext_resource path="res://src/actor/shape/Circle.gd" type="Script" id=1]
[ext_resource path="res://src/autoload/Clouds.gd" type="Script" id=2]
[ext_resource path="res://src/actor/shape/TreeTop.gd" type="Script" id=3]
[ext_resource path="res://src/shader/moon.gdshader" type="Shader" id=4]
[ext_resource path="res://media/image/box/round_rect100.png" type="Texture" id=5]
[ext_resource path="res://media/image/details/circle100.png" type="Texture" id=6]
[sub_resource type="CanvasItemMaterial" id=1]
blend_mode = 1
[ext_resource path="res://media/image/details/raindrop2.svg" type="Texture" id=6]
[ext_resource path="res://media/image/details/circle100.png" type="Texture" id=7]
[sub_resource type="Gradient" id=12]
offsets = PoolRealArray( 0, 0.05, 0.95, 1 )
@ -23,7 +21,7 @@ _data = [ Vector2( 0, 1 ), 0.0, 0.0, 0, 0, Vector2( 0.930435, 1 ), 0.0, 0.0, 0,
[sub_resource type="CurveTexture" id=15]
curve = SubResource( 14 )
[sub_resource type="ParticlesMaterial" id=13]
[sub_resource type="ParticlesMaterial" id=16]
emission_shape = 1
emission_sphere_radius = 150.0
flag_disable_z = true
@ -38,6 +36,25 @@ scale_random = 0.02
scale_curve = SubResource( 15 )
color_ramp = SubResource( 11 )
[sub_resource type="ParticlesMaterial" id=17]
emission_shape = 1
emission_sphere_radius = 150.0
flag_disable_z = true
direction = Vector3( 0, 1, 0 )
spread = 5.0
gravity = Vector3( 0, 0, 0 )
initial_velocity = 200.0
orbit_velocity = 0.0
orbit_velocity_random = 0.0
scale = 0.15
scale_random = 0.02
scale_curve = SubResource( 15 )
color = Color( 0, 0.909804, 1, 0.74902 )
color_ramp = SubResource( 11 )
[sub_resource type="CanvasItemMaterial" id=1]
blend_mode = 1
[sub_resource type="Curve" id=2]
_data = [ Vector2( 0, 1 ), 0.0, -0.527273, 0, 1, Vector2( 1, 0.472727 ), -0.527273, 0.0, 1, 0 ]
@ -53,6 +70,10 @@ shader_param/time_scale = 0.005
z_index = -50
z_as_relative = false
script = ExtResource( 2 )
snow_mat = SubResource( 16 )
snow_tex = ExtResource( 7 )
rain_mat = SubResource( 17 )
rain_tex = ExtResource( 6 )
[node name="Hide" type="Node2D" parent="."]
@ -81,7 +102,7 @@ amount = 200
lifetime = 9.0
preprocess = 10.0
visibility_rect = Rect2( -400, -100, 800, 3000 )
process_material = SubResource( 13 )
process_material = SubResource( 17 )
texture = ExtResource( 6 )
[node name="RayCast2D" type="RayCast2D" parent="Hide/Particles2D"]
@ -199,6 +220,6 @@ radius = 100.0
[node name="Clouds" type="Node2D" parent="Center"]
[node name="Snow" type="Node2D" parent="Center"]
[node name="Fall" type="Node2D" parent="Center"]
z_index = 65
z_as_relative = false