Grapple effects & particles & stuff :)

This commit is contained in:
Bingus_Violet 2024-02-27 11:27:54 -06:00
parent c290b1ce72
commit 421220e763
13 changed files with 203 additions and 61 deletions

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,41 @@
[gd_scene load_steps=7 format=3 uid="uid://c7ee2fxogdnlx"]
[ext_resource type="Script" path="res://Particles/Scripts/OneshotParticles.gd" id="1_8sxdw"]
[sub_resource type="Curve" id="Curve_ij5tg"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.721154, 0), -1.52381, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_lhu0n"]
curve = SubResource("Curve_ij5tg")
[sub_resource type="Curve" id="Curve_a1gx6"]
max_value = 3.0
_data = [Vector2(0, 3), 0.0, 0.0, 0, 0, Vector2(1, 1), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_210cn"]
curve = SubResource("Curve_a1gx6")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_75uqe"]
particle_flag_align_y = true
particle_flag_disable_z = true
inherit_velocity_ratio = 0.5
initial_velocity_min = 250.0
initial_velocity_max = 250.0
gravity = Vector3(0, 0, 0)
damping_min = 50.0
damping_max = 50.0
scale_min = 0.5
scale_curve = SubResource("CurveTexture_lhu0n")
scale_over_velocity_max = 1000.0
scale_over_velocity_curve = SubResource("CurveTexture_210cn")
[node name="FireParticles" type="GPUParticles2D"]
top_level = true
process_material = SubResource("ParticleProcessMaterial_75uqe")
lifetime = 0.75
explosiveness = 1.0
trail_enabled = true
trail_lifetime = 0.1
script = ExtResource("1_8sxdw")

View file

@ -0,0 +1,13 @@
extends GPUParticles2D
var following = false
func _ready():
emitting = true
one_shot = true
await get_tree().create_timer(lifetime * 2).timeout
queue_free()
func _process(delta):
global_position = get_parent().global_position

View file

@ -6,12 +6,13 @@ var spinAccel = 0
func spin(veloc, delta):
var vertSpinMult = abs(veloc.y) * clamp(veloc.x, -1, 1) / 1.5
var spinFactor = (veloc.x + vertSpinMult) / 30
var spinFactor = (veloc.x + vertSpinMult) / 40
spinFactor = clamp(spinFactor, -25, 25)
if player.direction or abs(player.velocity.x) > 100:
rotation = lerp(rotation, rotation + (spinFactor), delta)
else:
rotation = lerp(rotation, snappedf(rotation + (spinFactor * delta * 2), PI / 2), delta * 5)
rotation = lerp(rotation, snappedf(rotation + clamp(spinFactor * delta * 2, -PI / 3, PI / 3), PI / 2), delta * 5)
var landed = 0

View file

@ -8,9 +8,10 @@ var addedveloc = 0
const JUMP_VELOCITY = -450.0
const MAX_JUMPS = 2
var jumps = MAX_JUMPS
var wallKayote = 0
const FALL_SPEED = -JUMP_VELOCITY * 1.5
const FALL_SPEED = -JUMP_VELOCITY
var falling = false
var floorTime = 0
@ -20,6 +21,12 @@ var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func isWallSliding():
return is_on_wall_only() and direction
func getGravMulti():
var axis = (gen.boolToNumb(Input.is_action_pressed("up"), 1))
if velocity.y < 0:
return axis
return 1
func launch(veloc):
addedveloc = veloc
velocity.x = veloc
@ -27,13 +34,15 @@ func launch(veloc):
signal Jumped
func _physics_process(delta):
direction = round(Input.get_axis("left", "right"))
wallKayote -= delta
if not is_on_floor():
var lowGrav = velocity.y < 0 and (Input.is_action_pressed("up") or Input.is_action_pressed("jump"))
velocity.y += gravity * delta / gen.boolToNumb(lowGrav, 1)
if velocity.y < 1500:
var lowGrav = velocity.y < 0 and (Input.is_action_pressed("up") or Input.is_action_pressed("jump"))
velocity.y += gravity * delta / getGravMulti()
floorTime = 0
else:
@ -45,7 +54,7 @@ func _physics_process(delta):
wallKayote = 0.2
falling = false
if Input.is_action_just_pressed("respawn") or position.y > 500:
if Input.is_action_just_pressed("respawn") or position.y > 5000:
position = Vector2.ZERO
velocity = Vector2.ZERO
@ -53,8 +62,8 @@ func _physics_process(delta):
if wallKayote > 0 and not is_on_floor():
wallKayote /= 2
if Input.is_action_pressed("down"):
launch(get_wall_normal().x * SPEED * 2.5)
velocity.y = JUMP_VELOCITY / 2
launch(get_wall_normal().x * SPEED * 2)
velocity.y = JUMP_VELOCITY / 1.8
else:
launch(get_wall_normal().x * SPEED * 1.5)
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY)

View file

