continued from previous commit
This commit is contained in:
parent
4cfa04e490
commit
34927f93ea
5 changed files with 117 additions and 32 deletions
|
@ -208,7 +208,7 @@ const GRAVITY = 16.1 # gravity = 32.17 ft/s^2, grid unit is 2ft
|
|||
const MAX_FALL_SPEED = -37
|
||||
const ACCELERATION = 35
|
||||
const QUANTUM_DIST = 0.001
|
||||
const SPAWN_DISTANCE = 10
|
||||
const SPAWN_DISTANCE = 20
|
||||
|
||||
# specialized constants
|
||||
const FLASH_CYCLE = 0.15
|
||||
|
|
|
@ -253,6 +253,15 @@ func check_collision(unit : Unit, collider, collision_into_directions, delta):
|
|||
if intersects_results[0]:
|
||||
if is_ground_collision:
|
||||
if unit_env_collider[0] == Vector2(0, 0):
|
||||
|
||||
# slope acceleration for DownhillAutoscroller:
|
||||
# set the player's last_contacted_map_elem_type field
|
||||
if unit is DownhillAutoscrollerPlayer:
|
||||
unit.last_contacted_map_elem_type = collider_to_map_elem_type[collider]
|
||||
if collider_to_map_elem_type[collider] == Constants.MapElemType.OOB_LOWER:
|
||||
# this collision should have no effect
|
||||
return false
|
||||
|
||||
unit.pos.y = intersects_results[1].y + Constants.QUANTUM_DIST
|
||||
unit.pos.x = intersects_results[1].x
|
||||
if unit.unit_conditions[Constants.UnitCondition.IS_ON_GROUND]:
|
||||
|
@ -265,12 +274,6 @@ func check_collision(unit : Unit, collider, collision_into_directions, delta):
|
|||
unit.v_speed = 0
|
||||
unit.landed()
|
||||
reangle_move(unit, collider, false)
|
||||
|
||||
|
||||
# slope acceleration for DownhillAutoscroller:
|
||||
# set the player's last_contacted_map_elem_type field
|
||||
if unit is DownhillAutoscrollerPlayer:
|
||||
unit.last_contacted_map_elem_type = collider_to_map_elem_type[collider]
|
||||
else:
|
||||
if collider[0].x == collider[1].x:
|
||||
# vertical wall collision
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue