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()