Attempted to use the particle system
This commit is contained in:
parent
798e64e284
commit
8c0deb42a2
5 changed files with 221 additions and 25 deletions
|
|
@ -157,6 +157,8 @@ func hurt(dmg: int, dir: Vector2 = Vector2.ZERO):
|
||||||
|
|
||||||
inv_time = hit_invulnerability
|
inv_time = hit_invulnerability
|
||||||
reset_to_velocity = Vector2(-sign(earth_aligner.local_from_global(dir).x)*knockback_strength, -damage_knockup)
|
reset_to_velocity = Vector2(-sign(earth_aligner.local_from_global(dir).x)*knockback_strength, -damage_knockup)
|
||||||
|
return true
|
||||||
|
return false
|
||||||
|
|
||||||
func die():
|
func die():
|
||||||
if not dead:
|
if not dead:
|
||||||
|
|
|
||||||
BIN
water/Warning_particle_emmission_shape.png
Normal file
BIN
water/Warning_particle_emmission_shape.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 839 B |
40
water/Warning_particle_emmission_shape.png.import
Normal file
40
water/Warning_particle_emmission_shape.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="CompressedTexture2D"
|
||||||
|
uid="uid://dfb734b3lshuk"
|
||||||
|
path="res://.godot/imported/Warning_particle_emmission_shape.png-dcaecf9f51a4295968493261a9781314.ctex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://water/Warning_particle_emmission_shape.png"
|
||||||
|
dest_files=["res://.godot/imported/Warning_particle_emmission_shape.png-dcaecf9f51a4295968493261a9781314.ctex"]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/high_quality=false
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/uastc_level=0
|
||||||
|
compress/rdo_quality_loss=0.0
|
||||||
|
compress/hdr_compression=1
|
||||||
|
compress/normal_map=0
|
||||||
|
compress/channel_pack=0
|
||||||
|
mipmaps/generate=false
|
||||||
|
mipmaps/limit=-1
|
||||||
|
roughness/mode=0
|
||||||
|
roughness/src_normal=""
|
||||||
|
process/channel_remap/red=0
|
||||||
|
process/channel_remap/green=1
|
||||||
|
process/channel_remap/blue=2
|
||||||
|
process/channel_remap/alpha=3
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/normal_map_invert_y=false
|
||||||
|
process/hdr_as_srgb=false
|
||||||
|
process/hdr_clamp_exposure=false
|
||||||
|
process/size_limit=0
|
||||||
|
detect_3d/compress_to=1
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
signal water_reached_max_height
|
signal water_reached_max_height
|
||||||
|
@onready var player : Player = %Player
|
||||||
|
@export var animation_height : float = 0
|
||||||
|
@export var radius_base : float = 0
|
||||||
|
|
||||||
var radius : float:
|
var radius : float:
|
||||||
set(new_radius):
|
set(new_radius):
|
||||||
|
|
@ -37,6 +40,32 @@ var tsunami_angle : float:
|
||||||
return
|
return
|
||||||
update_scale(mesh)
|
update_scale(mesh)
|
||||||
mesh.material.set_shader_parameter("tsunami_angle", tsunami_angle)
|
mesh.material.set_shader_parameter("tsunami_angle", tsunami_angle)
|
||||||
|
|
||||||
|
func check_player_collision():
|
||||||
|
var pos = player.position
|
||||||
|
var angle = atan2(pos.y, pos.x)
|
||||||
|
var water_height = get_height_at(angle)
|
||||||
|
var player_height = sqrt(pos.x * pos.x + pos.y * pos.y)
|
||||||
|
if(water_height > player_height - 25):
|
||||||
|
if player.hurt(1, Vector2.ZERO):
|
||||||
|
player.reset_to_velocity = Vector2(0, -2000)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
func get_height_at(angle):
|
||||||
|
var TIME : float = Time.get_ticks_usec() / 1000000.;
|
||||||
|
var wave1 = amplitude/1. * sin(150. * angle + TIME);
|
||||||
|
var wave2 = amplitude/2. * sin(90. * angle + 1.6 * TIME);
|
||||||
|
var wave3 = amplitude/3. * sin(55. * angle + 2.3 * TIME);
|
||||||
|
var wave4 = amplitude/4. * sin(35. * angle + 3.9 * TIME);
|
||||||
|
var wave = wave1 + wave2 + wave3 + wave4;
|
||||||
|
|
||||||
|
var angle_diff : float = angle - tsunami_angle;
|
||||||
|
angle_diff = fmod(angle_diff + PI + TAU, TAU) - PI;
|
||||||
|
var sinc : float = (sin(20. * angle_diff) / angle_diff/ 20.);
|
||||||
|
var tsunami : float = pow(abs(sinc), 1.5) * tsunami_size * sign(sinc);
|
||||||
|
return radius + wave + tsunami;
|
||||||
|
|
||||||
|
|
||||||
@export var animation_angle : float = 0
|
@export var animation_angle : float = 0
|
||||||
@export var tsunami_base_angle : float
|
@export var tsunami_base_angle : float
|
||||||
|
|
@ -60,26 +89,30 @@ func update_shader():
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
update_shader()
|
update_shader()
|
||||||
radius = rise_from
|
radius_base = rise_from
|
||||||
auto_rise = false
|
auto_rise = false
|
||||||
radius = 2950;
|
radius_base = 2950;
|
||||||
create_tsunami(4.712, 1);
|
|
||||||
await get_tree().create_timer(10).timeout
|
#create_tsunami(4.712, 1);
|
||||||
create_tsunami(4.712, 1);
|
await get_tree().create_timer(3).timeout
|
||||||
|
#create_tsunami(4.712, 1);
|
||||||
|
rise_water()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _process(_delta: float) -> void:
|
func _process(_delta: float) -> void:
|
||||||
|
check_player_collision()
|
||||||
if auto_rise:
|
if auto_rise:
|
||||||
var time: float = Time.get_unix_time_from_system()
|
var time: float = Time.get_unix_time_from_system()
|
||||||
if time - start_unix_time > rise_time:
|
if time - start_unix_time > rise_time:
|
||||||
auto_rise = false
|
auto_rise = false
|
||||||
radius = rise_to
|
radius_base = rise_to
|
||||||
water_reached_max_height.emit()
|
water_reached_max_height.emit()
|
||||||
else:
|
else:
|
||||||
radius = lerpf(rise_from, rise_to, (time - start_unix_time) / rise_time)
|
radius_base = lerpf(rise_from, rise_to, (time - start_unix_time) / rise_time)
|
||||||
|
|
||||||
if $Tsunami.is_playing():
|
tsunami_angle = tsunami_base_angle + animation_angle * direction;
|
||||||
tsunami_angle = tsunami_base_angle + animation_angle * direction;
|
radius = radius_base + animation_height
|
||||||
|
|
||||||
# direction is -1 for left, +1 for right
|
# direction is -1 for left, +1 for right
|
||||||
func create_tsunami(angle : float, dir : int):
|
func create_tsunami(angle : float, dir : int):
|
||||||
|
|
@ -90,3 +123,9 @@ func create_tsunami(angle : float, dir : int):
|
||||||
tsunami_base_angle = angle;
|
tsunami_base_angle = angle;
|
||||||
|
|
||||||
$Tsunami.play("tsunami")
|
$Tsunami.play("tsunami")
|
||||||
|
|
||||||
|
func rise_water():
|
||||||
|
$WaterRise.play("water_rise")
|
||||||
|
await $WaterRise.animation_finished
|
||||||
|
radius_base = radius + animation_height
|
||||||
|
animation_height = 0
|
||||||
|
|
|
||||||
147
water/water.tscn
147
water/water.tscn
File diff suppressed because one or more lines are too long
Loading…
Add table
Reference in a new issue