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

View file

@ -2,38 +2,54 @@ extends Sprite2D
@onready var player = $"../"
@onready var wallSlidingParticles = $"WallslidingParticles"
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
if player.direction:
if player.direction or abs(player.velocity.x) > 100:
rotation = lerp(rotation, rotation + (spinFactor), delta)
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
@onready var slidingVariants = [$"WallslidingNeutral", $"WallslidingUp", $"WallslidingDown"]
func disableSlidingVariants(keep=null):
for variant in slidingVariants:
if variant != keep:
variant.emitting = false
func _process(delta):
var velocity = player.velocity
var grapple = $"GrappleCore"
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.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)
else:
wallSlidingParticles.emitting = false
disableSlidingVariants()
if not floored:
spin(velocity, delta)
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)
else:
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.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)
#modulate.h = abs(player.position.x / 400.)
offset.y = (8 * pow(scale.y, -1) - 8)
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="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/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"]
radius = 8.0
@ -28,27 +30,52 @@ scale_max = 2.0
scale_curve = SubResource("CurveTexture_d404m")
[node name="Character" type="CharacterBody2D"]
collision_mask = 7
floor_stop_on_slope = false
floor_snap_length = 3.0
script = ExtResource("1_c5ycp")
[node name="Camera" type="Camera2D" parent="."]
zoom = Vector2(3, 3)
position_smoothing_enabled = true
position_smoothing_speed = 35.0
script = ExtResource("3_2bdku")
[node name="Camera" parent="." instance=ExtResource("2_oahgu")]
position_smoothing_speed = 20.0
[node name="BoxCollider" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_jbiem")
[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
texture = ExtResource("1_3vfyw")
script = ExtResource("3_6plye")
[node name="WallslidingParticles" type="GPUParticles2D" parent="Sprite"]
[node name="WallslidingUp" type="GPUParticles2D" parent="Sprite"]
show_behind_parent = true
top_level = true
position = Vector2(-7.79423, 4.5)
rotation = 0.785398
emitting = false
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,72 +2,87 @@ extends CharacterBody2D
const SPEED = 400.0
const ACCEL = 7.0
var direction = 0
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
var falling = false
var floorTime = 0
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var direction = 0
var addedveloc = 0
var wallKayote = 0
func isWallSliding():
return is_on_wall_only() and direction
func launch(veloc):
addedveloc = veloc
velocity.x = 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("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)
floorTime = 0
else:
floorTime += delta
jumps = MAX_JUMPS
falling = false
if is_on_wall_only() and direction:
wallKayote = 0.225
if isWallSliding():
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 wallKayote > 0:
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY)
launch(get_wall_normal().x * SPEED)
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
else:
launch(get_wall_normal().x * SPEED * 1.5)
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY)
elif jumps > 0:
Jumped.emit()
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY)
jumps -= 1
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
velocity.y = clamp(velocity.y + FALL_SPEED, FALL_SPEED, INF)
if is_on_wall_only():
velocity.y = lerpf(velocity.y, clamp(velocity.y, JUMP_VELOCITY, 100), delta * 10)
if isWallSliding():
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)
finalSpeed = clamp(lerp(finalSpeed, SPEED, delta * 10), SPEED, INF)
#print(finalSpeed)
var finalSpeed = clamp(abs(velocity.x), SPEED, INF)
if floorTime > 0.05:
finalSpeed = clamp(lerp(finalSpeed, SPEED, delta * 20), SPEED, INF)
velocity.x = lerp(velocity.x, direction * finalSpeed, delta * ACCEL)
#if abs(velocity.x) < abs(addedveloc):
#print("boiyoing")
velocity.x += addedveloc * delta * 10
if abs(velocity.x) < abs(addedveloc):
addedveloc = lerp(addedveloc, velocity.x, ACCEL * 2 * delta)
velocity.x += addedveloc * delta * 15
addedveloc = lerpf(addedveloc, 0, delta * 5)
move_and_slide()

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