working on spikes
This commit is contained in:
parent
aff18ec43c
commit
b0e4a8db60
13 changed files with 618 additions and 503 deletions
|
|
@ -23,7 +23,7 @@ z_index = 10
|
||||||
z_as_relative = false
|
z_as_relative = false
|
||||||
|
|
||||||
[node name="Player" parent="Entities" unique_id=500011307 instance=ExtResource("2_feb5d")]
|
[node name="Player" parent="Entities" unique_id=500011307 instance=ExtResource("2_feb5d")]
|
||||||
position = Vector2(32, 304)
|
position = Vector2(168, 392)
|
||||||
|
|
||||||
[node name="Static" type="CanvasLayer" parent="." unique_id=884024747]
|
[node name="Static" type="CanvasLayer" parent="." unique_id=884024747]
|
||||||
layer = 20
|
layer = 20
|
||||||
|
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
src/level/tiles.aseprite
(Stored with Git LFS)
BIN
src/level/tiles.aseprite
(Stored with Git LFS)
Binary file not shown.
BIN
src/level/tiles.png
(Stored with Git LFS)
BIN
src/level/tiles.png
(Stored with Git LFS)
Binary file not shown.
Binary file not shown.
1028
src/level/world.ldtk
1028
src/level/world.ldtk
File diff suppressed because it is too large
Load diff
6
src/level/world.post_import.gd
Normal file
6
src/level/world.post_import.gd
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
@tool
|
||||||
|
|
||||||
|
func post_import(level: LDTKLevel) -> LDTKLevel:
|
||||||
|
# Behaviour goes here
|
||||||
|
|
||||||
|
return level
|
||||||
1
src/level/world.post_import.gd.uid
Normal file
1
src/level/world.post_import.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://40yv73g8vqs6
|
||||||
|
|
@ -39,7 +39,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
public float WaterAccel { get; set; } = 600.0f;
|
public float WaterAccel { get; set; } = 600.0f;
|
||||||
|
|
||||||
[Export(PropertyHint.None, "suffix:px/s")]
|
[Export(PropertyHint.None, "suffix:px/s")]
|
||||||
public float JumpAscentSpeed { get; set; } = 120.0f;
|
public float JumpAscentSpeed { get; set; } = 100.0f;
|
||||||
|
|
||||||
[Export(PropertyHint.None, "suffix:px/s")]
|
[Export(PropertyHint.None, "suffix:px/s")]
|
||||||
public float SlashSpeedBoost { get; set; } = 90.0f;
|
public float SlashSpeedBoost { get; set; } = 90.0f;
|
||||||
|
|
@ -64,7 +64,9 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
|
|
||||||
private ulong MaxInputBufferTimeMicroseconds => (ulong)(MaxInputBufferTime * 1_000_000);
|
private ulong MaxInputBufferTimeMicroseconds => (ulong)(MaxInputBufferTime * 1_000_000);
|
||||||
public bool IsJumping => !JumpTimer.IsStopped();
|
public bool IsJumping => !JumpTimer.IsStopped();
|
||||||
public bool IsWallJumping => !WallJumpTimer.IsStopped();
|
public bool IsWallBouncing => !WallBounceTimer.IsStopped();
|
||||||
|
public bool IsWallClimbing => !WallClimbTimer.IsStopped();
|
||||||
|
public bool IsWallJumping => IsWallBouncing || IsWallClimbing;
|
||||||
public bool IsDoingAnyJump => IsJumping || IsWallJumping;
|
public bool IsDoingAnyJump => IsJumping || IsWallJumping;
|
||||||
|
|
||||||
/// The direction the player is currently holding.
|
/// The direction the player is currently holding.
|
||||||
|
|
@ -84,14 +86,18 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
public float BankedDashPoints { get; set; }
|
public float BankedDashPoints { get; set; }
|
||||||
public float StaminaPoints { get; set; }
|
public float StaminaPoints { get; set; }
|
||||||
|
|
||||||
|
public Vector2 LastWallJumpNormal { get; set; }
|
||||||
|
|
||||||
[Node] private AnimationTree AnimationTree { get; set; } = null!;
|
[Node] private AnimationTree AnimationTree { get; set; } = null!;
|
||||||
[Node] private Area2D SubmersedSensor { get; set; } = null!;
|
[Node] private Area2D SubmersedSensor { get; set; } = null!;
|
||||||
[Node] private Hitbox DashHitbox { get; set; } = null!;
|
[Node] private Hitbox DashHitbox { get; set; } = null!;
|
||||||
[Node] private Node2D HandAttachment { get; set; } = null!;
|
[Node] private Node2D HandAttachment { get; set; } = null!;
|
||||||
[Node] private Timer JumpTimer { get; set; } = null!;
|
[Node] private Timer JumpTimer { get; set; } = null!;
|
||||||
[Node] private Timer WallJumpTimer { get; set; } = null!;
|
[Node] private Timer WallBounceTimer { get; set; } = null!;
|
||||||
|
[Node] private Timer WallClimbTimer { get; set; } = null!;
|
||||||
[Node] private Timer JumpAllowedTimer { get; set; } = null!;
|
[Node] private Timer JumpAllowedTimer { get; set; } = null!;
|
||||||
[Node] private Timer WallJumpAllowedTimer { get; set; } = null!;
|
[Node] private Timer WallJumpAllowedTimer { get; set; } = null!;
|
||||||
|
[Node] private Timer WallClimbDirectionChangeTimer { get; set; } = null!;
|
||||||
[Node] private Timer WaterJumpAllowedTimer { get; set; } = null!;
|
[Node] private Timer WaterJumpAllowedTimer { get; set; } = null!;
|
||||||
[Node] private Timer DashTimer { get; set; } = null!;
|
[Node] private Timer DashTimer { get; set; } = null!;
|
||||||
[Node] private Timer DashDirectionChangeTimer { get; set; } = null!;
|
[Node] private Timer DashDirectionChangeTimer { get; set; } = null!;
|
||||||
|
|
@ -255,6 +261,20 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
}
|
}
|
||||||
else if (IsWallJumping)
|
else if (IsWallJumping)
|
||||||
{
|
{
|
||||||
|
if (!WallClimbDirectionChangeTimer.IsStopped())
|
||||||
|
{
|
||||||
|
if (IsWallClimbing
|
||||||
|
&& (_currentDirection.Y >= 0f
|
||||||
|
|| Mathf.Sign(_currentDirection.X) == Mathf.Sign(LastWallJumpNormal.X)))
|
||||||
|
{
|
||||||
|
GD.Print("climb to bounce change!");
|
||||||
|
// Turn the climb to a bounce and refund the stamina
|
||||||
|
WallClimbTimer.Stop();
|
||||||
|
StaminaPoints += 1f;
|
||||||
|
WallBounce();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
velocity = WallJumpDirection * JumpAscentSpeed;
|
velocity = WallJumpDirection * JumpAscentSpeed;
|
||||||
}
|
}
|
||||||
else if (!IsOnFloor() && !IsInWater && DashTimer.IsStopped())
|
else if (!IsOnFloor() && !IsInWater && DashTimer.IsStopped())
|
||||||
|
|
@ -270,7 +290,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
{
|
{
|
||||||
if (velocity.Y >= 0f)
|
if (velocity.Y >= 0f)
|
||||||
velocity.Y = Mathf.MoveToward(velocity.Y * Mathf.Pow(0.0001f, deltaF), 0f, 750f * deltaF);
|
velocity.Y = Mathf.MoveToward(velocity.Y * Mathf.Pow(0.0001f, deltaF), 0f, 750f * deltaF);
|
||||||
IsFacingRight = Mathf.Sign(GetWallNormal().X) > 0;
|
IsFacingRight = Mathf.Sign(LastWallJumpNormal.X) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -290,7 +310,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
if (collision.GetCollider() is not TileMapLayer tileMapLayer)
|
if (collision.GetCollider() is not TileMapLayer tileMapLayer)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var collisionPos = collision.GetPosition() + collision.GetTravel();
|
var collisionPos = collision.GetPosition();
|
||||||
var mapCoords = tileMapLayer.GlobalToMap(collisionPos);
|
var mapCoords = tileMapLayer.GlobalToMap(collisionPos);
|
||||||
|
|
||||||
if (tileMapLayer.GetCellTileData(mapCoords) is not { } tileData)
|
if (tileMapLayer.GetCellTileData(mapCoords) is not { } tileData)
|
||||||
|
|
@ -319,7 +339,12 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsOnCeiling()) JumpTimer.Stop();
|
if (IsOnCeiling()) JumpTimer.Stop();
|
||||||
if (IsOnWall() && !IsInWater) WallJumpAllowedTimer.Start();
|
if (IsOnWall() && !IsInWater)
|
||||||
|
{
|
||||||
|
LastWallJumpNormal = GetWallNormal();
|
||||||
|
WallJumpAllowedTimer.Start();
|
||||||
|
}
|
||||||
|
|
||||||
if (IsOnFloor() || IsInWater)
|
if (IsOnFloor() || IsInWater)
|
||||||
{
|
{
|
||||||
StaminaPoints = MaxStaminaPoints;
|
StaminaPoints = MaxStaminaPoints;
|
||||||
|
|
@ -352,7 +377,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
var wallNormal = GetWallNormal();
|
var wallNormal = LastWallJumpNormal;
|
||||||
return !IsOnFloor()
|
return !IsOnFloor()
|
||||||
&& IsOnWall()
|
&& IsOnWall()
|
||||||
// player holding into the wall
|
// player holding into the wall
|
||||||
|
|
@ -447,7 +472,7 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
when StaminaPoints >= 1f
|
when StaminaPoints >= 1f
|
||||||
&& !WallJumpAllowedTimer.IsStopped()
|
&& !WallJumpAllowedTimer.IsStopped()
|
||||||
&& (input.Direction.X == 0f ||
|
&& (input.Direction.X == 0f ||
|
||||||
Mathf.Sign(input.Direction.X) != Mathf.Sign(GetWallNormal().X)):
|
Mathf.Sign(input.Direction.X) != Mathf.Sign(LastWallJumpNormal.X)):
|
||||||
WallClimb();
|
WallClimb();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
@ -495,11 +520,11 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
|
|
||||||
private void WallBounce()
|
private void WallBounce()
|
||||||
{
|
{
|
||||||
WallJumpTimer.Start();
|
WallBounceTimer.Start();
|
||||||
WallJumpAllowedTimer.Stop();
|
WallJumpAllowedTimer.Stop();
|
||||||
JumpAllowedTimer.Stop();
|
JumpAllowedTimer.Stop();
|
||||||
|
|
||||||
var wallDirection = (float)Mathf.Sign(GetWallNormal().X);
|
var wallDirection = (float)Mathf.Sign(LastWallJumpNormal.X);
|
||||||
IsFacingRight = wallDirection > 0f;
|
IsFacingRight = wallDirection > 0f;
|
||||||
const float upwardComponent = -0.6f;
|
const float upwardComponent = -0.6f;
|
||||||
var direction = new Vector2(wallDirection, upwardComponent).Normalized();
|
var direction = new Vector2(wallDirection, upwardComponent).Normalized();
|
||||||
|
|
@ -508,7 +533,8 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
|
|
||||||
private void WallClimb()
|
private void WallClimb()
|
||||||
{
|
{
|
||||||
WallJumpTimer.Start();
|
WallClimbTimer.Start();
|
||||||
|
WallClimbDirectionChangeTimer.Start();
|
||||||
WallJumpAllowedTimer.Stop();
|
WallJumpAllowedTimer.Stop();
|
||||||
JumpAllowedTimer.Stop();
|
JumpAllowedTimer.Stop();
|
||||||
StaminaPoints -= 1.0f;
|
StaminaPoints -= 1.0f;
|
||||||
|
|
@ -518,17 +544,18 @@ public sealed partial class Player : CharacterBody2D, IAttackable, IHitboxOwner,
|
||||||
|
|
||||||
private void JumpCut()
|
private void JumpCut()
|
||||||
{
|
{
|
||||||
if (!JumpTimer.IsStopped())
|
if (IsJumping || IsWallClimbing)
|
||||||
{
|
{
|
||||||
JumpTimer.Stop();
|
JumpTimer.Stop();
|
||||||
|
WallClimbTimer.Stop();
|
||||||
// Jump cut only once if we're still moving up
|
// Jump cut only once if we're still moving up
|
||||||
if (Velocity.Y < 0)
|
if (Velocity.Y < 0)
|
||||||
Velocity *= new Vector2(1f, 0.1f);
|
Velocity *= new Vector2(1f, 0.1f);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!WallJumpTimer.IsStopped())
|
if (IsWallBouncing)
|
||||||
{
|
{
|
||||||
WallJumpTimer.Stop();
|
WallBounceTimer.Stop();
|
||||||
if (Velocity.Y < 0)
|
if (Velocity.Y < 0)
|
||||||
Velocity *= new Vector2(1f, 0.1f);
|
Velocity *= new Vector2(1f, 0.1f);
|
||||||
Velocity = Velocity.LimitLength(AirMaxSpeed);
|
Velocity = Velocity.LimitLength(AirMaxSpeed);
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ shader_parameter/color_ramp = SubResource("GradientTexture1D_5f2sf")
|
||||||
size = Vector2(6, 14)
|
size = Vector2(6, 14)
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_o822w"]
|
[sub_resource type="RectangleShape2D" id="RectangleShape2D_o822w"]
|
||||||
size = Vector2(8, 12)
|
size = Vector2(4, 2)
|
||||||
|
|
||||||
[sub_resource type="Animation" id="Animation_yw30f"]
|
[sub_resource type="Animation" id="Animation_yw30f"]
|
||||||
resource_name = "RESET"
|
resource_name = "RESET"
|
||||||
|
|
@ -731,7 +731,7 @@ texture = SubResource("GradientTexture2D_2j2mp")
|
||||||
texture_scale = 3.37
|
texture_scale = 3.37
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="." unique_id=1975474809]
|
[node name="Camera2D" type="Camera2D" parent="." unique_id=1975474809]
|
||||||
position = Vector2(0, -16)
|
position = Vector2(0, -11)
|
||||||
process_callback = 0
|
process_callback = 0
|
||||||
limit_enabled = false
|
limit_enabled = false
|
||||||
editor_draw_screen = false
|
editor_draw_screen = false
|
||||||
|
|
@ -840,12 +840,11 @@ shape = SubResource("RectangleShape2D_crv7r")
|
||||||
|
|
||||||
[node name="SubmersedSensor" type="Area2D" parent="." unique_id=1595680866]
|
[node name="SubmersedSensor" type="Area2D" parent="." unique_id=1595680866]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
visible = false
|
|
||||||
collision_layer = 0
|
collision_layer = 0
|
||||||
collision_mask = 32
|
collision_mask = 32
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="SubmersedSensor" unique_id=1538343174]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="SubmersedSensor" unique_id=1538343174]
|
||||||
position = Vector2(0, -21)
|
position = Vector2(0, -8)
|
||||||
shape = SubResource("RectangleShape2D_o822w")
|
shape = SubResource("RectangleShape2D_o822w")
|
||||||
debug_color = Color(0, 0.5282814, 0.99723786, 0.41960785)
|
debug_color = Color(0, 0.5282814, 0.99723786, 0.41960785)
|
||||||
|
|
||||||
|
|
@ -877,7 +876,13 @@ process_callback = 0
|
||||||
wait_time = 0.25
|
wait_time = 0.25
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
[node name="WallJumpTimer" type="Timer" parent="." unique_id=299887998]
|
[node name="WallBounceTimer" type="Timer" parent="." unique_id=299887998]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
process_callback = 0
|
||||||
|
wait_time = 0.25
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="WallClimbTimer" type="Timer" parent="." unique_id=172417895]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
process_callback = 0
|
process_callback = 0
|
||||||
wait_time = 0.25
|
wait_time = 0.25
|
||||||
|
|
@ -895,6 +900,12 @@ process_callback = 0
|
||||||
wait_time = 0.073
|
wait_time = 0.073
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="WallClimbDirectionChangeTimer" type="Timer" parent="." unique_id=801101361]
|
||||||
|
unique_name_in_owner = true
|
||||||
|
process_callback = 0
|
||||||
|
wait_time = 0.132
|
||||||
|
one_shot = true
|
||||||
|
|
||||||
[node name="WaterJumpAllowedTimer" type="Timer" parent="." unique_id=1597932610]
|
[node name="WaterJumpAllowedTimer" type="Timer" parent="." unique_id=1597932610]
|
||||||
unique_name_in_owner = true
|
unique_name_in_owner = true
|
||||||
process_callback = 0
|
process_callback = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue