AAAA
This commit is contained in:
parent
279b5e5599
commit
4f70414ed9
46 changed files with 1485 additions and 170 deletions
228
Player/Ghosts/CharacterGhost.tscn
Normal file
228
Player/Ghosts/CharacterGhost.tscn
Normal 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
|
BIN
Player/Ghosts/GhostData/Level1HighJumpTutorial.res
Normal file
BIN
Player/Ghosts/GhostData/Level1HighJumpTutorial.res
Normal file
Binary file not shown.
BIN
Player/Ghosts/GhostData/Level1JumpTutorial.res
Normal file
BIN
Player/Ghosts/GhostData/Level1JumpTutorial.res
Normal file
Binary file not shown.
BIN
Player/Ghosts/GhostData/Level1WallJumpTutorial.res
Normal file
BIN
Player/Ghosts/GhostData/Level1WallJumpTutorial.res
Normal file
Binary file not shown.
BIN
Player/Ghosts/GhostData/Level1WallJumpTutorial2.res
Normal file
BIN
Player/Ghosts/GhostData/Level1WallJumpTutorial2.res
Normal file
Binary file not shown.
BIN
Player/Ghosts/GhostData/MovementTutorial.res
Normal file
BIN
Player/Ghosts/GhostData/MovementTutorial.res
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue