hold x midair for tricks
This commit is contained in:
parent
d92122f1b6
commit
d02d369c13
File diff suppressed because one or more lines are too long
|
@ -7,6 +7,7 @@ enum ActionType {
|
||||||
JUMP,
|
JUMP,
|
||||||
MOVE,
|
MOVE,
|
||||||
RECOIL,
|
RECOIL,
|
||||||
|
SPIN,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum UnitCondition {
|
enum UnitCondition {
|
||||||
|
@ -20,6 +21,7 @@ enum UnitCurrentAction {
|
||||||
IDLE,
|
IDLE,
|
||||||
JUMPING,
|
JUMPING,
|
||||||
RECOILING,
|
RECOILING,
|
||||||
|
SPINNING,
|
||||||
}
|
}
|
||||||
|
|
||||||
enum UnitMovingStatus {
|
enum UnitMovingStatus {
|
||||||
|
@ -68,6 +70,7 @@ const UNIT_TYPE_ACTIONS = {
|
||||||
ActionType.JUMP,
|
ActionType.JUMP,
|
||||||
ActionType.MOVE,
|
ActionType.MOVE,
|
||||||
ActionType.RECOIL,
|
ActionType.RECOIL,
|
||||||
|
ActionType.SPIN,
|
||||||
],
|
],
|
||||||
UnitType.NPC: [
|
UnitType.NPC: [
|
||||||
ActionType.MOVE,
|
ActionType.MOVE,
|
||||||
|
@ -79,6 +82,7 @@ const UNIT_TYPE_CURRENT_ACTIONS = {
|
||||||
UnitCurrentAction.IDLE,
|
UnitCurrentAction.IDLE,
|
||||||
UnitCurrentAction.JUMPING,
|
UnitCurrentAction.JUMPING,
|
||||||
UnitCurrentAction.RECOILING,
|
UnitCurrentAction.RECOILING,
|
||||||
|
UnitCurrentAction.SPINNING,
|
||||||
],
|
],
|
||||||
UnitType.NPC: [
|
UnitType.NPC: [
|
||||||
UnitCurrentAction.IDLE,
|
UnitCurrentAction.IDLE,
|
||||||
|
|
|
@ -162,3 +162,5 @@ func handle_player_input():
|
||||||
and player.unit_conditions[Constants.UnitCondition.IS_ON_GROUND]
|
and player.unit_conditions[Constants.UnitCondition.IS_ON_GROUND]
|
||||||
and input_table[Constants.PlayerInput.GBA_A][I_T_JUST_PRESSED])):
|
and input_table[Constants.PlayerInput.GBA_A][I_T_JUST_PRESSED])):
|
||||||
player.set_action(Constants.ActionType.JUMP)
|
player.set_action(Constants.ActionType.JUMP)
|
||||||
|
|
||||||
|
player.custom_inputs()
|
||||||
|
|
|
@ -260,8 +260,10 @@ func check_collision(unit : Unit, collider, collision_into_directions, delta):
|
||||||
unit.set_unit_condition(Constants.UnitCondition.IS_ON_GROUND, true)
|
unit.set_unit_condition(Constants.UnitCondition.IS_ON_GROUND, true)
|
||||||
# landed on ground, horizontal component to become magnitude
|
# landed on ground, horizontal component to become magnitude
|
||||||
unit.v_speed = 0
|
unit.v_speed = 0
|
||||||
|
unit.landed()
|
||||||
reangle_move(unit, collider, false)
|
reangle_move(unit, collider, false)
|
||||||
|
|
||||||
|
|
||||||
# slope acceleration for DownhillAutoscroller:
|
# slope acceleration for DownhillAutoscroller:
|
||||||
# set the player's last_contacted_map_elem_type field
|
# set the player's last_contacted_map_elem_type field
|
||||||
if unit is DownhillAutoscrollerPlayer:
|
if unit is DownhillAutoscrollerPlayer:
|
||||||
|
|
|
@ -280,3 +280,7 @@ func start_flash():
|
||||||
func invincibility_ended():
|
func invincibility_ended():
|
||||||
# implemented in subclass
|
# implemented in subclass
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func landed():
|
||||||
|
# implemented in subclass
|
||||||
|
pass
|
||||||
|
|
|
@ -5,9 +5,42 @@ class_name DownhillAutoscrollerPlayer
|
||||||
export var min_speed : float = 3
|
export var min_speed : float = 3
|
||||||
export var max_speed : float = 16
|
export var max_speed : float = 16
|
||||||
export var player_initiated_acceleration : float = 8
|
export var player_initiated_acceleration : float = 8
|
||||||
|
export var boost_per_second : float = 10
|
||||||
|
|
||||||
var last_contacted_map_elem_type : int = Constants.MapElemType.SQUARE
|
var last_contacted_map_elem_type : int = Constants.MapElemType.SQUARE
|
||||||
|
|
||||||
|
var boost : float = 0 # to movement speed
|
||||||
|
|
||||||
|
func execute_actions(delta):
|
||||||
|
.execute_actions(delta)
|
||||||
|
for action_num in Constants.UNIT_TYPE_ACTIONS[Constants.UnitType.PLAYER]:
|
||||||
|
if !actions[action_num]:
|
||||||
|
continue
|
||||||
|
match action_num:
|
||||||
|
# handle custom actions
|
||||||
|
Constants.ActionType.SPIN:
|
||||||
|
spin(delta)
|
||||||
|
_:
|
||||||
|
pass
|
||||||
|
|
||||||
|
func spin(delta):
|
||||||
|
set_current_action(Constants.UnitCurrentAction.SPINNING)
|
||||||
|
boost += boost_per_second * delta
|
||||||
|
|
||||||
|
func reset_current_action():
|
||||||
|
.reset_current_action()
|
||||||
|
if get_current_action() == Constants.UnitCurrentAction.SPINNING:
|
||||||
|
if not actions[Constants.ActionType.SPIN]:
|
||||||
|
set_current_action(Constants.UnitCurrentAction.IDLE)
|
||||||
|
|
||||||
|
func custom_inputs():
|
||||||
|
if scene.input_table[Constants.PlayerInput.GBA_B][scene.I_T_JUST_PRESSED]:
|
||||||
|
if not get_condition(Constants.UnitCondition.IS_ON_GROUND, true):
|
||||||
|
set_action(Constants.ActionType.SPIN)
|
||||||
|
if (get_current_action() == Constants.UnitCurrentAction.SPINNING
|
||||||
|
and scene.input_table[Constants.PlayerInput.GBA_B][scene.I_T_PRESSED]):
|
||||||
|
set_action(Constants.ActionType.SPIN)
|
||||||
|
|
||||||
func process_unit(delta, time_elapsed : float):
|
func process_unit(delta, time_elapsed : float):
|
||||||
# always be movin'
|
# always be movin'
|
||||||
facing = Constants.Direction.RIGHT
|
facing = Constants.Direction.RIGHT
|
||||||
|
@ -27,6 +60,8 @@ func process_unit(delta, time_elapsed : float):
|
||||||
if (target_move_speed < Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type]
|
if (target_move_speed < Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type]
|
||||||
and scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]):
|
and scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]):
|
||||||
target_move_speed = move_toward(target_move_speed, Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type], player_initiated_acceleration * delta)
|
target_move_speed = move_toward(target_move_speed, Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type], player_initiated_acceleration * delta)
|
||||||
|
if target_move_speed > max_speed:
|
||||||
|
target_move_speed = move_toward(target_move_speed, max_speed, player_initiated_acceleration * delta)
|
||||||
else:
|
else:
|
||||||
# shallow slope: arctan(.5) = 27 degrees, sin(27) = 0.45
|
# shallow slope: arctan(.5) = 27 degrees, sin(27) = 0.45
|
||||||
# steep slope: sin(45) = 0.71
|
# steep slope: sin(45) = 0.71
|
||||||
|
@ -50,9 +85,9 @@ func process_unit(delta, time_elapsed : float):
|
||||||
if ground_influenced_acceleration == 0:
|
if ground_influenced_acceleration == 0:
|
||||||
# flat ground
|
# flat ground
|
||||||
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]:
|
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]:
|
||||||
end_speed = max(target_move_speed, Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type])
|
end_speed = max(min(target_move_speed, max_speed), Constants.UNIT_TYPE_MOVE_SPEEDS[unit_type])
|
||||||
else:
|
else:
|
||||||
end_speed = target_move_speed
|
end_speed = min(target_move_speed, max_speed)
|
||||||
else:
|
else:
|
||||||
# incline
|
# incline
|
||||||
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]:
|
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]:
|
||||||
|
@ -62,13 +97,18 @@ func process_unit(delta, time_elapsed : float):
|
||||||
if target_move_speed < end_speed:
|
if target_move_speed < end_speed:
|
||||||
target_move_speed = move_toward(target_move_speed, end_speed, player_initiated_acceleration * delta)
|
target_move_speed = move_toward(target_move_speed, end_speed, player_initiated_acceleration * delta)
|
||||||
else:
|
else:
|
||||||
target_move_speed = move_toward(target_move_speed, end_speed, ground_influenced_acceleration * delta)
|
if ground_influenced_acceleration > 0:
|
||||||
|
target_move_speed = move_toward(target_move_speed, end_speed, ground_influenced_acceleration * delta)
|
||||||
|
else:
|
||||||
|
target_move_speed = move_toward(target_move_speed, end_speed, player_initiated_acceleration * delta)
|
||||||
else:
|
else:
|
||||||
var acceleration = ground_influenced_acceleration
|
var acceleration = ground_influenced_acceleration
|
||||||
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]:
|
if scene.input_table[Constants.PlayerInput.RIGHT][scene.I_T_PRESSED]:
|
||||||
acceleration = max(acceleration, player_initiated_acceleration)
|
acceleration = max(acceleration, player_initiated_acceleration)
|
||||||
if target_move_speed < max_speed:
|
if target_move_speed < max_speed:
|
||||||
target_move_speed = move_toward(target_move_speed, max_speed, acceleration * delta)
|
target_move_speed = move_toward(target_move_speed, max_speed, acceleration * delta)
|
||||||
|
else:
|
||||||
|
target_move_speed = move_toward(target_move_speed, max_speed, player_initiated_acceleration * delta)
|
||||||
|
|
||||||
.process_unit(delta, time_elapsed)
|
.process_unit(delta, time_elapsed)
|
||||||
|
|
||||||
|
@ -92,3 +132,11 @@ func handle_recoil():
|
||||||
hit_queued = false
|
hit_queued = false
|
||||||
# skip recoil pushback logic, since target_move_speed is already
|
# skip recoil pushback logic, since target_move_speed is already
|
||||||
# set to min_speed
|
# set to min_speed
|
||||||
|
|
||||||
|
func landed():
|
||||||
|
if get_current_action() == Constants.UnitCurrentAction.SPINNING:
|
||||||
|
hit(Constants.Direction.RIGHT)
|
||||||
|
boost = 0
|
||||||
|
return
|
||||||
|
target_move_speed += boost
|
||||||
|
boost = 0
|
||||||
|
|
|
@ -90,3 +90,7 @@ func handle_recoil():
|
||||||
else:
|
else:
|
||||||
h_speed -= RECOIL_PUSHBACK
|
h_speed -= RECOIL_PUSHBACK
|
||||||
facing = hit_dir
|
facing = hit_dir
|
||||||
|
|
||||||
|
func custom_inputs():
|
||||||
|
# implemented in subclass
|
||||||
|
pass
|
||||||
|
|
Loading…
Reference in New Issue