forked from team-sg/hero-mark-2
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
|
# velocity
|
||||||
var velocity: Vector2 = Vector2.ZERO
|
var velocity: Vector2 = Vector2.ZERO
|
||||||
|
# current falling speed
|
||||||
|
var current_fall_speed: float = 0.0
|
||||||
# snap vector
|
# snap vector
|
||||||
var snap: Vector2 = Vector2.ZERO
|
var snap: Vector2 = Vector2.ZERO
|
||||||
# ladder currently attached to
|
# ladder currently attached to
|
||||||
|
@ -79,6 +81,8 @@ func _ready() -> void:
|
||||||
$StateDebugLayer/StateChartDebug.target = state_chart
|
$StateDebugLayer/StateChartDebug.target = state_chart
|
||||||
|
|
||||||
func _physics_process(delta: float) -> void:
|
func _physics_process(delta: float) -> void:
|
||||||
|
# snap sprite
|
||||||
|
graphics.global_position = global_position.round()
|
||||||
# update transition guard properties
|
# update transition guard properties
|
||||||
# whether player can currently shoot an arrow
|
# whether player can currently shoot an arrow
|
||||||
var can_shoot = Game.arrows > 0 and get_tree().get_nodes_in_group("player_arrow").size() == 0
|
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:
|
else:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
func reset_fall_speed():
|
||||||
|
current_fall_speed = 0
|
||||||
|
|
||||||
# STATE ENTERS/EXITS #
|
# STATE ENTERS/EXITS #
|
||||||
func _on_Grounded_state_entered() -> void:
|
func _on_Grounded_state_entered() -> void:
|
||||||
|
@ -158,6 +164,10 @@ func _on_Grounded_state_entered() -> void:
|
||||||
grounded_shape.disabled = false
|
grounded_shape.disabled = false
|
||||||
airborne_shape.disabled = true
|
airborne_shape.disabled = true
|
||||||
snap.y = 2.5 # snap when in grounded state
|
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
|
velocity.y = 1.0
|
||||||
|
|
||||||
func _on_Still_state_entered() -> void:
|
func _on_Still_state_entered() -> void:
|
||||||
|
@ -259,6 +269,7 @@ func _on_Dead_state_entered() -> void:
|
||||||
# send signals
|
# send signals
|
||||||
emit_signal("died")
|
emit_signal("died")
|
||||||
state_chart.send_event("died")
|
state_chart.send_event("died")
|
||||||
|
Input.start_joy_vibration(0,1,1,0.2)
|
||||||
# spawn death particles
|
# spawn death particles
|
||||||
if not skip_blood:
|
if not skip_blood:
|
||||||
var particles = DeathSplatter.instance()
|
var particles = DeathSplatter.instance()
|
||||||
|
@ -412,6 +423,7 @@ func _process_jump(delta: float) -> void:
|
||||||
## called by states SG will fall during
|
## called by states SG will fall during
|
||||||
func _process_gravity(delta: float) -> void:
|
func _process_gravity(delta: float) -> void:
|
||||||
velocity.y = min(velocity.y + gravity * delta, max_fall_speed)
|
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
|
## called after all other physics things
|
||||||
func _process_movement(delta: float) -> void:
|
func _process_movement(delta: float) -> void:
|
||||||
|
|
|
@ -1541,8 +1541,8 @@ align = 1
|
||||||
[connection signal="state_physics_processing" from="StateChart/Root/Movement" to="." method="_process_movement"]
|
[connection signal="state_physics_processing" from="StateChart/Root/Movement" to="." method="_process_movement"]
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded" to="." method="_on_Grounded_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded" to="." method="_on_Grounded_state_entered"]
|
||||||
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded" to="." method="_process_grounded"]
|
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded" to="." method="_process_grounded"]
|
||||||
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_horizontal_movement_grounded"]
|
|
||||||
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_can_walk"]
|
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_can_walk"]
|
||||||
|
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/CanWalk" to="." method="_process_horizontal_movement_grounded"]
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Still" to="." method="_on_Still_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Still" to="." method="_on_Still_state_entered"]
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Walking" to="." method="_on_Walking_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Walking" to="." method="_on_Walking_state_entered"]
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Blinking" to="." method="_on_Blinking_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/CanWalk/Blinking" to="." method="_on_Blinking_state_entered"]
|
||||||
|
@ -1553,6 +1553,7 @@ align = 1
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/Shooting" to="." method="_on_Shooting_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/Shooting" to="." method="_on_Shooting_state_entered"]
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/Pushing" to="." method="_on_Pushing_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Grounded/Pushing" to="." method="_on_Pushing_state_entered"]
|
||||||
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/Pushing" to="." method="_process_pushing"]
|
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Grounded/Pushing" to="." method="_process_pushing"]
|
||||||
|
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="reset_fall_speed"]
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="_on_Airborne_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne" to="." method="_on_Airborne_state_entered"]
|
||||||
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne" to="." method="_process_gravity"]
|
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne" to="." method="_process_gravity"]
|
||||||
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_horizontal_movement"]
|
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Jump" to="." method="_process_horizontal_movement"]
|
||||||
|
@ -1565,6 +1566,7 @@ align = 1
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Falling/NormalFalling" to="." method="_on_NormalFalling_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Falling/NormalFalling" to="." method="_on_NormalFalling_state_entered"]
|
||||||
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Falling/NormalFalling" to="." method="_process_horizontal_movement"]
|
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/Falling/NormalFalling" to="." method="_process_horizontal_movement"]
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Falling/ScaredFalling" to="." method="_on_ScaredFalling_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/Falling/ScaredFalling" to="." method="_on_ScaredFalling_state_entered"]
|
||||||
|
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="reset_fall_speed"]
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="_on_DoubleJump_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="_on_DoubleJump_state_entered"]
|
||||||
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="_process_horizontal_movement"]
|
[connection signal="state_physics_processing" from="StateChart/Root/Movement/Airborne/DoubleJump" to="." method="_process_horizontal_movement"]
|
||||||
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/AirShooting" to="." method="_on_AirShooting_state_entered"]
|
[connection signal="state_entered" from="StateChart/Root/Movement/Airborne/AirShooting" to="." method="_on_AirShooting_state_entered"]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue