More stuffs
This commit is contained in:
parent
4cffceb1f4
commit
edc9eb5d73
8 changed files with 123 additions and 24 deletions
|
@ -2,14 +2,16 @@ extends Sprite2D
|
|||
|
||||
@onready var player = $"../"
|
||||
|
||||
@onready var wallSlidingParticles = $"WallslidingParticles"
|
||||
|
||||
func spin(veloc, delta):
|
||||
var vertSpinMult = abs(veloc.y) * clamp(veloc.x, -1, 1) / 1.5
|
||||
var spinFactor = (veloc.x + vertSpinMult) / 20
|
||||
var spinFactor = (veloc.x + vertSpinMult) / 30
|
||||
|
||||
if player.direction:
|
||||
rotation = lerp(rotation, rotation + (spinFactor), delta)
|
||||
else:
|
||||
rotation = lerp(rotation, snappedf(rotation + (spinFactor * delta * 2), PI / 2), delta * 10)
|
||||
rotation = lerp(rotation, snappedf(rotation, PI / 2), delta * 10)
|
||||
|
||||
var landed = 0
|
||||
|
||||
|
@ -18,22 +20,40 @@ func _process(delta):
|
|||
|
||||
var floored = player.is_on_floor()
|
||||
|
||||
print(scale)
|
||||
if player.is_on_wall_only() and velocity.y > 0:
|
||||
wallSlidingParticles.emitting = true
|
||||
wallSlidingParticles.global_position = player.position + (player.get_wall_normal() * -8)
|
||||
wallSlidingParticles.global_rotation = player.get_wall_normal().x * deg_to_rad(45)
|
||||
else:
|
||||
wallSlidingParticles.emitting = false
|
||||
|
||||
if not floored:
|
||||
spin(velocity, delta)
|
||||
landed = velocity.y
|
||||
|
||||
scale = Vector2.ONE
|
||||
|
||||
if player.is_on_wall():
|
||||
rotation = lerp(rotation, deg_to_rad(30) * player.get_wall_normal().x + snappedf(rotation, PI / 2), delta * 15)
|
||||
else:
|
||||
rotation = 0
|
||||
var floorRot = player.get_floor_normal().angle() + (PI / 2)
|
||||
|
||||
if abs(rotation - floorRot) > 0.9:
|
||||
rotation = floorRot
|
||||
|
||||
rotation = lerp(rotation, floorRot, delta * 10)
|
||||
|
||||
if landed:
|
||||
rotation = 0
|
||||
scale.y = 1 - (landed / 800)
|
||||
scale.x = 1 + (landed / 800)
|
||||
landed = 0
|
||||
|
||||
scale.y = lerp(scale.y, 1.0, delta * 10)
|
||||
scale.x = lerp(scale.x, 1.0, delta * 10)
|
||||
|
||||
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.x = clamp(scale.x, 0.1, INF)
|
||||
|
||||
offset.y = (8 * pow(scale.y, -1) - 8)
|
||||
offset.x = 0
|
||||
|
|
|
@ -1,26 +1,54 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://cqcjan67wgkc1"]
|
||||
[gd_scene load_steps=9 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="Script" path="res://Player/BasicCharacter/AnimationController.gd" id="3_6plye"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_42acf"]
|
||||
size = Vector2(16, 16)
|
||||
[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_d404m"]
|
||||
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_d404m")
|
||||
|
||||
[node name="Character" type="CharacterBody2D"]
|
||||
floor_snap_length = 3.0
|
||||
script = ExtResource("1_c5ycp")
|
||||
|
||||
[node name="BoxCollider" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_42acf")
|
||||
|
||||
[node name="Camera" type="Camera2D" parent="."]
|
||||
zoom = Vector2(3, 3)
|
||||
position_smoothing_enabled = true
|
||||
position_smoothing_speed = 20.0
|
||||
position_smoothing_speed = 35.0
|
||||
script = ExtResource("3_2bdku")
|
||||
|
||||
[node name="BoxCollider" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_jbiem")
|
||||
|
||||
[node name="Sprite" type="Sprite2D" parent="."]
|
||||
self_modulate = Color(1, 0, 0, 1)
|
||||
rotation = 0.0123838
|
||||
texture = ExtResource("1_3vfyw")
|
||||
script = ExtResource("3_6plye")
|
||||
|
||||
[node name="WallslidingParticles" type="GPUParticles2D" parent="Sprite"]
|
||||
show_behind_parent = true
|
||||
top_level = true
|
||||
position = Vector2(-7.79423, 4.5)
|
||||
rotation = 0.785398
|
||||
process_material = SubResource("ParticleProcessMaterial_65t6y")
|
||||
|
|
|
@ -3,32 +3,71 @@ extends CharacterBody2D
|
|||
const SPEED = 400.0
|
||||
const ACCEL = 7.0
|
||||
|
||||
const JUMP_VELOCITY = -400.0
|
||||
const JUMP_VELOCITY = -450.0
|
||||
|
||||
const FALL_SPEED = -JUMP_VELOCITY * 2
|
||||
const MAX_JUMPS = 2
|
||||
var jumps = MAX_JUMPS
|
||||
|
||||
const FALL_SPEED = -JUMP_VELOCITY * 1.5
|
||||
var falling = false
|
||||
|
||||
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
|
||||
|
||||
var direction = Vector2.ZERO
|
||||
var direction = 0
|
||||
|
||||
var addedveloc = 0
|
||||
|
||||
var wallKayote = 0
|
||||
|
||||
func launch(veloc):
|
||||
addedveloc = veloc
|
||||
velocity.x = veloc
|
||||
|
||||
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")
|
||||
|
||||
velocity.y += gravity * delta / gen.boolToNumb(lowGrav, 1)
|
||||
else:
|
||||
jumps = MAX_JUMPS
|
||||
falling = false
|
||||
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
|
||||
if is_on_wall_only() and direction:
|
||||
wallKayote = 0.225
|
||||
|
||||
print(-get_wall_normal().x, direction)
|
||||
|
||||
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)
|
||||
elif jumps > 0:
|
||||
velocity.y = clamp(velocity.y + JUMP_VELOCITY, -INF, JUMP_VELOCITY)
|
||||
jumps -= 1
|
||||
falling = false
|
||||
|
||||
if Input.is_action_just_pressed("down") and not falling:
|
||||
falling = true
|
||||
velocity.y = clamp(velocity.y + FALL_SPEED, -INF, FALL_SPEED)
|
||||
|
||||
direction = round(Input.get_axis("left", "right"))
|
||||
velocity.y = clamp(velocity.y + FALL_SPEED, FALL_SPEED, INF)
|
||||
|
||||
velocity.x = lerp(velocity.x, direction * SPEED, delta * ACCEL)
|
||||
if is_on_wall_only():
|
||||
velocity.y = lerpf(velocity.y, clamp(velocity.y, JUMP_VELOCITY, 100), delta * 10)
|
||||
|
||||
var finalSpeed = clamp(abs(velocity.x), SPEED, SPEED * 2) - abs(addedveloc)
|
||||
|
||||
finalSpeed = clamp(lerp(finalSpeed, SPEED, delta * 10), SPEED, INF)
|
||||
#print(finalSpeed)
|
||||
|
||||
velocity.x = lerp(velocity.x, direction * finalSpeed, delta * ACCEL)
|
||||
|
||||
#if abs(velocity.x) < abs(addedveloc):
|
||||
#print("boiyoing")
|
||||
velocity.x += addedveloc * delta * 10
|
||||
|
||||
addedveloc = lerpf(addedveloc, 0, delta * 5)
|
||||
|
||||
move_and_slide()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue