After imagees

This commit is contained in:
Bingus_Violet 2024-02-29 10:38:22 -06:00
parent 421220e763
commit 279b5e5599
8 changed files with 91 additions and 35 deletions

View file

@ -0,0 +1,11 @@
[gd_scene load_steps=2 format=3 uid="uid://bfd5g1y0u4e38"]
[ext_resource type="Script" path="res://Particles/Scripts/FadeAway.gd" id="1_jmv86"]
[node name="AfterImage" type="Sprite2D"]
modulate = Color(1, 1, 1, 0.752941)
show_behind_parent = true
top_level = true
visibility_layer = 257
rotation = 0.0123838
script = ExtResource("1_jmv86")

View file

@ -0,0 +1,20 @@
extends Sprite2D
@onready var parent = get_parent()
var duration = 0.25
func _ready():
self_modulate = parent.self_modulate
texture = parent.texture
scale = parent.scale
offset = parent.offset
global_position = parent.global_position
rotation = parent.rotation
var tween = create_tween()
tween.tween_property(self, "modulate", Color8(255, 255, 255, 0), duration)
await get_tree().create_timer(duration).timeout
queue_free()

View file

@ -18,17 +18,34 @@ var landed = 0
@onready var slidingVariants = [$"WallslidingNeutral", $"WallslidingUp", $"WallslidingDown"] @onready var slidingVariants = [$"WallslidingNeutral", $"WallslidingUp", $"WallslidingDown"]
var afterImage = preload("res://Particles/Player/AfterImage.tscn")
func disableSlidingVariants(keep=null): func disableSlidingVariants(keep=null):
for variant in slidingVariants: for variant in slidingVariants:
if variant != keep: if variant != keep:
variant.emitting = false variant.emitting = false
var imageTimer = 0
var imaging = false
var lastImage = Vector2.ZERO
func _process(delta): func _process(delta):
var velocity = player.velocity var velocity = player.velocity
var grapple = $"GrappleCore" var grapple = $"Grapple/GrappleCore"
var floored = player.is_on_floor() var floored = player.is_on_floor()
if velocity.length() >= 1100:
imaging = true
elif velocity.length() < 800:
imaging = false
if (imaging or find_child("Grapple") and $"Grapple".grappling) and (global_position - lastImage).length() > 16:
var parti = afterImage.instantiate()
add_child(parti)
parti.duration = velocity.length() / 2000
lastImage = global_position
if player.isWallSliding(): if player.isWallSliding():
var wallSlidingParticles = slidingVariants[0] var wallSlidingParticles = slidingVariants[0]
if abs(velocity.y) < 150: if abs(velocity.y) < 150:
@ -53,6 +70,10 @@ func _process(delta):
if player.isWallSliding(): if player.isWallSliding():
rotation = lerp(rotation, deg_to_rad(30) * player.get_wall_normal().x + snappedf(rotation, PI / 2), delta * 15) rotation = lerp(rotation, deg_to_rad(30) * player.get_wall_normal().x + snappedf(rotation, PI / 2), delta * 15)
else: else:
if Input.is_action_just_pressed("down"):
scale.x = 2
scale.y *= 0.5
var floorRot = player.get_floor_normal().angle() + (PI / 2) var floorRot = player.get_floor_normal().angle() + (PI / 2)
if abs(rotation - floorRot) > 0.9: if abs(rotation - floorRot) > 0.9:

View file

