added rumble and pixel snap
This commit is contained in:
parent
12eadd86e8
commit
31a71a542d
2 changed files with 15 additions and 1 deletions
|
@ -33,6 +33,8 @@ export var underwater = false
|
|||
|
||||
# velocity
|
||||
var velocity: Vector2 = Vector2.ZERO
|
||||
# current falling speed
|
||||
var current_fall_speed: float = 0.0
|
||||
# snap vector
|
||||
var snap: Vector2 = Vector2.ZERO
|
||||
# ladder currently attached to
|
||||
|
@ -79,6 +81,8 @@ func _ready() -> void:
|
|||
$StateDebugLayer/StateChartDebug.target = state_chart
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
# snap sprite
|
||||
graphics.global_position = global_position.round()
|
||||
# update transition guard properties
|
||||
# whether player can currently shoot an arrow
|
||||
var can_shoot = Game.arrows > 0 and get_tree().get_nodes_in_group("player_arrow").size() == 0
|
||||
|
@ -148,6 +152,8 @@ func get_stick_input(axis):
|
|||
else:
|
||||
return 0
|
||||
|
||||
func reset_fall_speed():
|
||||
current_fall_speed = 0
|
||||
|
||||
# STATE ENTERS/EXITS #
|
||||
func _on_Grounded_state_entered() -> void:
|
||||
|
@ -158,6 +164,10 @@ func _on_Grounded_state_entered() -> void:
|
|||
grounded_shape.disabled = false
|
||||
airborne_shape.disabled = true
|
||||
snap.y = 2.5 # snap when in grounded state
|
||||
var intensity = inverse_lerp(0.0, max_fall_speed, current_fall_speed)
|
||||
intensity = min(intensity * 1.1,1.0)
|
||||
print(intensity)
|
||||
Input.start_joy_vibration(0, 1.0, intensity, 0.05)
|
||||
velocity.y = 1.0
|
||||
|
||||
func _on_Still_state_entered() -> void:
|
||||
|
@ -259,6 +269,7 @@ func _on_Dead_state_entered() -> void:
|
|||
# send signals
|
||||
emit_signal("died")
|
||||
state_chart.send_event("died")
|
||||
Input.start_joy_vibration(0,1,1,0.2)
|
||||
# spawn death particles
|
||||
if not skip_blood:
|
||||
var particles = DeathSplatter.instance()
|
||||
|
@ -412,6 +423,7 @@ func _process_jump(delta: float) -> void:
|
|||
## called by states SG will fall during
|
||||
func _process_gravity(delta: float) -> void:
|
||||
velocity.y = min(velocity.y + gravity * delta, max_fall_speed)
|
||||
current_fall_speed = max(velocity.y,current_fall_speed)
|
||||
|
||||
## called after all other physics things
|
||||
func _process_movement(delta: float) -> void:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue