forked from team-sg/hero-mark-2
make player physics manipulatable
This commit is contained in:
parent
2fd0a5c519
commit
ac3248a912
1 changed files with 10 additions and 7 deletions
|
@ -3,6 +3,13 @@ extends KinematicBody2D
|
|||
const ArrowProjectile = preload("res://objects/player/arrow_projectile.tscn")
|
||||
|
||||
##CLEAN UP CODE LATER
|
||||
##Movement
|
||||
export var walk_speed = 50
|
||||
export var gravity = 12
|
||||
export var max_fall_speed = INF
|
||||
export var jump_time = 15
|
||||
export var jump_force = 150
|
||||
export var doublejump_force = 122
|
||||
##Children
|
||||
onready var sprite = $Sprite
|
||||
onready var climb_ray = $ClimbRay
|
||||
|
@ -21,12 +28,8 @@ var axis = Vector2.ZERO #Current direction being held
|
|||
var trail_color = Color(0.25,0,1,0.4)
|
||||
#Physics
|
||||
var velocity = Vector2.ZERO
|
||||
var walk_speed = 50
|
||||
var gravity = 12
|
||||
var jump_pressure = 0
|
||||
var jump_force = 150
|
||||
var doublejump_force = 122
|
||||
var current_ladder = null #Used for checking climbing every frame instead of area entered
|
||||
var jump_pressure = 0
|
||||
var can_doublejump = true
|
||||
var can_move_in_air = false
|
||||
var transport_speed = 0.0
|
||||
|
@ -79,7 +82,7 @@ func _physics_process(delta):
|
|||
|
||||
#Gravity
|
||||
if current_state != State.CLIMB:
|
||||
velocity.y += gravity
|
||||
velocity.y = min(velocity.y + gravity, max_fall_speed)
|
||||
#Cut y velocity when hitting ceiling
|
||||
if is_on_ceiling():
|
||||
current_state = State.FALL
|
||||
|
@ -126,7 +129,7 @@ func _process_idle_walk():
|
|||
func _process_jump():
|
||||
jump_pressure += 1
|
||||
#Pressure sensitive jump
|
||||
if jump_pressure == 15 or Input.is_action_just_released("jump"):
|
||||
if jump_pressure >= jump_time or Input.is_action_just_released("jump"):
|
||||
velocity.y = -jump_force / 4
|
||||
#velocity.y = 0
|
||||
current_state = State.FALL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue