continued from previous commit

This commit is contained in:
D L 2023-01-28 16:19:29 -08:00
parent 4cfa04e490
commit 34927f93ea
5 changed files with 117 additions and 32 deletions

View file

@ -11,6 +11,8 @@ var last_contacted_map_elem_type : int = Constants.MapElemType.SQUARE
var boost : float = 0 # to movement speed
var respawn_pos : Vector2
func execute_actions(delta):
.execute_actions(delta)
for action_num in Constants.UNIT_TYPE_ACTIONS[Constants.UnitType.PLAYER]:
@ -46,10 +48,6 @@ func process_unit(delta, time_elapsed : float):
facing = Constants.Direction.RIGHT
actions[Constants.ActionType.MOVE] = true
# Check if fallen off
if last_contacted_map_elem_type == Constants.MapElemType.OOB_LOWER:
oob_lower()
# Fine tune the player's speed
if get_current_action() == Constants.UnitCurrentAction.RECOILING:
@ -145,24 +143,43 @@ func landed():
target_move_speed += boost
boost = 0
func oob_lower():
# Called when the player falls in a hole
func react(delta):
.react(delta)
# Calculate respawn point
var tilemap : TileMap = get_node("../Stage")
var tile : Vector2 = pos.floor()
tile.y *= -1
while tilemap.get_cellv(tile) == 22 or tilemap.get_cellv(tile) < 0:
tile += Vector2.RIGHT
while tilemap.get_cellv(tile) >= 0:
tile += Vector2.UP
pos = tile
pos.x += 0.5
pos.y *= -1
last_contacted_map_elem_type = Constants.MapElemType.SLOPE_LEFT
# =======================
# Check if fallen off
if last_contacted_map_elem_type == Constants.MapElemType.OOB_LOWER:
# Called when the player falls in a hole
# reset speed
# should other things be done here?
h_speed = 0
# Calculate respawn point
var tilemap : TileMap = get_node("../Stage")
var tile : Vector2 = pos.floor()
tile.y *= -1
while tilemap.get_cellv(tile) == 22 or tilemap.get_cellv(tile) < 0:
tile += Vector2.RIGHT
while tilemap.get_cellv(tile) >= 0:
tile += Vector2.UP
respawn_pos = tile
respawn_pos.x += 0.5
respawn_pos.y *= -1
last_contacted_map_elem_type = Constants.MapElemType.SLOPE_LEFT
# =======================
# reset speed
# should other things be done here?
# - player's ongoing trick has to be reset
# - camera has to freeze its y position as player drops offscreen
# - a smooth transition has to play
# - player starts off recoiling and slowed down (they are hit)
var spectator_cam : Camera2D = get_node("../SpectatorCam")
spectator_cam.position = get_node("Camera2D").get_camera_screen_center()
spectator_cam.offset = get_node("Camera2D").offset
spectator_cam.make_current()
var anim_player : AnimationPlayer = scene.find_node("PitTransitionPlayer")
anim_player.play("PitTransition")
func respawn_from_pit():
pos = respawn_pos
hit(Constants.Direction.RIGHT)
boost = 0
get_node("Camera2D").make_current()