This commit is contained in:
Bingus_Violet 2024-02-26 08:28:11 -06:00
parent 5cfdd34e96
commit 13ccecad19
25 changed files with 730 additions and 53 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 121 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bi5ofgcvid5qk"
path="res://.godot/imported/GrappleCenter.png-5e9ed5c2d1472f72fd1015c922d13ef9.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Player/GrappleHook/GrappleCenter.png"
dest_files=["res://.godot/imported/GrappleCenter.png-5e9ed5c2d1472f72fd1015c922d13ef9.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

View file

@ -0,0 +1,93 @@
extends Node2D
@onready var player = $"../../"
@onready var sprite = $"../"
@onready var grappleCore = $"../GrappleCore"
@onready var Smoother = $"../../../Smoother"
var grappleProjectile = preload("res://Player/GrappleHook/GrappleHookProjectile/GrappleHookProjectile.tscn")
var proj = null
var grappleSpeed = Vector2.ZERO
var retractDur = 0
var retractStart = Vector2.ZERO
var grappleDur = 0
var grappling = false
var retracting = false
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
func grappleStart():
grappleSpeed = (500 + clamp(player.velocity.length(), 500, 1000))
grappleDur = .5
grappling = true
func _physics_process(delta):
grappleDur -= 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
proj = grappleProjectile.instantiate()
proj.position = player.position
proj.rotation = moveVector.angle()
proj.velocity = (moveVector * 1500) + player.velocity
#grappleDur = 10
add_child(proj)
#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.velocity.y = player.JUMP_VELOCITY
grappleDur = 0
retractStart = proj.position
retracting = true
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
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

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bncu47o5ynskj"
path="res://.godot/imported/Grapple.png-feaba7449a5f3ea3aa251c5a08ccef36.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Player/GrappleHook/GrappleHookProjectile/Grapple.png"
dest_files=["res://.godot/imported/Grapple.png-feaba7449a5f3ea3aa251c5a08ccef36.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

View file

@ -0,0 +1,37 @@
extends CharacterBody2D
var lifeTime = 0.6
@onready var parent = get_parent()
var lastPos = null
var detecting = true
func objectHit(body):
if body != self:
velocity = Vector2.ZERO
parent.grappleStart()
func _physics_process(delta):
if not lastPos:
lastPos = position
move_and_slide()
if detecting:
if lifeTime <= 0:
velocity = Vector2.ZERO
parent.retracting = true
parent.retractStart = position
lifeTime -= delta
var space_state = get_world_2d().direct_space_state
var query = PhysicsRayQueryParameters2D.create(lastPos, position, 3, [parent.get_parent().get_parent()])
var result = space_state.intersect_ray(query)
if result:
detecting = false
position = result.position
objectHit(result.collider)
print(result.position)

View file

@ -0,0 +1,43 @@
[gd_scene load_steps=4 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"]
[node name="GrappleHook" type="CharacterBody2D"]
top_level = true
disable_mode = 2
collision_layer = 4
collision_mask = 0
motion_mode = 1
platform_floor_layers = 4294967040
script = ExtResource("1_nba88")
[node name="Sprite" type="Sprite2D" parent="."]
z_index = 2
texture = ExtResource("2_sst4t")
[node name="GrappleLine" type="Line2D" parent="."]
top_level = true
z_index = 1
texture_repeat = 2
points = PackedVector2Array(0, 0, 33, 0)
width = 4.0
texture = ExtResource("2_xkdsl")
texture_mode = 1
joint_mode = 2
begin_cap_mode = 2
end_cap_mode = 2
round_precision = 4
[node name="GrappleBord" type="Line2D" parent="."]
modulate = Color(0, 0, 0, 1)
top_level = true
texture_repeat = 2
points = PackedVector2Array(0, 0, 33, 0)
width = 6.0
texture_mode = 1
joint_mode = 2
begin_cap_mode = 2
end_cap_mode = 2
round_precision = 4

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://gn347ng3iu02"
path="res://.godot/imported/GrappleTether.png-070f72f0eebbe08ec00dac245679c61b.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Player/GrappleHook/GrappleHookProjectile/GrappleTether.png"
dest_files=["res://.godot/imported/GrappleTether.png-070f72f0eebbe08ec00dac245679c61b.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 B

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 119 B