Added fall zones
This commit is contained in:
parent
d02d369c13
commit
c257f9c1ad
8 changed files with 64 additions and 7 deletions
|
@ -46,6 +46,10 @@ 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:
|
||||
|
@ -140,3 +144,25 @@ func landed():
|
|||
return
|
||||
target_move_speed += boost
|
||||
boost = 0
|
||||
|
||||
func oob_lower():
|
||||
# Called when the player falls in a hole
|
||||
|
||||
# Calculate respawn point
|
||||
var tilemap : TileMap = get_node("../Stage")
|
||||
var tile : Vector2 = pos.floor()
|
||||
tile.y *= -1
|
||||
while tilemap.get_cellv(tile) == 23 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
|
||||
# =======================
|
||||
|
||||
# reset speed
|
||||
# should other things be done here?
|
||||
h_speed = 0
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue