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
+17 -5
View File
@@ -13,15 +13,19 @@ signal move
const GRAVITY: int = 700 const GRAVITY: int = 700
@export var speed: float = 1300 @export var speed: float = 1300
@export var maxSpeed: float = 300 @export var maxSpeed: float = 300
@export var friction: int = 1200 @export var maxAirSpeed: float = 350
@export var airFriction: int = 250 @export var friction: int = 3000
@export var jumpHight: float = -275 @export var airFriction: int = 1400
@export var jumpHight: float = -300
@export var maxJumpCount: int = 2 @export var maxJumpCount: int = 2
@export var dashSpeed: float = 600
@export var wallPushBack: float = 200
var canDash: bool = true var canDash: bool = true
var deathEffect: PackedScene = preload("uid://dm4oirxl6bpnn") var deathEffect: PackedScene = preload("uid://dm4oirxl6bpnn")
var camreaCenterPosition: Vector2 var camreaCenterPosition: Vector2
var swordHitBoxXPos: float var swordHitBoxXPos: float
var dashTime: float = 0.1
func _ready() -> void: func _ready() -> void:
#connects the signal from scene manager to on spawn #connects the signal from scene manager to on spawn
@@ -33,11 +37,11 @@ func _ready() -> void:
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
#calls move and slide so the state scripts don't have to cause that causes bugs #calls move and slide so the state scripts don't have to cause that causes bugs
move_and_slide() move_and_slide()
#print(velocity.x)
#emits move purly for jump state cause that is dependent on exact move and slide in the code #emits move purly for jump state cause that is dependent on exact move and slide in the code
move.emit() move.emit()
if is_on_floor(): get_dash()
canDash = true
#kills the player when they get too low #kills the player when they get too low
#if global_position.y > 200: #if global_position.y > 200:
@@ -69,3 +73,11 @@ func hurt(enemy: Node2D) -> void:
if PlayerManager.currenthealth == 0: if PlayerManager.currenthealth == 0:
player_death() 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
@@ -5,8 +5,10 @@ extends NodeState
const jumpGravity = player.GRAVITY const jumpGravity = player.GRAVITY
var dashSpeed: float = 500 @onready var dashSpeed: float = player.dashSpeed
var dashTime: float = .3 @onready var jumpHight: float = player.jumpHight
var dashTime: float = .2
var dashDone: bool = false var dashDone: bool = false
var canDash: bool = true var canDash: bool = true
@@ -9,12 +9,12 @@ extends NodeState
@export_category("Fall State") @export_category("Fall State")
@export var coyoteTime: float = .2 @export var coyoteTime: float = .4
var coyoteJump: bool var coyoteJump: bool
const GRAVITY = player.GRAVITY const GRAVITY = player.GRAVITY
@onready var speed = player.speed @onready var speed = player.speed
@onready var maxSpeed = player.maxSpeed @onready var maxSpeed = player.maxAirSpeed
@onready var friction = player.airFriction @onready var friction = player.airFriction
@@ -33,7 +33,7 @@ func on_phyisics_process(delta: float) -> void:
if direction: if direction:
player.velocity.x += direction * speed * delta 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: if direction != 0:
animatedSprite2D.flip_h = false if direction > 0 else true animatedSprite2D.flip_h = false if direction > 0 else true
@@ -12,10 +12,13 @@ const jumpGravity = player.GRAVITY
@onready var jumpHight = player.jumpHight @onready var jumpHight = player.jumpHight
@onready var maxJumpCount = player.maxJumpCount @onready var maxJumpCount = player.maxJumpCount
@onready var speed = player.speed @onready var speed = player.speed
@onready var maxSpeed = player.maxSpeed @onready var maxSpeed = player.maxAirSpeed
@onready var friction = player.friction @onready var friction = player.airFriction
@onready var wallPushBack = player.wallPushBack
var currentJumpCount: int = 0 var currentJumpCount: int = 0
var wallJumpCoyoteTime: float = 0.3
var canWallJump: bool = false
@warning_ignore("unused_parameter") @warning_ignore("unused_parameter")
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
@@ -28,6 +31,9 @@ func on_process(delta: float) -> void:
pass pass
func on_phyisics_process(delta: float) -> void: func on_phyisics_process(delta: float) -> void:
var direction: float = GameInputEvents.movement_input()
player.velocity.y += jumpGravity * delta player.velocity.y += jumpGravity * delta
if player.is_on_floor(): if player.is_on_floor():
currentJumpCount = 0 currentJumpCount = 0
@@ -35,7 +41,7 @@ func on_phyisics_process(delta: float) -> void:
fallState.coyoteJump = false fallState.coyoteJump = false
currentJumpCount += 1 currentJumpCount += 1
if fallState.coyoteJump and currentJumpCount <= maxJumpCount: if fallState.coyoteJump and currentJumpCount < maxJumpCount:
player.velocity.y = jumpHight player.velocity.y = jumpHight
fallState.coyoteJump = false fallState.coyoteJump = false
currentJumpCount += 1 currentJumpCount += 1
@@ -43,12 +49,13 @@ func on_phyisics_process(delta: float) -> void:
#multi jumps #multi jumps
multiJump() multiJump()
#movment shit under here #movment shit under here
var direction: float = GameInputEvents.movement_input()
if direction: if direction:
player.velocity.x += direction * speed * delta 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: if direction != 0:
animatedSprite2D.flip_h = false if direction > 0 else true animatedSprite2D.flip_h = false if direction > 0 else true
@@ -63,7 +70,7 @@ func on_phyisics_process(delta: float) -> void:
func enter() -> void: func enter() -> void:
ledgeGrabBox.disabled = false ledgeGrabBox.disabled = false
animatedSprite2D.play("Jump") animatedSprite2D.play("Jump")
if not fallState.coyoteJump: if not fallState.coyoteJump and not player.is_on_wall():
currentJumpCount += 1 currentJumpCount += 1
multiJump() multiJump()
@@ -91,6 +98,28 @@ func transition_states() -> void:
func multiJump(): 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 player.velocity.y = jumpHight
currentJumpCount += 1 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
@@ -6,6 +6,7 @@ extends NodeState
const GRAVITY = player.GRAVITY const GRAVITY = player.GRAVITY
@onready var speed = player.speed @onready var speed = player.speed
@onready var maxSpeed = player.maxSpeed @onready var maxSpeed = player.maxSpeed
@onready var friction = player.friction
@warning_ignore("unused_parameter") @warning_ignore("unused_parameter")
func on_process(delta: float) -> void: func on_process(delta: float) -> void:
@@ -16,8 +17,8 @@ func on_phyisics_process(delta: float) -> void:
if direction: if direction:
player.velocity.x += direction * speed * delta player.velocity.x += direction * speed * delta
player.velocity.x = clamp(player.velocity.x, -maxSpeed, maxSpeed) #player.velocity.x = clamp(player.velocity.x, -maxSpeed, maxSpeed)
#player.velocity.x = move_toward(player.velocity.x, maxSpeed, 100 * delta) player.velocity.x = move_toward(player.velocity.x, clamp(player.velocity.x, -maxSpeed, maxSpeed), friction * delta)
if direction != 0: if direction != 0:
animatedSprite2D.flip_h = false if direction > 0 else true animatedSprite2D.flip_h = false if direction > 0 else true
File diff suppressed because one or more lines are too long