This commit is contained in:
bingus_violet 2024-03-13 16:15:55 -05:00
parent 279b5e5599
commit 4f70414ed9
46 changed files with 1485 additions and 170 deletions

View file

@ -29,10 +29,13 @@ var imageTimer = 0
var imaging = false
var lastImage = Vector2.ZERO
func _ready():
if player.has_signal("Jumped"):
player.Jumped.connect(_on_character_jumped)
func _process(delta):
var velocity = player.velocity
var grapple = $"Grapple/GrappleCore"
var floored = player.is_on_floor()
@ -41,7 +44,7 @@ func _process(delta):
elif velocity.length() < 800:
imaging = false
if (imaging or find_child("Grapple") and $"Grapple".grappling) and (global_position - lastImage).length() > 16:
if (imaging or (find_child("Grapple") and $"Grapple".grappling)) and (global_position - lastImage).length() > 16:
var parti = afterImage.instantiate()
add_child(parti)
parti.duration = velocity.length() / 2000
@ -62,6 +65,12 @@ func _process(delta):
disableSlidingVariants()
if not floored:
if player.is_on_ceiling() and landed < -100:
rotation = 0
scale.y = 1 + (landed / 800)
scale.x = 1 - (landed / 800)
spin(velocity, delta)
landed = velocity.y
@ -97,11 +106,14 @@ func _process(delta):
offset.y = (8 * pow(scale.y, -1) - 8)
offset.x = 0
grapple.offset = offset
if find_child("Grapple"):
$"Grapple/GrappleCore".offset = offset
func _on_character_jumped():
if not player.direction:
rotation = 0
scale.y = 1.5
scale.x = 0.5
else:
scale = Vector2.ONE
offset = Vector2.ZERO

View file

@ -1,85 +1,28 @@
[gd_scene load_steps=11 format=3 uid="uid://cqcjan67wgkc1"]
[gd_scene load_steps=4 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/Camera/CameraController.gd" id="2_yp33m"]
[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
[sub_resource type="Curve" id="Curve_ky2t4"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.738916, 0), -1.78462, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_1w0c6"]
curve = SubResource("Curve_ky2t4")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_65t6y"]
particle_flag_align_y = true
particle_flag_disable_z = true
particle_flag_damping_as_friction = true
direction = Vector3(0, -1, 0)
initial_velocity_min = 34.78
initial_velocity_max = 34.78
gravity = Vector3(0, 250, 0)
scale_min = 2.0
scale_max = 2.0
scale_curve = SubResource("CurveTexture_1w0c6")
[sub_resource type="CircleShape2D" id="CircleShape2D_mnfw7"]
radius = 4.0
[node name="Character" type="CharacterBody2D"]
collision_mask = 7
collision_layer = 3
floor_stop_on_slope = false
floor_snap_length = 3.0
platform_on_leave = 2
script = ExtResource("1_c5ycp")
savedInputsPath = "res://Player/Ghosts/GhostData/testGhostRecording.res"
[node name="Camera" type="Camera2D" parent="."]
zoom = Vector2(3, 3)
position_smoothing_enabled = true
position_smoothing_speed = 20.0
script = ExtResource("2_yp33m")
[node name="BoxCollider" type="CollisionShape2D" parent="."]
[node name="CircleCollider" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_jbiem")
[node name="Sprite" type="Sprite2D" parent="."]
self_modulate = Color(0.678431, 0.298039, 1, 1)
visibility_layer = 257
z_index = 1
rotation = 0.0123838
texture = ExtResource("1_3vfyw")
script = ExtResource("3_6plye")
[node name="SquishDetection" type="Area2D" parent="."]
[node name="WallslidingUp" type="GPUParticles2D" parent="Sprite"]
show_behind_parent = true
top_level = true
position = Vector2(-7.79423, 4.5)
emitting = false
process_material = SubResource("ParticleProcessMaterial_65t6y")
[node name="CircleCollider" type="CollisionShape2D" parent="SquishDetection"]
shape = SubResource("CircleShape2D_mnfw7")
[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"]
modulate = Color(0, 1, 0, 1)
script = ExtResource("5_sv1u0")
[node name="GrappleCore" type="Sprite2D" parent="Sprite/Grapple"]
texture = ExtResource("6_ismrc")
[connection signal="Jumped" from="." to="Sprite" method="_on_character_jumped"]
[connection signal="body_shape_entered" from="SquishDetection" to="." method="_on_squish_detection_body_shape_entered"]
[connection signal="body_shape_exited" from="SquishDetection" to="." method="_on_squish_detection_body_shape_exited"]

View file

@ -1,12 +1,12 @@
extends CharacterBody2D
const SPEED = 400.0
const SPEED = 500.0
const ACCEL = 7.0
var direction = 0
var addedveloc = 0
const JUMP_VELOCITY = -450.0
const MAX_JUMPS = 2
const MAX_JUMPS = 1
var jumps = MAX_JUMPS
var wallKayote = 0
@ -15,14 +15,61 @@ const FALL_SPEED = -JUMP_VELOCITY
var falling = false
var floorTime = 0
var kayote = 0
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var checkpointPos = Vector2.ZERO
@export var ghostMode = false
var ghostFrame = 0
var startPos = Vector2.ZERO
var can_move = true
@onready var camera = $Camera
@export var savedInputsPath : String
var savedInputsRef = load(savedInputsPath)
var savedInputs = []
var wallPower = 0
var squishers = -1
func actionPressed(inp):
if ghostMode:
if inp in savedInputs[ghostFrame]:
return true
return false
else:
return Input.is_action_pressed(inp)
func actionJustPressed(inp):
if ghostMode:
if inp in savedInputs[ghostFrame] and not inp in savedInputs[ghostFrame - 1]:
return true
return false
else:
return Input.is_action_just_pressed(inp)
func getAxis(inp1, inp2):
if ghostMode:
var dir = 0
if actionPressed("left"):
dir -= 1
if actionPressed("right"):
dir += 1
return clamp(dir, -1, 1)
else:
return Input.get_axis(inp1, inp2)
func isWallSliding():
return is_on_wall_only() and direction
func getGravMulti():
var axis = (gen.boolToNumb(Input.is_action_pressed("up"), 1))
var axis = (gen.boolToNumb(actionPressed("up"), 1))
if velocity.y < 0:
return axis
return 1
@ -32,66 +79,208 @@ func launch(veloc):
velocity.x = veloc
signal Jumped
signal Died
var deathParticles = preload("res://Particles/Player/deathParticles.tscn")
func die():
Died.emit()
var parti = deathParticles.instantiate()
parti.modulate = $Sprite.self_modulate
add_child(parti)
can_move = false
$Sprite.visible = false
var camTween = get_tree().create_tween()
camTween.set_trans(Tween.TRANS_SINE)
camTween.set_ease(Tween.EASE_IN_OUT)
#camTween.tween_property(camera, "global_position", global_position, 1)
camTween.tween_property(camera, "global_position", checkpointPos, (global_position.distance_to(checkpointPos) / 2500) + 0.5).set_delay(1)
await camTween.finished
parti = deathParticles.instantiate()
parti.modulate = $Sprite.self_modulate
add_child(parti)
$Sprite.visible = true
$"../Smoother".reset_node(self)
camera.position_smoothing_enabled = true
global_position = checkpointPos
camera.global_position = global_position
velocity = Vector2(0, -350)
can_move = true
func _ready():
startPos = global_position
if ghostMode:
var rc = load(savedInputsPath)
if rc:
var inputKeyRaw = rc["actions"]
var frameDataRaw = rc["data"]
var inputKey = []
var frameData = {}
for action in inputKeyRaw:
inputKey.append(action)
for frame in frameDataRaw:
frameData[frame] = {}
for x in frameDataRaw[frame]:
frameData[frame][x] = frameDataRaw[frame][x]
var frameCount = gen.getRecordingFrameCount(frameData)
var held = []
for frame in range(frameCount):
savedInputs.append([])
if frameData.has(frame):
for actID in frameData[frame]:
var pressed = frameData[frame][actID]
var inputName = inputKey[actID]
if pressed == 1:
held.append(inputName)
elif inputName in held:
held.remove_at(held.find(inputName))
savedInputs[frame] += held
@onready var trail = $"Sprite/Trail"
var ghosting = true
var ghostParti = preload("res://Particles/Ghosts/spawnParticles.tscn")
func spawnParti():
var parti = ghostParti.instantiate()
add_child(parti)
parti.top_level = true
parti.global_position = global_position
func _physics_process(delta):
direction = round(Input.get_axis("left", "right"))
wallKayote -= delta
if not is_on_floor():
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:
floorTime += delta
jumps = MAX_JUMPS
falling = false
if isWallSliding():
wallKayote = 0.2
falling = false
if Input.is_action_just_pressed("respawn") or position.y > 5000:
position = Vector2.ZERO
if ghostFrame + 1 >= savedInputs.size() and ghostMode:
ghostFrame = 0
trail.points = []
$Sprite.visible = false
ghosting = false
spawnParti()
global_position = startPos
velocity = Vector2.ZERO
await get_tree().create_timer(3).timeout
spawnParti()
ghosting = true
$Sprite.visible = true
if Input.is_action_just_pressed("jump"):
if wallKayote > 0 and not is_on_floor():
wallKayote /= 2
if Input.is_action_pressed("down"):
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)
elif jumps > 0:
Jumped.emit()
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY)
jumps -= 1
if (ghosting or !ghostMode) and can_move:
var space_state = get_world_2d().direct_space_state
if ghostFrame == 0:
spawnParti()
ghostFrame += 1
direction = round(getAxis("left", "right"))
wallKayote -= delta
if not is_on_floor():
if velocity.y < 2000:
velocity.y += gravity * delta / getGravMulti()
floorTime = 0
kayote -= delta
else:
kayote = 0.3
floorTime += delta
jumps = MAX_JUMPS
falling = false
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 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, 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):
addedveloc = lerp(addedveloc, velocity.x, ACCEL * 2 * delta)
velocity.x += addedveloc * delta * 15
if isWallSliding():
wallKayote = 0.3
falling = false
addedveloc = lerpf(addedveloc, 0, delta * 5)
if actionJustPressed("respawn") or position.y > 5000:
die()
if actionJustPressed("jump"):
if wallKayote > 0 and not is_on_floor():
wallKayote /= 2
var query = PhysicsRayQueryParameters2D.create(global_position + (get_wall_normal() * 32), global_position + (get_wall_normal() * -64))
query.exclude = [self]
var result = space_state.intersect_ray(query)
if result and "velocity" in result.collider:
velocity.y += result.collider.velocity.y
if actionPressed("down"):
launch(get_wall_normal().x * SPEED * 1.75)
velocity.y = clamp((velocity.y / 2) + JUMP_VELOCITY / 1.8, -INF, JUMP_VELOCITY / 1.8)
else:
launch(get_wall_normal().x * SPEED * 1.35)
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY)
if result and "velocity" in result.collider:
velocity.x += result.collider.velocity.x
elif jumps > 0:
Jumped.emit()
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY)
if kayote < 0:
jumps -= 1
else:
var query = PhysicsRayQueryParameters2D.create(global_position + (Vector2.UP * 32), global_position + (Vector2.DOWN * 64))
query.exclude = [self]
var result = space_state.intersect_ray(query)
if result and "velocity" in result.collider:
velocity += result.collider.velocity
falling = false
if actionPressed("down") and not is_on_floor() and kayote > 0:
launch(direction * SPEED * 1.75)
kayote = 0
if actionJustPressed("down") and not falling and not isWallSliding():
falling = true
velocity.y = clamp(velocity.y + FALL_SPEED, FALL_SPEED, INF)
if isWallSliding():
var upDown = clamp(getAxis("up", "down"), -0.5, 1)
var holdMulti = (upDown * 2) + 1
var query = PhysicsRayQueryParameters2D.create(global_position + (get_wall_normal() * 32), global_position + (get_wall_normal() * -64))
query.exclude = [self]
var result = space_state.intersect_ray(query)
print(result)
if result and "velocity" in result.collider and abs(result.collider.velocity.x) > 50:
velocity.y = lerpf(velocity.y, 0, delta * 30)
else:
velocity.y = lerpf(velocity.y, clamp(velocity.y, JUMP_VELOCITY, 100 * holdMulti), delta * 10)
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):
addedveloc = lerp(addedveloc, velocity.x, ACCEL * 2 * delta)
velocity.x += addedveloc * delta * 15
addedveloc = lerpf(addedveloc, 0, delta * 5)
move_and_slide()
move_and_slide()
func _process(delta):
if ghostMode:
if velocity.length() > 5:
trail.add_point(global_position)
elif trail.get_point_count() > 0:
trail.remove_point(0)
if trail.get_point_count() > 100:
trail.remove_point(0)
func _on_squish_detection_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
squishers += 1
if squishers >= 2:
die()
func _on_squish_detection_body_shape_exited(body_rid, body, body_shape_index, local_shape_index):
squishers -= 1
print("Unsquish :(")

View file

@ -0,0 +1,69 @@
[gd_scene load_steps=8 format=3 uid="uid://bl4g0ao3b8b6p"]
[ext_resource type="Texture2D" uid="uid://dvx8lliqdi3dv" path="res://Player/Skins/Square/Square.png" id="1_k2mt0"]
[ext_resource type="Script" path="res://Player/BasicCharacter/AnimationController.gd" id="2_laadp"]
[sub_resource type="Curve" id="Curve_ky2t4"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(0.738916, 0), -1.78462, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_1w0c6"]
curve = SubResource("Curve_ky2t4")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_65t6y"]
particle_flag_align_y = true
particle_flag_disable_z = true
particle_flag_damping_as_friction = true
direction = Vector3(0, -1, 0)
initial_velocity_min = 34.78
initial_velocity_max = 34.78
gravity = Vector3(0, 250, 0)
scale_min = 2.0
scale_max = 2.0
scale_curve = SubResource("CurveTexture_1w0c6")
[sub_resource type="Curve" id="Curve_rdcm5"]
_data = [Vector2(0, 0), -4.02276, 4.38034, 0, 0, Vector2(1, 1), -0.0750911, 0.0, 0, 0]
point_count = 2
[sub_resource type="Gradient" id="Gradient_rfqd0"]
interpolation_mode = 2
colors = PackedColorArray(1, 1, 1, 0, 0, 1, 1, 1)
[node name="Sprite" type="Sprite2D"]
visibility_layer = 257
z_index = 10
texture = ExtResource("1_k2mt0")
script = ExtResource("2_laadp")
[node name="WallslidingUp" type="GPUParticles2D" parent="."]
show_behind_parent = true
top_level = true
position = Vector2(-7.79423, 4.5)
emitting = false
process_material = SubResource("ParticleProcessMaterial_65t6y")
[node name="WallslidingNeutral" type="GPUParticles2D" parent="."]
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="."]
show_behind_parent = true
top_level = true
position = Vector2(-7.79423, 4.5)
emitting = false
amount = 24
process_material = SubResource("ParticleProcessMaterial_65t6y")
[node name="Trail" type="Line2D" parent="."]
top_level = true
texture_filter = 2
width = 5.0
width_curve = SubResource("Curve_rdcm5")
default_color = Color(0, 1, 1, 1)
gradient = SubResource("Gradient_rfqd0")
end_cap_mode = 2