@ -2,7 +2,7 @@
[ext_resource type="Texture2D" uid="uid://dvx8lliqdi3dv" path="res://Player/Skins/Square/Square.png" id="1_3vfyw"] [ext_resource type="Texture2D" uid="uid://dvx8lliqdi3dv" path="res://Player/Skins/Square/Square.png" id="1_3vfyw"]
[ext_resource type="Script" path="res://Player/BasicCharacter/CharacterController.gd" id="1_c5ycp"] [ext_resource type="Script" path="res://Player/BasicCharacter/CharacterController.gd" id="1_c5ycp"]
[ext_resource type="PackedScene" uid="uid://cjjrxtvufk35a" path="res://Player/Camera/camera.tscn" id="2_oahgu"] [ext_resource type="Script" path="res://Player/Camera/CameraController.gd" id="2_yp33m"]
[ext_resource type="Script" path="res://Player/BasicCharacter/AnimationController.gd" id="3_6plye"] [ext_resource type="Script" path="res://Player/BasicCharacter/AnimationController.gd" id="3_6plye"]
[ext_resource type="Script" path="res://Player/GrappleHook/GrappleHook.gd" id="5_sv1u0"] [ext_resource type="Script" path="res://Player/GrappleHook/GrappleHook.gd" id="5_sv1u0"]
[ext_resource type="Texture2D" uid="uid://bi5ofgcvid5qk" path="res://Player/GrappleHook/GrappleCenter.png" id="6_ismrc"] [ext_resource type="Texture2D" uid="uid://bi5ofgcvid5qk" path="res://Player/GrappleHook/GrappleCenter.png" id="6_ismrc"]
@ -14,7 +14,7 @@ radius = 8.0
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.738916, 0), -1.78462, 0.0, 0, 0] _data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.738916, 0), -1.78462, 0.0, 0, 0]
point_count = 2 point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_d404m"] [sub_resource type="CurveTexture" id="CurveTexture_1w0c6"]
curve = SubResource("Curve_ky2t4") curve = SubResource("Curve_ky2t4")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_65t6y"] [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_65t6y"]
@ -27,7 +27,7 @@ initial_velocity_max = 34.78
gravity = Vector3(0, 250, 0) gravity = Vector3(0, 250, 0)
scale_min = 2.0 scale_min = 2.0
scale_max = 2.0 scale_max = 2.0
scale_curve = SubResource("CurveTexture_d404m") scale_curve = SubResource("CurveTexture_1w0c6")
[node name="Character" type="CharacterBody2D"] [node name="Character" type="CharacterBody2D"]
collision_mask = 7 collision_mask = 7
@ -35,8 +35,11 @@ floor_stop_on_slope = false
floor_snap_length = 3.0 floor_snap_length = 3.0
script = ExtResource("1_c5ycp") script = ExtResource("1_c5ycp")
[node name="Camera" parent="." instance=ExtResource("2_oahgu")] [node name="Camera" type="Camera2D" parent="."]
zoom = Vector2(3, 3)
position_smoothing_enabled = true
position_smoothing_speed = 20.0 position_smoothing_speed = 20.0
script = ExtResource("2_yp33m")
[node name="BoxCollider" type="CollisionShape2D" parent="."] [node name="BoxCollider" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_jbiem") shape = SubResource("CircleShape2D_jbiem")
@ -44,6 +47,7 @@ shape = SubResource("CircleShape2D_jbiem")
[node name="Sprite" type="Sprite2D" parent="."] [node name="Sprite" type="Sprite2D" parent="."]
self_modulate = Color(0.678431, 0.298039, 1, 1) self_modulate = Color(0.678431, 0.298039, 1, 1)
visibility_layer = 257 visibility_layer = 257
z_index = 1
rotation = 0.0123838 rotation = 0.0123838
texture = ExtResource("1_3vfyw") texture = ExtResource("1_3vfyw")
script = ExtResource("3_6plye") script = ExtResource("3_6plye")
@ -72,10 +76,10 @@ amount = 24
process_material = SubResource("ParticleProcessMaterial_65t6y") process_material = SubResource("ParticleProcessMaterial_65t6y")
[node name="Grapple" type="Node2D" parent="Sprite"] [node name="Grapple" type="Node2D" parent="Sprite"]
modulate = Color(0, 1, 0, 1)
script = ExtResource("5_sv1u0") script = ExtResource("5_sv1u0")
[node name="GrappleCore" type="Sprite2D" parent="Sprite"] [node name="GrappleCore" type="Sprite2D" parent="Sprite/Grapple"]
modulate = Color(0.513726, 1, 0.482353, 1)
texture = ExtResource("6_ismrc") texture = ExtResource("6_ismrc")
[connection signal="Jumped" from="." to="Sprite" method="_on_character_jumped"] [connection signal="Jumped" from="." to="Sprite" method="_on_character_jumped"]

View file

@ -1,9 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://cjjrxtvufk35a"]
[ext_resource type="Script" path="res://Player/Camera/CameraController.gd" id="1_5yyqm"]
[node name="Camera" type="Camera2D"]
zoom = Vector2(3, 3)
position_smoothing_enabled = true
position_smoothing_speed = 1.0
script = ExtResource("1_5yyqm")

View file

@ -3,7 +3,7 @@ extends Node2D
@onready var player = $"../../" @onready var player = $"../../"
@onready var sprite = $"../" @onready var sprite = $"../"
@onready var grappleCore = $"../GrappleCore" @onready var grappleCore = $"GrappleCore"
@onready var Smoother = $"../../../Smoother" @onready var Smoother = $"../../../Smoother"
@ -63,6 +63,8 @@ func _physics_process(delta):
if player.is_on_floor(): if player.is_on_floor():
grapples = 2 grapples = 2
#$"parti".emitting = grappling
if Input.is_action_just_pressed("pullGrapple") and not proj and grapples: if Input.is_action_just_pressed("pullGrapple") and not proj and grapples:
grapples -= 1 grapples -= 1
@ -70,23 +72,25 @@ func _physics_process(delta):
proj.position = player.position proj.position = player.position
proj.rotation = moveVector.angle() proj.rotation = moveVector.angle()
proj.modulate = Color8(0, 255, 0)
modulate = Color8(0, 255, 0)
proj.modulate = modulate
proj.velocity = (moveVector * 1500) + player.velocity proj.velocity = (moveVector * 1000) + player.velocity
#grappleDur = 10 #grappleDur = 10
add_child(proj) add_child(proj)
var parti = grappleShootParti.instantiate() #var parti = grappleShootParti.instantiate()
parti.rotation = proj.rotation #parti.rotation = proj.rotation
parti.position = proj.position #parti.position = proj.position
parti.process_material.initial_velocity_min = (proj.velocity.length() + player.velocity.length()) / 6 #parti.process_material.initial_velocity_min = (proj.velocity.length() + player.velocity.length()) / 6
add_child(parti) #add_child(parti)
#else: #else:
if proj and grappleDur > 0 and (player.position - proj.position).length() > 15 and not Input.is_action_just_pressed("jump"): if proj and grappleDur > 0 and (player.position - proj.position).length() > 15 and not Input.is_action_just_pressed("jump"):
launch(delta) launch(delta)
elif proj and grappling: elif proj and grappling:
player.jumps += 1 player.jumps = player.MAX_JUMPS
player.falling = false player.falling = false
#player.velocity.y = player.JUMP_VELOCITY #player.velocity.y = player.JUMP_VELOCITY
grappleDur = 0 grappleDur = 0
@ -103,10 +107,10 @@ func _process(delta):
projData.retractDur += delta * 4 / ((projData.retractStart - player.position).length() / 300) projData.retractDur += delta * 4 / ((projData.retractStart - player.position).length() / 300)
renderLine(proj) renderLine(proj)
if projData.retractDur >= 1: if projData.retractDur >= 1:
var parti = proj.get_node("parti") if proj.find_child("parti"):
parti.emitting = false var parti = proj.get_node("parti")
parti.modulate = proj.modulate parti.emitting = false
parti.reparent(player) parti.reparent(self)
proj.queue_free() proj.queue_free()
proj = null proj = null
retractDur = 0 retractDur = 0

View file

@ -21,7 +21,8 @@ func _physics_process(delta):
move_and_slide() move_and_slide()
$"parti".emitting = (lastPos - position).length() > 0 if find_child("parti"):
$"parti".emitting = (lastPos - position).length() > 0
if detecting: if detecting:
if lifeTime <= 0: if lifeTime <= 0:
@ -40,4 +41,5 @@ func _physics_process(delta):
detecting = false detecting = false
position = result.position position = result.position
objectHit(result.collider) objectHit(result.collider)
lastPos = position lastPos = position

View file

@ -8,21 +8,23 @@
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), -2.51429, 0.0, 0, 0] _data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), -2.51429, 0.0, 0, 0]
point_count = 2 point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_f4r8k"] [sub_resource type="CurveTexture" id="CurveTexture_h7vvv"]
curve = SubResource("Curve_qnwwb") curve = SubResource("Curve_qnwwb")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_tkwr2"] [sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_tkwr2"]
particle_flag_align_y = true particle_flag_align_y = true
particle_flag_disable_z = true particle_flag_disable_z = true
inherit_velocity_ratio = 0.1 inherit_velocity_ratio = -0.1
direction = Vector3(0, 1, 0)
spread = 180.0 spread = 180.0
flatness = 1.0
initial_velocity_min = 50.0 initial_velocity_min = 50.0
initial_velocity_max = 50.0 initial_velocity_max = 50.0
gravity = Vector3(0, 0, 0) gravity = Vector3(0, 0, 0)
damping_min = 50.0 damping_min = 50.0
damping_max = 50.0 damping_max = 50.0
scale_max = 2.0 scale_max = 2.0
scale_curve = SubResource("CurveTexture_f4r8k") scale_curve = SubResource("CurveTexture_h7vvv")
[node name="GrappleHook" type="CharacterBody2D"] [node name="GrappleHook" type="CharacterBody2D"]
top_level = true top_level = true
@ -39,7 +41,7 @@ texture = ExtResource("2_sst4t")
[node name="GrappleLine" type="Line2D" parent="."] [node name="GrappleLine" type="Line2D" parent="."]
top_level = true top_level = true
z_index = 1 z_index = 2
texture_repeat = 2 texture_repeat = 2
points = PackedVector2Array(0, 0, 33, 0) points = PackedVector2Array(0, 0, 33, 0)
width = 4.0 width = 4.0
@ -53,6 +55,7 @@ round_precision = 4
[node name="GrappleBord" type="Line2D" parent="."] [node name="GrappleBord" type="Line2D" parent="."]
modulate = Color(0, 0, 0, 1) modulate = Color(0, 0, 0, 1)
top_level = true top_level = true
z_index = 1
texture_repeat = 2 texture_repeat = 2
points = PackedVector2Array(0, 0, 33, 0) points = PackedVector2Array(0, 0, 33, 0)
width = 6.0 width = 6.0
@ -63,7 +66,7 @@ end_cap_mode = 2
round_precision = 4 round_precision = 4
[node name="parti" type="GPUParticles2D" parent="."] [node name="parti" type="GPUParticles2D" parent="."]
amount = 100 amount = 200
process_material = SubResource("ParticleProcessMaterial_tkwr2") process_material = SubResource("ParticleProcessMaterial_tkwr2")
lifetime = 2.0 lifetime = 2.0
fixed_fps = 0 fixed_fps = 0