@ -2,9 +2,13 @@ extends Camera2D
@onready var player = $"../"
var speedMod = 0
func _process(delta):
var velocModifier = clamp(abs(player.velocity.x) - 700, 0, 1000)
var direction = clamp(player.velocity.x, -1, 1)
speedMod = lerpf(speedMod, velocModifier * direction / 10, delta * 20)
position = (get_local_mouse_position() / 3)
position.x += velocModifier * direction / 10
position.x += speedMod

View file

@ -5,5 +5,5 @@
[node name="Camera" type="Camera2D"]
zoom = Vector2(3, 3)
position_smoothing_enabled = true
position_smoothing_speed = 35.0
position_smoothing_speed = 1.0
script = ExtResource("1_5yyqm")

View file

@ -48,3 +48,19 @@ offset_right = 283.0
offset_bottom = 177.0
text = "Added Velocity: 0"
label_settings = SubResource("LabelSettings_nvd2b")
[node name="Jumps" type="Label" parent="GuiRoot"]
layout_mode = 0
offset_top = 168.0
offset_right = 283.0
offset_bottom = 213.0
text = "Jumps: 0"
label_settings = SubResource("LabelSettings_nvd2b")
[node name="Grapples" type="Label" parent="GuiRoot"]
layout_mode = 0
offset_top = 208.0
offset_right = 283.0
offset_bottom = 253.0
text = "Grapples: 0"
label_settings = SubResource("LabelSettings_nvd2b")

View file

@ -1,13 +1,19 @@
extends Control
@onready var player = $"../../"
@onready var grapple = $"../../Sprite/Grapple"
@onready var velocNumb = $"Velocity"
@onready var horzVeloc = $"HorzVeloc"
@onready var vertVeloc = $"VertVeloc"
@onready var addedVeloc = $"AddedVeloc"
@onready var jumps = $"Jumps"
@onready var grapples = $"Grapples"
func _physics_process(delta):
velocNumb.text = "Velocity: " + str(round(player.velocity.length()))
horzVeloc.text = "Horizontal Velocity: " + str(round(abs(player.velocity.x)))
vertVeloc.text = "Vertical Velocity: " + str(round(abs(player.velocity.y)))
horzVeloc.text = "Horizontal Velocity: " + str(round(player.velocity.x))
vertVeloc.text = "Vertical Velocity: " + str(round(player.velocity.y))
addedVeloc.text = "Added Velocity: " + str(round(abs(player.addedveloc)))
jumps.text = "Jumps: " + str(player.jumps)
grapples.text = "Grapples: " + str(grapple.grapples)

View file

@ -10,6 +10,7 @@ extends Node2D
var grappleProjectile = preload("res://Player/GrappleHook/GrappleHookProjectile/GrappleHookProjectile.tscn")
var proj = null
var retractingProj = []
var grappleSpeed = Vector2.ZERO
var retractDur = 0
@ -18,18 +19,40 @@ var retractStart = Vector2.ZERO
var grappleDur = 0
var grappling = false
var retracting = false
var grapples = 0
var grappleShootParti = preload("res://Particles/Grapple/GrappleParti.tscn")
func renderLine(proj):
var grappleLine = proj.get_node("GrappleLine")
var grappleBord = proj.get_node("GrappleBord")
var grapOffset = grappleCore.offset * sprite.scale
grappleLine.set_point_position(1, player.position + grapOffset)
grappleBord.set_point_position(1, player.position + grapOffset)
grappleLine.set_point_position(0, proj.position)
grappleBord.set_point_position(0, proj.position)
var curve = Curve.new()
curve.add_point(Vector2(0, 1))
curve.add_point(Vector2(1, sprite.scale.y))
grappleLine.width_curve = curve
grappleBord.width_curve = curve
func launch(delta):
if proj:
player.jumps = player.MAX_JUMPS - 1
var grappleVeloc = (proj.position - player.position).normalized() * grappleSpeed
player.launch(grappleVeloc.x)
player.velocity.y = grappleVeloc.y
player.velocity.y = lerp(player.velocity.y, grappleVeloc.y, 10 * delta)
func grappleStart():
grappleSpeed = (500 + clamp(player.velocity.length(), 500, 1000))
grappleDur = 1
grappleDur = 0.5
grappling = true
func _physics_process(delta):
@ -37,57 +60,59 @@ func _physics_process(delta):
var moveVector = (get_global_mouse_position() - player.position).normalized()
if Input.is_action_just_pressed("pullGrapple") and not proj:
#player.velocity.y = player.JUMP_VELOCITY / 2
if player.is_on_floor():
grapples = 2
if Input.is_action_just_pressed("pullGrapple") and not proj and grapples:
grapples -= 1
proj = grappleProjectile.instantiate()
proj.position = player.position
proj.rotation = moveVector.angle()
proj.modulate = Color8(0, 255, 0)
proj.velocity = (moveVector * 1500) + player.velocity
#grappleDur = 10
add_child(proj)
var parti = grappleShootParti.instantiate()
parti.rotation = proj.rotation
parti.position = proj.position
parti.process_material.initial_velocity_min = (proj.velocity.length() + player.velocity.length()) / 6
add_child(parti)
#else:
if proj and grappleDur > 0 and (player.position - proj.position).length() > 15 and not Input.is_action_just_pressed("jump"):
launch(delta)
elif proj and grappling:
player.jumps = 1
player.jumps += 1
player.falling = false
#player.velocity.y = player.JUMP_VELOCITY
grappleDur = 0
retractStart = proj.position
retracting = true
retractingProj.append({"proj": proj, "retractStart": proj.position, "retractDur": 0})
proj = null
grappling = false
func _process(delta):
if proj and retracting == true:
proj.position = lerp(retractStart, player.position, retractDur)
retractDur += delta * 4
if retractDur >= 1:
proj.queue_free()
proj = null
retracting = false
retractDur = 0
for projData in retractingProj:
var proj = projData.proj
if is_instance_valid(proj):
proj.position = lerp(projData.retractStart, player.position, projData.retractDur)
projData.retractDur += delta * 4 / ((projData.retractStart - player.position).length() / 300)
renderLine(proj)
if projData.retractDur >= 1:
var parti = proj.get_node("parti")
parti.emitting = false
parti.modulate = proj.modulate
parti.reparent(player)
proj.queue_free()
proj = null
retractDur = 0
else:
retractingProj.remove_at(retractingProj.find(projData))
if proj:
#Engine.time_scale = 0.1
var grappleLine = proj.get_node("GrappleLine")
var grappleBord = proj.get_node("GrappleBord")
var grapOffset = grappleCore.offset * sprite.scale
grappleLine.set_point_position(1, player.position + grapOffset)
grappleBord.set_point_position(1, player.position + grapOffset)
grappleLine.set_point_position(0, proj.position)
grappleBord.set_point_position(0, proj.position)
var curve = Curve.new()
curve.add_point(Vector2(0, 1))
curve.add_point(Vector2(1, sprite.scale.y))
grappleLine.width_curve = curve
grappleBord.width_curve = curve
if is_instance_valid(proj):
renderLine(proj)

