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

229
Core/Scripts/smoother.gd Normal file
View file

@ -0,0 +1,229 @@
# MIT LICENSE
#
# Copyright 2022 Anatol Bogun
#
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
# associated documentation files (the "Software"), to deal in the Software without restriction,
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all copies or
# substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
class_name Smoother extends Node
## Smoother Node
## Version: 1.0.4
##
## A node type that smoothes scene nodes' properties by interpolating _physics_process steps.
##
## For documentation please visit https://github.com/anatolbogun/godot-smoother-node .
## Node properties that are interpolated.
## Defaults to ["position"], even if not displayed in the inspector.
@export var properties:Array[String] = ["position"]
## Apply interpolation to this node's parent.
@export var smooth_parent: = true :
set (value):
if value == false:
# remove parent from _properties in case this gets toggled on and off during runtime
_properties.erase(get_parent())
smooth_parent = value
## Apply interpolation to the recursive children of this node's parent.
@export var recursive: = true
## Explicitly include node paths in addition to the nodes that are included by other Smoother
## settings.
@export var includes:Array[NodePath] = []
## Explicitly exclude node paths.
## This will exclude nodes that would otherwise be included by other settings.
@export var excludes:Array[NodePath] = []
# get an array of all currently smoothed nodes; mainly for debugging performance optimisations
var smoothed_nodes:Array[Node] :
get:
var parent: = get_parent()
return _get_physics_process_nodes(parent, !smooth_parent) if parent != null else [] as Array[Node]
var _properties: = {}
var _physics_process_nodes:Array[Node]
var _physics_process_just_updated: = false
## Reset all smoothed nodes.
func reset() -> void:
_properties.clear()
## Reset a specific node. You may want to call this when a node gets teleported.
func reset_node(node:Node) -> void:
_properties.erase(node)
## Reset a specific Node by NodePath. You may want to call this when a Node gets teleported.
func reset_node_path(path:NodePath) -> void:
var node: = get_node_or_null(path)
if node != null:
reset_node(node)
## Add a Node to the includes Array[NodePath].
func add_include_node(node:Node) -> Array[NodePath]:
return add_include_path(get_path_to(node))
## Add a NodePath to the includes Array[NodePath].
func add_include_path(path:NodePath) -> Array[NodePath]:
return _add_unique_to_array(includes, path) as Array[NodePath]
## Remove a Node from the includes Array[NodePath].
func remove_include_node(node:Node) -> Array[NodePath]:
return remove_include_path(get_path_to(node))
## Remove a NodePath from the includes Array[NodePath].
func remove_include_path(path:NodePath) -> Array[NodePath]:
return _remove_all_from_array(includes, path) as Array[NodePath]
## Add a Node to the excludes Array[NodePath].
func add_exclude_node(node:Node) -> Array[NodePath]:
return add_exclude_path(get_path_to(node))
## Add a NodePath to the excludes Array[NodePath].
func add_exclude_path(path:NodePath) -> Array[NodePath]:
return _add_unique_to_array(excludes, path) as Array[NodePath]
## Remove a Node from the excludes Array[NodePath].
func remove_exclude_node(node:Node) -> Array[NodePath]:
return remove_exclude_path(get_path_to(node))
## Remove a NodePath from the excludes Array[NodePath].
func remove_exclude_path(path:NodePath) -> Array[NodePath]:
return _remove_all_from_array(excludes, path) as Array[NodePath]
## Add an item to an array unless the array already contains that item.
func _add_unique_to_array(array:Array, item:Variant) -> Array:
if !array.has(item):
array.push_back(item)
return array
## Remove all array items that match item.
func _remove_all_from_array(array:Array, item:Variant) -> Array:
while array.has(item):
array.erase(item)
return array
## Apply interpolation to all smoothed_nodes supported properties.
func _process(_delta: float) -> void:
for node in _physics_process_nodes:
if !_properties.has(node): continue
for property in _properties[node]:
var values = _properties[node][property]
if values.size() == 2:
if _physics_process_just_updated:
values[1] = node[property]
node[property] = lerp(values[0], values[1], Engine.get_physics_interpolation_fraction())
_physics_process_just_updated = false
## Store all smoothed_nodes' relevant properties of the previous (origin) and this (target)
## _physics_process frames for interpolation in the upcoming _process frames and apply the origin
## values.
func _physics_process(_delta: float) -> void:
var parent: = get_parent()
if parent == null: return
# move this node to the top of the parent tree (typically a scene's root node) so that it is
# called before all other _physics_processes
parent.move_child(self, 0)
if smooth_parent:
process_priority = parent.process_priority - 1
# update the relevant nodes once per _physics_process
_physics_process_nodes = _get_physics_process_nodes(parent, !smooth_parent)
# clean up _properties
for key in _properties.keys():
if !_physics_process_nodes.has(key):
_properties.erase(key)
for node in _physics_process_nodes:
if !_properties.has(node):
# called on the first frame after a node was added to _properties
_properties[node] = {}
# clean up _properties when a node exited the tree
node.tree_exited.connect(func (): _properties.erase(node))
for property in properties:
if ! property in node: continue
if !_properties[node].has(property):
# called on the first frame after a node was added to _properties
_properties[node][property] = [node[property]]
elif _properties[node][property].size() < 2:
# called on the second frame after a node was added to _properties
_properties[node][property].push_front(_properties[node][property][0])
_properties[node][property][1] = node[property]
else:
_properties[node][property][0] = _properties[node][property][1]
node[property] = _properties[node][property][0]
_physics_process_just_updated = true
## Get the relevant nodes to be smoothed based on this node's tree position and properties.
func _get_physics_process_nodes(node: Node, ignore_node: = false, with_includes: = true) -> Array[Node]:
var nodes:Array[Node] = []
nodes.assign(includes.map(
get_node_or_null
).filter(
func (_node:Node) -> bool: return _node != null && !excludes.has(get_path_to(_node))
) if with_includes else [])
if (
!ignore_node
&& node != self
&& !node is RigidBody2D
&& !node is RigidBody3D
&& !nodes.has(node)
&& !excludes.has(get_path_to(node))
&& node.has_method("_physics_process")
):
nodes.push_back(node)
if recursive:
for child in node.get_children():
for nested_node in _get_physics_process_nodes(child, false, false):
_add_unique_to_array(nodes, nested_node)
return nodes

File diff suppressed because one or more lines are too long

View file

@ -2,38 +2,54 @@ extends Sprite2D
@onready var player = $"../" @onready var player = $"../"
@onready var wallSlidingParticles = $"WallslidingParticles" var spinAccel = 0
func spin(veloc, delta): func spin(veloc, delta):
var vertSpinMult = abs(veloc.y) * clamp(veloc.x, -1, 1) / 1.5 var vertSpinMult = abs(veloc.y) * clamp(veloc.x, -1, 1) / 1.5
var spinFactor = (veloc.x + vertSpinMult) / 30 var spinFactor = (veloc.x + vertSpinMult) / 30
if player.direction: if player.direction or abs(player.velocity.x) > 100:
rotation = lerp(rotation, rotation + (spinFactor), delta) rotation = lerp(rotation, rotation + (spinFactor), delta)
else: else:
rotation = lerp(rotation, snappedf(rotation, PI / 2), delta * 10) rotation = lerp(rotation, snappedf(rotation + (spinFactor * delta * 2), PI / 2), delta * 5)
var landed = 0 var landed = 0
@onready var slidingVariants = [$"WallslidingNeutral", $"WallslidingUp", $"WallslidingDown"]
func disableSlidingVariants(keep=null):
for variant in slidingVariants:
if variant != keep:
variant.emitting = false
func _process(delta): func _process(delta):
var velocity = player.velocity var velocity = player.velocity
var grapple = $"GrappleCore"
var floored = player.is_on_floor() var floored = player.is_on_floor()
if player.is_on_wall_only() and velocity.y > 0: if player.isWallSliding():
var wallSlidingParticles = slidingVariants[0]
if abs(velocity.y) < 150:
wallSlidingParticles = slidingVariants[1]
elif abs(velocity.y) > 300:
wallSlidingParticles = slidingVariants[2]
disableSlidingVariants(wallSlidingParticles)
wallSlidingParticles.emitting = true wallSlidingParticles.emitting = true
wallSlidingParticles.global_position = player.position + (player.get_wall_normal() * -8) wallSlidingParticles.global_position = player.position + (player.get_wall_normal() * -8 * player.scale.x)
wallSlidingParticles.global_rotation = player.get_wall_normal().x * deg_to_rad(45) wallSlidingParticles.global_rotation = player.get_wall_normal().x * deg_to_rad(45)
else: else:
wallSlidingParticles.emitting = false disableSlidingVariants()
if not floored: if not floored:
spin(velocity, delta) spin(velocity, delta)
landed = velocity.y landed = velocity.y
scale = Vector2.ONE #scale = Vector2.ONE
if player.is_on_wall(): 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:
var floorRot = player.get_floor_normal().angle() + (PI / 2) var floorRot = player.get_floor_normal().angle() + (PI / 2)
@ -52,8 +68,18 @@ func _process(delta):
scale.y = lerp(scale.y, 1.0, delta * 7) scale.y = lerp(scale.y, 1.0, delta * 7)
scale.x = lerp(scale.x, 1.0, delta * 7) scale.x = lerp(scale.x, 1.0, delta * 7)
scale.y = clamp(scale.y, 0.1, INF) scale.y = clamp(scale.y, 0.25, INF)
scale.x = clamp(scale.x, 0.1, INF) scale.x = clamp(scale.x, 0.1, INF)
#modulate.h = abs(player.position.x / 400.)
offset.y = (8 * pow(scale.y, -1) - 8) offset.y = (8 * pow(scale.y, -1) - 8)
offset.x = 0 offset.x = 0
grapple.offset = offset
func _on_character_jumped():
if not player.direction:
rotation = 0
scale.y = 1.5
scale.x = 0.5

