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

@ -2,3 +2,22 @@ extends Node
func boolToNumb(val, offset=0):
return float(val) + offset
func getCurrentActions():
var actionsList = InputMap.get_actions()
var validActions = {}
for action in actionsList:
if not "ui_" in action:
if Input.is_action_just_pressed(action):
validActions[action] = 1
elif Input.is_action_just_released(action):
validActions[action] = 2
return validActions
func getRecordingFrameCount(recording):
var frameSort = []
for frame in recording:
frameSort.append(frame)
frameSort.sort()
return frameSort[-1]

429
Maps/MapTest2.tscn Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,10 @@
extends Area2D
@export var animator : AnimationPlayer
@export var animation : String
@export var playOnce := true
var animReady = false
func _on_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
animator.play(animation)

View file

@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://dc8odchuhx80d"]
[ext_resource type="Script" path="res://Objects/AnimTrigger/AnimTrigger.gd" id="1_n4pxa"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_ilg2i"]
[node name="AnimTrigger" type="Area2D"]
collision_layer = 4
script = ExtResource("1_n4pxa")
[node name="Collider" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_ilg2i")
[connection signal="body_shape_entered" from="." to="." method="_on_body_shape_entered"]

View file

@ -1,4 +1,4 @@
extends Node
extends Node2D
# Called when the node enters the scene tree for the first time.

View file

@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://dep314vkturtp"]
[node name="Checkpoint" type="Node2D"]

View file

@ -0,0 +1,13 @@
extends Area2D
var killing = null
@export var detecting := false
func _on_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
if "die" in body and detecting:
killing = body
func _physics_process(delta):
if killing:
killing.die()
killing = null

View file

@ -0,0 +1,14 @@
[gd_scene load_steps=3 format=3 uid="uid://b5cr2rihwvwq2"]
[ext_resource type="Script" path="res://Objects/DeathCollider/DeathCollider.gd" id="1_get24"]
[sub_resource type="RectangleShape2D" id="RectangleShape2D_pangl"]
size = Vector2(16, 16)
[node name="DeathCollider" type="Area2D"]
script = ExtResource("1_get24")
[node name="Collider" type="CollisionShape2D" parent="."]
shape = SubResource("RectangleShape2D_pangl")
[connection signal="body_shape_entered" from="." to="." method="_on_body_shape_entered"]

View file

@ -0,0 +1,30 @@
extends Node2D
var detecting = true
func _on_anim_trigger_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
if detecting:
detecting = false
var tween = get_tree().create_tween()
tween.set_ease(Tween.EASE_IN)
tween.set_trans(Tween.TRANS_CUBIC)
tween.set_parallel(true)
tween.tween_property($SmasherBody, "position", Vector2(0, -66), 0.3)
tween.tween_property($SmasherBody2, "position", Vector2(0, 66), 0.3)
await tween.finished
tween = get_tree().create_tween()
tween.set_ease(Tween.EASE_IN)
tween.set_trans(Tween.TRANS_SINE)
tween.set_parallel(true)
tween.tween_property($SmasherBody, "position", Vector2(0, -100), 2).set_delay(1)
tween.tween_property($SmasherBody2, "position", Vector2(0, 100), 2).set_delay(1)
await tween.finished
detecting = true

View file

@ -0,0 +1,41 @@
[gd_scene load_steps=4 format=3 uid="uid://cufm4g76fik7t"]
[ext_resource type="PackedScene" uid="uid://dc8odchuhx80d" path="res://Objects/AnimTrigger/anim_trigger.tscn" id="1_cq28h"]
[ext_resource type="Script" path="res://Objects/GroundSmasher/DualSmasher.gd" id="1_px0wu"]
[ext_resource type="Texture2D" uid="uid://cnkms0met64fy" path="res://Objects/GroundSmasher/Smasher.png" id="2_6f7iw"]
[node name="Smasher" type="Node2D"]
script = ExtResource("1_px0wu")
[node name="AnimTrigger" parent="." instance=ExtResource("1_cq28h")]
scale = Vector2(1.6, 4)
collision_layer = 0
collision_mask = 2
script = null
[node name="SmasherBody" type="AnimatableBody2D" parent="."]
position = Vector2(0, -100)
[node name="Sprite2D" type="Sprite2D" parent="SmasherBody"]
position = Vector2(0, -37)
texture = ExtResource("2_6f7iw")
offset = Vector2(0, 40)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="SmasherBody"]
position = Vector2(0, -8)
polygon = PackedVector2Array(-16, -52, -16, 68, -13, 74, 0, 74, 13, 74, 16, 68, 16, -52)
[node name="SmasherBody2" type="AnimatableBody2D" parent="."]
position = Vector2(0, 100)
rotation = 3.14159
[node name="Sprite2D" type="Sprite2D" parent="SmasherBody2"]
position = Vector2(0, -37)
texture = ExtResource("2_6f7iw")
offset = Vector2(0, 40)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="SmasherBody2"]
position = Vector2(0, -8)
polygon = PackedVector2Array(-16, -52, -16, 68, -13, 74, 0, 74, 13, 74, 16, 68, 16, -52)
[connection signal="body_shape_entered" from="AnimTrigger" to="." method="_on_anim_trigger_body_shape_entered"]

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://cnkms0met64fy"
path="res://.godot/imported/Smasher.png-f4cece1b9694499f701efe8bcdb2c27c.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Objects/GroundSmasher/Smasher.png"
dest_files=["res://.godot/imported/Smasher.png-f4cece1b9694499f701efe8bcdb2c27c.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: 214 B

View file

@ -0,0 +1,46 @@
extends AnimatableBody2D
@onready var tip = $"Tip"
var detecting = true
var velocity = Vector2.ZERO
@onready var startPos = global_position
func _on_anim_trigger_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
if detecting:
detecting = false
var tween = get_tree().create_tween()
var space_state = get_world_2d().direct_space_state
var query = PhysicsRayQueryParameters2D.create(tip.global_position, tip.global_position + Vector2(0, 500).rotated(global_rotation))
var result = space_state.intersect_ray(query)
var finalPos = Vector2(0, 400).rotated(global_rotation)
if result:
finalPos = result.position - tip.global_position
tween.set_trans(Tween.TRANS_CUBIC)
tween.set_parallel(true)
tween.tween_property(self, "global_position", global_position + finalPos, 0.5).set_ease(Tween.EASE_IN)
tween.tween_property(self, "velocity", Vector2(0, 700).rotated(global_rotation), 0.5).set_ease(Tween.EASE_IN)
await tween.finished
tween = get_tree().create_tween()
tween.set_parallel(true)
tween.tween_property(self, "global_position", startPos, 2).set_trans(Tween.TRANS_SINE).set_delay(1).set_ease(Tween.EASE_IN)
tween.tween_property(self, "velocity", Vector2.ZERO, 0.5).set_trans(Tween.TRANS_SINE).set_delay(0.25).set_ease(Tween.EASE_IN)
#await get_tree().create_timer(0.25).timeout
#constant_linear_velocity = Vector2.ZERO
await tween.finished
detecting = true

View file

@ -0,0 +1,30 @@
[gd_scene load_steps=4 format=3 uid="uid://c7vbin1wckti1"]
[ext_resource type="PackedScene" uid="uid://dc8odchuhx80d" path="res://Objects/AnimTrigger/anim_trigger.tscn" id="1_qvh2l"]
[ext_resource type="Script" path="res://Objects/GroundSmasher/SmasherCollide.gd" id="2_0g66p"]
[ext_resource type="Texture2D" uid="uid://cnkms0met64fy" path="res://Objects/GroundSmasher/Smasher.png" id="2_s8d83"]
[node name="Smasher" type="Node2D"]
[node name="AnimTrigger" parent="." instance=ExtResource("1_qvh2l")]
scale = Vector2(1.6, 4)
collision_layer = 2
collision_mask = 2
script = null
[node name="SmasherBody" type="AnimatableBody2D" parent="."]
position = Vector2(0, -137)
script = ExtResource("2_0g66p")
[node name="Sprite2D" type="Sprite2D" parent="SmasherBody"]
texture = ExtResource("2_s8d83")
offset = Vector2(0, 40)
[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="SmasherBody"]
position = Vector2(0, 24)
polygon = PackedVector2Array(-16, -47, -16, 73, -13, 79, 13, 79, 16, 73, 16, -47)
[node name="Tip" type="Node2D" parent="SmasherBody"]
position = Vector2(0, 103)
[connection signal="body_shape_entered" from="AnimTrigger" to="SmasherBody" method="_on_anim_trigger_body_shape_entered"]

View file

@ -0,0 +1,19 @@
[gd_scene load_steps=3 format=3 uid="uid://xb5tl1a6bkkc"]
[ext_resource type="Script" path="res://Objects/SceneTeleporter/teleportergd.gd" id="1_l8pvx"]
[sub_resource type="CircleShape2D" id="CircleShape2D_wwqub"]
[node name="Teleporter" type="Node2D"]
position = Vector2(-361, 264)
script = ExtResource("1_l8pvx")
scenePath = "res://Maps/MapTest2.tscn"
[node name="CollisionDetector" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 2
[node name="CollisionShape" type="CollisionShape2D" parent="CollisionDetector"]
shape = SubResource("CircleShape2D_wwqub")
[connection signal="body_shape_entered" from="CollisionDetector" to="." method="_on_collision_detector_body_shape_entered"]

View file

@ -0,0 +1,9 @@
extends Node2D
@export var scenePath := "res://"
func _ready():
ResourceLoader.load_threaded_request(scenePath)
func _on_collision_detector_body_shape_entered(body_rid, body, body_shape_index, local_shape_index):
get_tree().change_scene_to_file(scenePath)

View file

@ -0,0 +1,47 @@
[gd_scene load_steps=7 format=3 uid="uid://cuk6upumkoafl"]
[ext_resource type="Script" path="res://Particles/Scripts/OneshotParticles.gd" id="1_001fc"]
[sub_resource type="Curve" id="Curve_nt6ns"]
min_value = -2.0
max_value = 2.0
_data = [Vector2(0, 0.0219781), 0.0, 4.98626, 0, 0, Vector2(1, 0.989011), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_82f2f"]
curve = SubResource("Curve_nt6ns")
[sub_resource type="Curve" id="Curve_d0nr1"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_p73qn"]
curve = SubResource("Curve_d0nr1")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_0xiht"]
particle_flag_align_y = true
particle_flag_disable_z = true
direction = Vector3(0, 0, 0)
spread = 180.0
initial_velocity_min = 150.0
initial_velocity_max = 150.0
orbit_velocity_min = -0.5
orbit_velocity_max = 0.5
orbit_velocity_curve = SubResource("CurveTexture_82f2f")
gravity = Vector3(0, 0, 0)
damping_min = 50.0
damping_max = 50.0
scale_min = 3.0
scale_max = 3.0
scale_curve = SubResource("CurveTexture_p73qn")
[node name="SpawnParticles" type="GPUParticles2D"]
modulate = Color(0, 1, 1, 1)
amount = 20
process_material = SubResource("ParticleProcessMaterial_0xiht")
lifetime = 2.0
speed_scale = 1.5
explosiveness = 1.0
fixed_fps = 0
interpolate = false
script = ExtResource("1_001fc")

View file

@ -0,0 +1,32 @@
[gd_scene load_steps=5 format=3 uid="uid://b4u5ekdtnki35"]
[ext_resource type="Script" path="res://Particles/Scripts/OneshotParticles.gd" id="1_0mqow"]
[sub_resource type="Curve" id="Curve_68wdg"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), -1.29471, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_sjct8"]
curve = SubResource("Curve_68wdg")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_gtww1"]
particle_flag_align_y = true
particle_flag_disable_z = true
direction = Vector3(0, 1, 0)
spread = 180.0
flatness = 0.1
initial_velocity_min = 100.0
initial_velocity_max = 500.0
damping_min = 100.0
damping_max = 100.0
scale_min = 2.0
scale_max = 5.0
scale_curve = SubResource("CurveTexture_sjct8")
scale_over_velocity_min = 1.0
scale_over_velocity_max = 5.0
[node name="DeathParticles" type="GPUParticles2D"]
amount = 50
process_material = SubResource("ParticleProcessMaterial_gtww1")
explosiveness = 1.0
script = ExtResource("1_0mqow")

View file

@ -10,4 +10,5 @@ func _ready():
queue_free()
func _process(delta):
global_position = get_parent().global_position
if following:
global_position = get_parent().global_position

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

View file

@ -8,7 +8,9 @@ func _process(delta):
var velocModifier = clamp(abs(player.velocity.x) - 700, 0, 1000)
var direction = clamp(player.velocity.x, -1, 1)
speedMod = lerpf(speedMod, velocModifier * direction / 10, delta * 20)
speedMod = lerpf(speedMod, velocModifier * direction / 5, delta * 10)
position = (get_local_mouse_position() / 3)
zoom = Vector2.ONE * 3 * get_viewport().size.length() / 3000
position = (get_local_mouse_position() / 2.5)
position.x += speedMod

View file

@ -0,0 +1,42 @@
extends Node2D
@onready var player = get_parent()
@onready var sprite = player.find_child("Sprite")
@export var tracking = false
var active = false
@export var finished = false
@export var saved = []
#func _ready():
#await get_tree().create_timer(30).timeout
#finished = true
func track():
saved.append(gen.getCurrentActions())
func _physics_process(delta):
if tracking:
track()
if finished:
print("TIME!!!!")
var dict = {"actions": [], "data": {}}
for frameNumb in len(saved):
var frame = saved[frameNumb]
for action in frame:
if not action in dict.actions:
dict.actions.append(action)
var actID = dict.actions.find(action)
if not frameNumb in dict.data:
dict.data[frameNumb] = {}
dict.data[frameNumb][actID] = frame[action]
dict.data[saved.size() - 1] = {}
var packed = PackedDataContainer.new()
packed.pack(dict)
ResourceSaver.save(packed, "ghostRecording.res")
queue_free()

View file

@ -1,7 +1,6 @@
extends Control
@onready var player = $"../../"
@onready var grapple = $"../../Sprite/Grapple"
@onready var velocNumb = $"Velocity"
@onready var horzVeloc = $"HorzVeloc"
@ -16,4 +15,7 @@ func _physics_process(delta):
vertVeloc.text = "Vertical Velocity: " + str(round(player.velocity.y))
addedVeloc.text = "Added Velocity: " + str(round(abs(player.addedveloc)))
jumps.text = "Jumps: " + str(player.jumps)
grapples.text = "Grapples: " + str(grapple.grapples)
if player.find_child("Grapple"):
grapples.text = "Grapples: " + str(player.find_child("Grapple").grapples)
func _process(delta):
size = get_viewport().size

View file

@ -0,0 +1,228 @@
[gd_scene load_steps=9 format=3 uid="uid://c4x2fbs6bvxpp"]
[ext_resource type="PackedScene" uid="uid://bl4g0ao3b8b6p" path="res://Player/BasicCharacter/sprite.tscn" id="2_mjdr3"]
[sub_resource type="GDScript" id="GDScript_nkjkv"]
script/source = "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
var falling = false
var floorTime = 0
var gravity = ProjectSettings.get_setting(\"physics/2d/default_gravity\")
func isWallSliding():
return is_on_wall_only() and direction
func getGravMulti():
var axis = (gen.boolToNumb(ghostInputHeld(\"up\"), 1))
if velocity.y < 0:
return axis
return 1
func launch(veloc):
addedveloc = veloc
velocity.x = veloc
signal Jumped
func die():
position = Vector2.ZERO
velocity = Vector2.ZERO
var ghostFrame = 0
var startPos = Vector2.ZERO
@export var savedInputsPath : String
var savedInputsRef = load(savedInputsPath)
var savedInputs = []
func ghostInputJustPressed(action):
if action in savedInputs[ghostFrame] and not action in savedInputs[ghostFrame - 1]:
return true
return false
func ghostInputHeld(action):
if action in savedInputs[ghostFrame]:
return true
return false
func _ready():
startPos = global_position
var rc = load(savedInputsPath)
for x in rc:
var dict = {}
for y in x:
dict[y] = x[y]
savedInputs.append(dict)
@onready var trail = $\"Sprite/Trail\"
var ghosting = true
func _physics_process(delta):
if ghostFrame + 1 >= savedInputs.size():
ghostFrame = 0
global_position = startPos
trail.points = []
$Sprite.visible = false
ghosting = false
$SpawnParticles.emitting = true
await get_tree().create_timer(3).timeout
ghosting = true
$Sprite.visible = true
if ghosting:
if ghostFrame == 0:
$SpawnParticles.emitting = true
ghostFrame += 1
direction = 0
if ghostInputHeld(\"left\"):
direction -= 1
if ghostInputHeld(\"right\"):
direction += 1
wallKayote -= delta
if not is_on_floor():
if velocity.y < 2000:
velocity.y += gravity * delta / getGravMulti()
floorTime = 0
else:
floorTime += delta
jumps = MAX_JUMPS
falling = false
if isWallSliding():
wallKayote = 0.2
falling = false
if ghostInputJustPressed(\"respawn\") or position.y > 5000:
die()
if ghostInputJustPressed(\"jump\"):
if wallKayote > 0 and not is_on_floor():
wallKayote /= 2
if ghostInputHeld(\"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
falling = false
if ghostInputJustPressed(\"down\") and not falling and not isWallSliding():
falling = true
velocity.y = clamp(velocity.y + FALL_SPEED, FALL_SPEED, INF)
if isWallSliding():
var upDown = 0
if ghostInputHeld(\"up\"):
upDown -= 0.5
if ghostInputHeld(\"down\"):
upDown += 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
addedveloc = lerpf(addedveloc, 0, delta * 5)
move_and_slide()
func _process(delta):
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)
"
[sub_resource type="CircleShape2D" id="CircleShape2D_jbiem"]
radius = 8.0
[sub_resource type="Curve" id="Curve_hemgx"]
min_value = -2.0
max_value = 2.0
_data = [Vector2(0, 0.0219781), 0.0, 4.98626, 0, 0, Vector2(1, 0.989011), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_12hes"]
curve = SubResource("Curve_hemgx")
[sub_resource type="Curve" id="Curve_8o02i"]
_data = [Vector2(0, 1), 0.0, 0.0, 0, 0, Vector2(1, 0), 0.0, 0.0, 0, 0]
point_count = 2
[sub_resource type="CurveTexture" id="CurveTexture_ibtln"]
curve = SubResource("Curve_8o02i")
[sub_resource type="ParticleProcessMaterial" id="ParticleProcessMaterial_6e1l2"]
particle_flag_align_y = true
particle_flag_disable_z = true
direction = Vector3(0, 0, 0)
spread = 180.0
initial_velocity_min = 150.0
initial_velocity_max = 150.0
orbit_velocity_min = -0.5
orbit_velocity_max = 0.5
orbit_velocity_curve = SubResource("CurveTexture_12hes")
gravity = Vector3(0, 0, 0)
damping_min = 50.0
damping_max = 50.0
scale_min = 3.0
scale_max = 3.0
scale_curve = SubResource("CurveTexture_ibtln")
[node name="Character" type="CharacterBody2D"]
collision_layer = 3
floor_stop_on_slope = false
floor_snap_length = 3.0
script = SubResource("GDScript_nkjkv")
[node name="BoxCollider" type="CollisionShape2D" parent="."]
shape = SubResource("CircleShape2D_jbiem")
[node name="Sprite" parent="." instance=ExtResource("2_mjdr3")]
modulate = Color(0, 1, 1, 1)
[node name="SpawnParticles" type="GPUParticles2D" parent="."]
modulate = Color(0, 1, 1, 1)
emitting = false
amount = 20
process_material = SubResource("ParticleProcessMaterial_6e1l2")
lifetime = 2.0
one_shot = true
speed_scale = 1.5
explosiveness = 1.0
fixed_fps = 0
interpolate = false

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -5,8 +5,6 @@ extends Node2D
@onready var grappleCore = $"GrappleCore"
@onready var Smoother = $"../../../Smoother"
var grappleProjectile = preload("res://Player/GrappleHook/GrappleHookProjectile/GrappleHookProjectile.tscn")
var proj = null
@ -46,17 +44,19 @@ func renderLine(proj):
func launch(delta):
if proj:
player.jumps = player.MAX_JUMPS - 1
var grappleVeloc = (proj.position - player.position).normalized() * grappleSpeed
var distance = proj.global_position - player.global_position
var grappleVeloc = distance.normalized() * (grappleSpeed + distance.length())
player.launch(grappleVeloc.x)
player.velocity.y = lerp(player.velocity.y, grappleVeloc.y, 10 * delta)
func grappleStart():
grappleSpeed = (500 + clamp(player.velocity.length(), 500, 1000))
grappleDur = 0.5
grappleSpeed = (500 + clamp(player.velocity.length(), 500, 2000))
grappleDur = 0.1
grappling = true
func _physics_process(delta):
grappleDur -= delta
if not Input.is_action_pressed("pullGrapple"):
grappleDur -= delta
var moveVector = (get_global_mouse_position() - player.position).normalized()
@ -73,10 +73,10 @@ func _physics_process(delta):
proj.position = player.position
proj.rotation = moveVector.angle()
modulate = Color8(0, 255, 0)
modulate = Color8(0, 255, 150)
proj.modulate = modulate
proj.velocity = (moveVector * 1000) + player.velocity
proj.velocity = (moveVector * 1500) + player.velocity
#grappleDur = 10
add_child(proj)

View file

@ -10,6 +10,9 @@ var detecting = true
var partiDebounce = true
var target = null
var bodyOffset = Vector2.ZERO
func objectHit(body):
if body != self:
velocity = Vector2.ZERO
@ -26,7 +29,7 @@ func _physics_process(delta):
if detecting:
if lifeTime <= 0:
velocity = Vector2.ZERO
velocity = -velocity
parent.retractingProj.append({"proj": self, "retractStart": position, "retractDur": 0})
parent.grappling = false
parent.proj = null
@ -39,7 +42,11 @@ func _physics_process(delta):
if result:
detecting = false
position = result.position
global_position = result.position
target = result.collider
bodyOffset = global_position - result.collider.global_position
objectHit(result.collider)
elif parent.grappling and target:
global_position = target.global_position + bodyOffset
lastPos = position
lastPos = global_position

View file

@ -36,7 +36,7 @@ platform_floor_layers = 4294967040
script = ExtResource("1_nba88")
[node name="Sprite" type="Sprite2D" parent="."]
z_index = 2
z_index = 4
texture = ExtResource("2_sst4t")
[node name="GrappleLine" type="Line2D" parent="."]

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View file

@ -0,0 +1,4 @@
extends PointLight2D
func _ready():
enabled = true

View file

@ -0,0 +1,5 @@
extends Sprite2D
func _process(_delta):
region_rect.size = Vector2.ONE * 2000
get_parent().get_parent().offset = get_viewport_rect().size / 2

BIN
ghostRecording.res Normal file

Binary file not shown.

View file

@ -11,9 +11,8 @@ config_version=5
[application]
config/name="Grapple Test"
run/main_scene="res://Maps/Testing Purgatory.tscn"
run/main_scene="res://Maps/MapTest2.tscn"
config/features=PackedStringArray("4.2", "Forward Plus")
run/max_fps=60
boot_splash/bg_color=Color(0, 0, 0, 1)
config/icon="res://icon.svg"
@ -21,6 +20,10 @@ config/icon="res://icon.svg"
gen="*res://Core/Scripts/GeneralFunctions.gd"
[debug]
settings/stdout/print_fps=true
[display]
window/size/viewport_width=1920
@ -86,6 +89,7 @@ respawn={
[physics]
common/physics_ticks_per_second=144
common/physics_jitter_fix=0.0
2d/default_gravity=1300.0