View file

@ -8,6 +8,8 @@ var lastPos = null
var detecting = true
var partiDebounce = true
func objectHit(body):
if body != self:
velocity = Vector2.ZERO
@ -19,11 +21,15 @@ func _physics_process(delta):
move_and_slide()
$"parti".emitting = (lastPos - position).length() > 0
if detecting:
if lifeTime <= 0:
velocity = Vector2.ZERO
parent.retracting = true
parent.retractStart = position
parent.retractingProj.append({"proj": self, "retractStart": position, "retractDur": 0})
parent.grappling = false
parent.proj = null
detecting = false
lifeTime -= delta
var space_state = get_world_2d().direct_space_state
@ -34,4 +40,4 @@ func _physics_process(delta):
detecting = false
position = result.position
objectHit(result.collider)
print(result.position)
lastPos = position

View file

@ -1,9 +1,29 @@
[gd_scene load_steps=4 format=3 uid="uid://dmgf8fsvy1wjh"]
[gd_scene load_steps=7 format=3 uid="uid://dmgf8fsvy1wjh"]
[ext_resource type="Script" path="res://Player/GrappleHook/GrappleHookProjectile/GrappleHookProjectile.gd" id="1_nba88"]
[ext_resource type="Texture2D" uid="uid://bncu47o5ynskj" path="res://Player/GrappleHook/GrappleHookProjectile/Grapple.png" id="2_sst4t"]
[ext_resource type="Texture2D" uid="uid://gn347ng3iu02" path="res://Player/GrappleHook/GrappleHookProjectile/GrappleTether.png" id="2_xkdsl"]
[sub_resource type="Curve" id="Curve_qnwwb"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), -2.51429, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_f4r8k"]
curve = SubResource("Curve_qnwwb")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_tkwr2"]
particle_flag_align_y = true
particle_flag_disable_z = true
inherit_velocity_ratio = 0.1
spread = 180.0
initial_velocity_min = 50.0
initial_velocity_max = 50.0
gravity = Vector3(0, 0, 0)
damping_min = 50.0
damping_max = 50.0
scale_max = 2.0
scale_curve = SubResource("CurveTexture_f4r8k")
[node name="GrappleHook" type="CharacterBody2D"]
top_level = true
disable_mode = 2
@ -41,3 +61,11 @@ joint_mode = 2
begin_cap_mode = 2
end_cap_mode = 2
round_precision = 4
[node name="parti" type="GPUParticles2D" parent="."]
amount = 100
process_material = SubResource("ParticleProcessMaterial_tkwr2")
lifetime = 2.0
fixed_fps = 0
interpolate = false
visibility_rect = Rect2(-12500, -12500, 25000, 25000)

View file

@ -13,7 +13,7 @@ config_version=5
config/name="Grapple Test"
run/main_scene="res://Maps/Testing Purgatory.tscn"
config/features=PackedStringArray("4.2", "Forward Plus")
run/max_fps=144
run/max_fps=60
boot_splash/bg_color=Color(0, 0, 0, 1)
config/icon="res://icon.svg"
@ -54,6 +54,7 @@ up={
"deadzone": 0.5,
"events": [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":87,"key_label":0,"unicode":119,"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":4194320,"key_label":0,"unicode":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":32,"key_label":0,"unicode":32,"echo":false,"script":null)
]
}
down={