Added wall jumps and tweaked values and movement

This commit is contained in:
2026-02-16 23:47:10 -05:00
parent 5518f3ce79
commit c3d09c9a88
6 changed files with 64 additions and 20 deletions

View File

@@ -13,15 +13,19 @@ signal move
const GRAVITY: int = 700
@export var speed: float = 1300
@export var maxSpeed: float = 300
@export var friction: int = 1200
@export var airFriction: int = 250
@export var jumpHight: float = -275
@export var maxAirSpeed: float = 350
@export var friction: int = 3000
@export var airFriction: int = 1400
@export var jumpHight: float = -300
@export var maxJumpCount: int = 2
@export var dashSpeed: float = 600
@export var wallPushBack: float = 200
var canDash: bool = true
var deathEffect: PackedScene = preload("uid://dm4oirxl6bpnn")
var camreaCenterPosition: Vector2
var swordHitBoxXPos: float
var dashTime: float = 0.1
func _ready() -> void:
#connects the signal from scene manager to on spawn
@@ -33,11 +37,11 @@ func _ready() -> void:
func _physics_process(delta: float) -> void:
#calls move and slide so the state scripts don't have to cause that causes bugs
move_and_slide()
#print(velocity.x)
#emits move purly for jump state cause that is dependent on exact move and slide in the code
move.emit()
if is_on_floor():
canDash = true
get_dash()
#kills the player when they get too low
#if global_position.y > 200:
@@ -69,3 +73,11 @@ func hurt(enemy: Node2D) -> void:
if PlayerManager.currenthealth == 0:
player_death()
func get_dash() -> void:
if is_on_floor():
await get_tree().create_timer(dashTime).timeout
if is_on_floor():
canDash = true
if is_on_wall():
canDash = true

View File

@@ -5,8 +5,10 @@ extends NodeState
const jumpGravity = player.GRAVITY
var dashSpeed: float = 500
var dashTime: float = .3
@onready var dashSpeed: float = player.dashSpeed
@onready var jumpHight: float = player.jumpHight
var dashTime: float = .2
var dashDone: bool = false
var canDash: bool = true

View File

@@ -9,12 +9,12 @@ extends NodeState
@export_category("Fall State")
@export var coyoteTime: float = .2
@export var coyoteTime: float = .4
var coyoteJump: bool
const GRAVITY = player.GRAVITY
@onready var speed = player.speed
@onready var maxSpeed = player.maxSpeed
@onready var maxSpeed = player.maxAirSpeed
@onready var friction = player.airFriction
@@ -33,7 +33,7 @@ func on_phyisics_process(delta: float) -> void:
if direction:
player.velocity.x += direction * speed * delta
player.velocity.x = clamp(player.velocity.x, -maxSpeed, maxSpeed)
player.velocity.x = move_toward(player.velocity.x, clamp(player.velocity.x, -maxSpeed, maxSpeed), friction * delta)
if direction != 0:
animatedSprite2D.flip_h = false if direction > 0 else true

View File

@@ -12,10 +12,13 @@ const jumpGravity = player.GRAVITY
@onready var jumpHight = player.jumpHight
@onready var maxJumpCount = player.maxJumpCount
@onready var speed = player.speed
@onready var maxSpeed = player.maxSpeed
@onready var friction = player.friction
@onready var maxSpeed = player.maxAirSpeed
@onready var friction = player.airFriction
@onready var wallPushBack = player.wallPushBack
var currentJumpCount: int = 0
var wallJumpCoyoteTime: float = 0.3
var canWallJump: bool = false
@warning_ignore("unused_parameter")
func _physics_process(delta: float) -> void:
@@ -28,6 +31,9 @@ func on_process(delta: float) -> void:
pass
func on_phyisics_process(delta: float) -> void:
var direction: float = GameInputEvents.movement_input()
player.velocity.y += jumpGravity * delta
if player.is_on_floor():
currentJumpCount = 0
@@ -35,7 +41,7 @@ func on_phyisics_process(delta: float) -> void:
fallState.coyoteJump = false
currentJumpCount += 1
if fallState.coyoteJump and currentJumpCount <= maxJumpCount:
if fallState.coyoteJump and currentJumpCount < maxJumpCount:
player.velocity.y = jumpHight
fallState.coyoteJump = false
currentJumpCount += 1
@@ -43,12 +49,13 @@ func on_phyisics_process(delta: float) -> void:
#multi jumps
multiJump()
#movment shit under here
var direction: float = GameInputEvents.movement_input()
if direction:
player.velocity.x += direction * speed * delta
player.velocity.x = clamp(player.velocity.x, -maxSpeed, maxSpeed)
player.velocity.x = move_toward(player.velocity.x, clamp(player.velocity.x, -maxSpeed, maxSpeed), friction * delta)
if direction != 0:
animatedSprite2D.flip_h = false if direction > 0 else true
@@ -63,7 +70,7 @@ func on_phyisics_process(delta: float) -> void:
func enter() -> void:
ledgeGrabBox.disabled = false
animatedSprite2D.play("Jump")
if not fallState.coyoteJump:
if not fallState.coyoteJump and not player.is_on_wall():
currentJumpCount += 1
multiJump()
@@ -91,6 +98,28 @@ func transition_states() -> void:
func multiJump():
if !player.is_on_floor() and currentJumpCount <= maxJumpCount and Input.is_action_just_pressed("move_jump"):
if !player.is_on_floor() and currentJumpCount < maxJumpCount and Input.is_action_just_pressed("move_jump") and not player.is_on_wall() and not fallState.coyoteJump:
player.velocity.y = jumpHight
currentJumpCount += 1
if player.is_on_wall():
canWallJump = true
wallJumpCoyote()
if Input.is_action_just_pressed("move_jump") and canWallJump:
var boost = 150
print("wall jump")
player.velocity.y = jumpHight
var wallDirection = player.get_wall_normal().x
var direction: float = GameInputEvents.movement_input()
if direction == wallDirection:
print("boost")
player.velocity.x =+ (wallPushBack + boost) * wallDirection
else:
print("no boost")
player.velocity.x =+ wallPushBack * wallDirection
currentJumpCount = 0
func wallJumpCoyote():
await get_tree().create_timer(wallJumpCoyoteTime).timeout
canWallJump = false

View File

@@ -6,6 +6,7 @@ extends NodeState
const GRAVITY = player.GRAVITY
@onready var speed = player.speed
@onready var maxSpeed = player.maxSpeed
@onready var friction = player.friction
@warning_ignore("unused_parameter")
func on_process(delta: float) -> void:
@@ -16,8 +17,8 @@ func on_phyisics_process(delta: float) -> void:
if direction:
player.velocity.x += direction * speed * delta
player.velocity.x = clamp(player.velocity.x, -maxSpeed, maxSpeed)
#player.velocity.x = move_toward(player.velocity.x, maxSpeed, 100 * delta)
#player.velocity.x = clamp(player.velocity.x, -maxSpeed, maxSpeed)
player.velocity.x = move_toward(player.velocity.x, clamp(player.velocity.x, -maxSpeed, maxSpeed), friction * delta)
if direction != 0:
animatedSprite2D.flip_h = false if direction > 0 else true

File diff suppressed because one or more lines are too long