View file

@ -1,4 +0,0 @@
extends Camera2D
func _process(delta):
position = get_local_mouse_position() / 3

View file

@ -1,9 +1,11 @@
[gd_scene load_steps=9 format=3 uid="uid://cqcjan67wgkc1"] [gd_scene load_steps=11 format=3 uid="uid://cqcjan67wgkc1"]
[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="Script" path="res://Player/BasicCharacter/CameraController.gd" id="3_2bdku"] [ext_resource type="PackedScene" uid="uid://cjjrxtvufk35a" path="res://Player/Camera/camera.tscn" id="2_oahgu"]
[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="Texture2D" uid="uid://bi5ofgcvid5qk" path="res://Player/GrappleHook/GrappleCenter.png" id="6_ismrc"]
[sub_resource type="CircleShape2D" id="CircleShape2D_jbiem"] [sub_resource type="CircleShape2D" id="CircleShape2D_jbiem"]
radius = 8.0 radius = 8.0
@ -28,27 +30,52 @@ scale_max = 2.0
scale_curve = SubResource("CurveTexture_d404m") scale_curve = SubResource("CurveTexture_d404m")
[node name="Character" type="CharacterBody2D"] [node name="Character" type="CharacterBody2D"]
collision_mask = 7
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" type="Camera2D" parent="."] [node name="Camera" parent="." instance=ExtResource("2_oahgu")]
zoom = Vector2(3, 3) position_smoothing_speed = 20.0
position_smoothing_enabled = true
position_smoothing_speed = 35.0
script = ExtResource("3_2bdku")
[node name="BoxCollider" type="CollisionShape2D" parent="."] [node name="BoxCollider" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_jbiem") shape = SubResource("CircleShape2D_jbiem")
[node name="Sprite" type="Sprite2D" parent="."] [node name="Sprite" type="Sprite2D" parent="."]
self_modulate = Color(1, 0, 0, 1) self_modulate = Color(0.678431, 0.298039, 1, 1)
visibility_layer = 257
rotation = 0.0123838 rotation = 0.0123838
texture = ExtResource("1_3vfyw") texture = ExtResource("1_3vfyw")
script = ExtResource("3_6plye") script = ExtResource("3_6plye")
[node name="WallslidingParticles" type="GPUParticles2D" parent="Sprite"] [node name="WallslidingUp" type="GPUParticles2D" parent="Sprite"]
show_behind_parent = true show_behind_parent = true
top_level = true top_level = true
position = Vector2(-7.79423, 4.5) position = Vector2(-7.79423, 4.5)
rotation = 0.785398 emitting = false
process_material = SubResource("ParticleProcessMaterial_65t6y") process_material = SubResource("ParticleProcessMaterial_65t6y")
[node name="WallslidingNeutral" type="GPUParticles2D" parent="Sprite"]
show_behind_parent = true
top_level = true
position = Vector2(-7.79423, 4.5)
emitting = false
amount = 16
process_material = SubResource("ParticleProcessMaterial_65t6y")
[node name="WallslidingDown" type="GPUParticles2D" parent="Sprite"]
show_behind_parent = true
top_level = true
position = Vector2(-7.79423, 4.5)
emitting = false
amount = 24
process_material = SubResource("ParticleProcessMaterial_65t6y")
[node name="Grapple" type="Node2D" parent="Sprite"]
script = ExtResource("5_sv1u0")
[node name="GrappleCore" type="Sprite2D" parent="Sprite"]
modulate = Color(0.513726, 1, 0.482353, 1)
texture = ExtResource("6_ismrc")
[connection signal="Jumped" from="." to="Sprite" method="_on_character_jumped"]

View file

@ -2,71 +2,86 @@ extends CharacterBody2D
const SPEED = 400.0 const SPEED = 400.0
const ACCEL = 7.0 const ACCEL = 7.0
var direction = 0
var addedveloc = 0
const JUMP_VELOCITY = -450.0 const JUMP_VELOCITY = -450.0
const MAX_JUMPS = 2 const MAX_JUMPS = 2
var jumps = MAX_JUMPS var jumps = MAX_JUMPS
var wallKayote = 0
const FALL_SPEED = -JUMP_VELOCITY * 1.5 const FALL_SPEED = -JUMP_VELOCITY * 1.5
var falling = false var falling = false
var floorTime = 0
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity") var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var direction = 0 func isWallSliding():
return is_on_wall_only() and direction
var addedveloc = 0
var wallKayote = 0
func launch(veloc): func launch(veloc):
addedveloc = veloc addedveloc = veloc
velocity.x = veloc velocity.x = veloc
signal Jumped
func _physics_process(delta): func _physics_process(delta):
direction = round(Input.get_axis("left", "right")) direction = round(Input.get_axis("left", "right"))
wallKayote -= delta wallKayote -= delta
if not is_on_floor(): if not is_on_floor():
var lowGrav = velocity.y < 0 and Input.is_action_pressed("jump") 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) velocity.y += gravity * delta / gen.boolToNumb(lowGrav, 1)
floorTime = 0
else: else:
floorTime += delta
jumps = MAX_JUMPS jumps = MAX_JUMPS
falling = false falling = false
if is_on_wall_only() and direction: if isWallSliding():
wallKayote = 0.225 wallKayote = 0.2
falling = false
print(-get_wall_normal().x, direction) if Input.is_action_just_pressed("respawn") or position.y > 500:
position = Vector2.ZERO
velocity = Vector2.ZERO
if Input.is_action_just_pressed("jump"): if Input.is_action_just_pressed("jump"):
if wallKayote > 0: if wallKayote > 0 and not is_on_floor():
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY) wallKayote /= 2
launch(get_wall_normal().x * SPEED) if Input.is_action_pressed("down"):
launch(get_wall_normal().x * SPEED * 2.5)
velocity.y = JUMP_VELOCITY / 2
else:
launch(get_wall_normal().x * SPEED * 1.5)
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY)
elif jumps > 0: elif jumps > 0:
Jumped.emit()
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY) velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY)
jumps -= 1 jumps -= 1
falling = false falling = false
if Input.is_action_just_pressed("down") and not falling: if Input.is_action_just_pressed("down") and not falling and not isWallSliding():
falling = true falling = true
velocity.y = clamp(velocity.y + FALL_SPEED, FALL_SPEED, INF) velocity.y = clamp(velocity.y + FALL_SPEED, FALL_SPEED, INF)
if is_on_wall_only(): if isWallSliding():
velocity.y = lerpf(velocity.y, clamp(velocity.y, JUMP_VELOCITY, 100), delta * 10) var upDown = clamp(Input.get_axis("up", "down"), -0.5, 1)
var holdMulti = (upDown * 2) + 1
velocity.y = lerpf(velocity.y, clamp(velocity.y, JUMP_VELOCITY, 100 * holdMulti), delta * 10)
var finalSpeed = clamp(abs(velocity.x), SPEED, SPEED * 2) - abs(addedveloc) var finalSpeed = clamp(abs(velocity.x), SPEED, INF)
if floorTime > 0.05:
finalSpeed = clamp(lerp(finalSpeed, SPEED, delta * 10), SPEED, INF) finalSpeed = clamp(lerp(finalSpeed, SPEED, delta * 20), SPEED, INF)
#print(finalSpeed)
velocity.x = lerp(velocity.x, direction * finalSpeed, delta * ACCEL) velocity.x = lerp(velocity.x, direction * finalSpeed, delta * ACCEL)
#if abs(velocity.x) < abs(addedveloc): if abs(velocity.x) < abs(addedveloc):
#print("boiyoing") addedveloc = lerp(addedveloc, velocity.x, ACCEL * 2 * delta)
velocity.x += addedveloc * delta * 10 velocity.x += addedveloc * delta * 15
addedveloc = lerpf(addedveloc, 0, delta * 5) addedveloc = lerpf(addedveloc, 0, delta * 5)

View file

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

View file

@ -0,0 +1,9 @@
[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 = 35.0
script = ExtResource("1_5yyqm")

50
Player/GUI/GUI.tscn Normal file
View file

@ -0,0 +1,50 @@
[gd_scene load_steps=3 format=3 uid="uid://b6rvghqqnqqk1"]
[ext_resource type="Script" path="res://Player/GUI/GuiRoot.gd" id="1_hovww"]
[sub_resource type="LabelSettings" id="LabelSettings_nvd2b"]
font_size = 32
[node name="CanvasLayer" type="CanvasLayer"]
[node name="GuiRoot" type="Control" parent="."]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
size_flags_horizontal = 3
size_flags_vertical = 3
script = ExtResource("1_hovww")
[node name="Velocity" type="Label" parent="GuiRoot"]
layout_mode = 0
offset_right = 79.0
offset_bottom = 23.0
text = "Velocity: 0"
label_settings = SubResource("LabelSettings_nvd2b")
[node name="HorzVeloc" type="Label" parent="GuiRoot"]
layout_mode = 0
offset_top = 44.0
offset_right = 328.0
offset_bottom = 89.0
text = "Horizontal Velocity: 0"
label_settings = SubResource("LabelSettings_nvd2b")
[node name="VertVeloc" type="Label" parent="GuiRoot"]
layout_mode = 0
offset_top = 88.0
offset_right = 283.0
offset_bottom = 133.0
text = "Vertical Velocity: 0"
label_settings = SubResource("LabelSettings_nvd2b")
[node name="AddedVeloc" type="Label" parent="GuiRoot"]
layout_mode = 0
offset_top = 132.0
offset_right = 283.0
offset_bottom = 177.0
text = "Added Velocity: 0"
label_settings = SubResource("LabelSettings_nvd2b")

View file

@ -0,0 +1,5 @@
extends Control
#
#func _process(delta):
#position = -get_viewport_transform().get_origin()
#print(position)

13
Player/GUI/GuiRoot.gd Normal file
View file

@ -0,0 +1,13 @@
extends Control
@onready var player = $"../../"
@onready var velocNumb = $"Velocity"
@onready var horzVeloc = $"HorzVeloc"
@onready var vertVeloc = $"VertVeloc"
@onready var addedVeloc = $"AddedVeloc"
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)))
addedVeloc.text = "Added Velocity: " + str(round(abs(player.addedveloc)))

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

View file

@ -21,6 +21,11 @@ config/icon="res://icon.svg"
gen="*res://Core/Scripts/GeneralFunctions.gd" gen="*res://Core/Scripts/GeneralFunctions.gd"
[display]
window/size/viewport_width=1920
window/size/viewport_height=1080
[editor] [editor]
version_control/plugin_name="GitPlugin" version_control/plugin_name="GitPlugin"
@ -71,10 +76,16 @@ spinGrapple={
, 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":81,"key_label":0,"unicode":113,"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":81,"key_label":0,"unicode":113,"echo":false,"script":null)
] ]
} }
respawn={
"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":82,"key_label":0,"unicode":114,"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":4194308,"key_label":0,"unicode":0,"echo":false,"script":null)
]
}
[physics] [physics]
common/physics_ticks_per_second=144 common/physics_jitter_fix=0.0
2d/default_gravity=1300.0 2d/default_gravity=1300.0
[rendering] [rendering]