Started particle system.
This commit is contained in:
parent
f28cecde1b
commit
9a09776900
5 changed files with 55 additions and 10 deletions
10
Materials/Particles/down_particles.tres
Normal file
10
Materials/Particles/down_particles.tres
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[gd_resource type="ParticleProcessMaterial" format=3 uid="uid://ck13qte606w1j"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
particle_flag_disable_z = true
|
||||||
|
emission_shape_offset = Vector3(0, -8, 0)
|
||||||
|
emission_shape = 1
|
||||||
|
emission_sphere_radius = 7.35
|
||||||
|
gravity = Vector3(0, -98, 0)
|
||||||
|
scale_max = 5.0
|
||||||
|
color = Color(0, 0, 0, 1)
|
||||||
10
Materials/Particles/up_particles.tres
Normal file
10
Materials/Particles/up_particles.tres
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
[gd_resource type="ParticleProcessMaterial" format=3 uid="uid://c81obsijtfpwq"]
|
||||||
|
|
||||||
|
[resource]
|
||||||
|
particle_flag_disable_z = true
|
||||||
|
emission_shape_offset = Vector3(0, -8, 0)
|
||||||
|
emission_shape = 1
|
||||||
|
emission_sphere_radius = 7.35
|
||||||
|
gravity = Vector3(0, 98, 0)
|
||||||
|
scale_max = 2.0
|
||||||
|
color = Color(0, 0, 0, 1)
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
[gd_scene load_steps=4 format=3 uid="uid://syx6ov00a585"]
|
[gd_scene load_steps=5 format=3 uid="uid://syx6ov00a585"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://ohb2t6o7wr1u" path="res://Scripts/player.gd" id="1_cvnsp"]
|
[ext_resource type="Script" uid="uid://ohb2t6o7wr1u" path="res://Scripts/player.gd" id="1_cvnsp"]
|
||||||
[ext_resource type="Texture2D" uid="uid://btqnhg54e1p66" path="res://Sprites/png/spritesheet.png" id="2_6t5aa"]
|
[ext_resource type="Texture2D" uid="uid://btqnhg54e1p66" path="res://Sprites/png/spritesheet.png" id="2_6t5aa"]
|
||||||
|
[ext_resource type="Material" uid="uid://ck13qte606w1j" path="res://Materials/Particles/down_particles.tres" id="2_vgqql"]
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jjgbg"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_jjgbg"]
|
||||||
size = Vector2(16, 16)
|
size = Vector2(16, 16)
|
||||||
|
|
@ -9,6 +10,12 @@ size = Vector2(16, 16)
|
||||||
[node name="Player" type="CharacterBody2D"]
|
[node name="Player" type="CharacterBody2D"]
|
||||||
script = ExtResource("1_cvnsp")
|
script = ExtResource("1_cvnsp")
|
||||||
|
|
||||||
|
[node name="GPUParticles2D" type="GPUParticles2D" parent="."]
|
||||||
|
emitting = false
|
||||||
|
amount = 100
|
||||||
|
lifetime = 3.3699999999999997
|
||||||
|
process_material = ExtResource("2_vgqql")
|
||||||
|
|
||||||
[node name="Sprite" type="Sprite2D" parent="."]
|
[node name="Sprite" type="Sprite2D" parent="."]
|
||||||
texture = ExtResource("2_6t5aa")
|
texture = ExtResource("2_6t5aa")
|
||||||
hframes = 2
|
hframes = 2
|
||||||
|
|
@ -16,3 +23,8 @@ vframes = 2
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||||
shape = SubResource("RectangleShape2D_jjgbg")
|
shape = SubResource("RectangleShape2D_jjgbg")
|
||||||
|
|
||||||
|
[node name="VisibleOnScreenNotifier2D" type="VisibleOnScreenNotifier2D" parent="."]
|
||||||
|
rect = Rect2(-8, -8, 16, 16)
|
||||||
|
|
||||||
|
[connection signal="screen_exited" from="VisibleOnScreenNotifier2D" to="." method="_on_visible_on_screen_notifier_2d_screen_exited"]
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ extends CharacterBody2D
|
||||||
|
|
||||||
@onready var tile_layer : TileMapLayer = $"../TileMapLayer"
|
@onready var tile_layer : TileMapLayer = $"../TileMapLayer"
|
||||||
@onready var level : Node2D = $".."
|
@onready var level : Node2D = $".."
|
||||||
|
@onready var particles : GPUParticles2D = $GPUParticles2D
|
||||||
|
|
||||||
@export_category("Movement")
|
@export_category("Movement")
|
||||||
@export var acceleration : float = 50
|
@export var acceleration : float = 50
|
||||||
|
|
@ -16,6 +17,8 @@ func _ready() -> void:
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
|
print(velocity.y)
|
||||||
|
|
||||||
if dead == false:
|
if dead == false:
|
||||||
#Horizontal movement.
|
#Horizontal movement.
|
||||||
move_input = Input.get_axis("move_left", "move_right")
|
move_input = Input.get_axis("move_left", "move_right")
|
||||||
|
|
@ -29,6 +32,9 @@ func _physics_process(delta: float) -> void:
|
||||||
|
|
||||||
if Input.is_action_just_pressed("flip") and (is_on_floor() or is_on_ceiling()):
|
if Input.is_action_just_pressed("flip") and (is_on_floor() or is_on_ceiling()):
|
||||||
al_globals.gravity *= -1
|
al_globals.gravity *= -1
|
||||||
|
|
||||||
|
if velocity.y > 500:
|
||||||
|
particles.emitting = true
|
||||||
|
|
||||||
move_and_slide() #Allow physics control.
|
move_and_slide() #Allow physics control.
|
||||||
spike_detection() #Checks for tiles with the "Spike" custom data enabled.
|
spike_detection() #Checks for tiles with the "Spike" custom data enabled.
|
||||||
|
|
@ -44,19 +50,19 @@ func spike_detection() -> void:
|
||||||
if tile_data:
|
if tile_data:
|
||||||
var custom_data = tile_data.get_custom_data("spike")
|
var custom_data = tile_data.get_custom_data("spike")
|
||||||
if custom_data == true:
|
if custom_data == true:
|
||||||
death()
|
death(false)
|
||||||
await get_tree().create_timer(1).timeout
|
|
||||||
respawn()
|
|
||||||
|
|
||||||
|
func death(fallen: bool) -> void:
|
||||||
func death() -> void:
|
|
||||||
dead = true
|
dead = true
|
||||||
velocity.x = 0
|
if !fallen:
|
||||||
velocity.y = 0
|
velocity.x = 0
|
||||||
scale.x = lerp(scale.x, 0.0, 0.1)
|
velocity.y = 0
|
||||||
scale.y = lerp(scale.y, 0.0, 0.1)
|
scale.x = lerp(scale.x, 0.0, 0.1)
|
||||||
|
scale.y = lerp(scale.y, 0.0, 0.1)
|
||||||
if al_globals.gravity < 0:
|
if al_globals.gravity < 0:
|
||||||
al_globals.gravity *= -1
|
al_globals.gravity *= -1
|
||||||
|
await get_tree().create_timer(1.0).timeout
|
||||||
|
respawn()
|
||||||
|
|
||||||
func respawn() -> void:
|
func respawn() -> void:
|
||||||
dead = false
|
dead = false
|
||||||
|
|
@ -66,3 +72,6 @@ func respawn() -> void:
|
||||||
position.y = level.startPosY
|
position.y = level.startPosY
|
||||||
|
|
||||||
|
|
||||||
|
func _on_visible_on_screen_notifier_2d_screen_exited() -> void:
|
||||||
|
if !dead:
|
||||||
|
death(true)
|
||||||
|
|
|
||||||
|
|
@ -41,3 +41,7 @@ move_right={
|
||||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194321,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[rendering]
|
||||||
|
|
||||||
|
environment/defaults/default_clear_color=Color(1, 1, 1, 1)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue