Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if label == "frame":
self.frame = unpack(' stages.edgegroundposition(self.stage) or \
self.player[i].y < -6) and not self.player[i].on_ground:
self.player[i].off_stage = True
else:
self.player[i].off_stage = False
# Keep track of a player's invulnerability due to respawn or ledge grab
self.player[i].invulnerability_left = max(0, self.player[i].invulnerability_left - 1)
if self.player[i].action == Action.ON_HALO_WAIT:
self.player[i].invulnerability_left = 120
# Don't give invulnerability to the first descent
if self.player[i].action == Action.ON_HALO_DESCENT and self.frame > 150:
self.player[i].invulnerability_left = 120
if self.player[i].action == Action.EDGE_CATCHING and self.player[i].action_frame == 1:
self.player[i].invulnerability_left = 36
# Which character are we right now?
# Slow down the speed by the character's friction, then apply it
if attacker_speed_x > 0:
attacker_speed_x = max(0, attacker_speed_x - friction)
else:
attacker_speed_x = min(0, attacker_speed_x + friction)
attacker_x += attacker_speed_x
# If attacker is in tha air...
else:
# First consider vertical movement. They will decelerate towards the stage
attacker_speed_y = max(-termvelocity, attacker_speed_y - gravity)
# NOTE Assume that the attacker will keep moving how they currently are
# If they do move halfway, then this will re-calculate later runs
attacker_y += attacker_speed_y
# Did we hit the ground this frame? If so, let's make some changes
if attacker_y <= 0 and abs(attacker_x) < stages.edgegroundposition(stage):
# TODO: Let's consider A moves that cancel when landing
attacker_y = 0
attacker_speed_y = 0
onground = True
attacker_x += attacker_speed_x
else:
attacker_x += locomotion_x
attacker_y += locomotion_y
if attackingframe['hitbox_1_status'] or attackingframe['hitbox_2_status'] or \
attackingframe['hitbox_3_status'] or attackingframe['hitbox_4_status']:
# Calculate the x and y positions of all 4 hitboxes for this frame
hitbox_1_x = float(attackingframe["hitbox_1_x"])
hitbox_1_y = float(attackingframe["hitbox_1_y"]) + attacker_y
hitbox_2_x = float(attackingframe["hitbox_2_x"])
# We can derive the direction we're supposed to be moving by xor'ing a few things together...
# 1) Current facing
# 2) Facing changed in the frame data
# 3) Is backwards roll
facingchanged = self.framedata[character_state.character][character_state.action][character_state.action_frame]["facing_changed"]
backroll = character_state.action in [Action.ROLL_BACKWARD, Action.GROUND_ROLL_BACKWARD_UP, \
Action.GROUND_ROLL_BACKWARD_DOWN, Action.BACKWARD_TECH]
if not (character_state.facing ^ facingchanged ^ backroll):
distance = -distance
position = character_state.x + distance
if character_state.action not in [Action.TECH_MISS_UP, Action.TECH_MISS_DOWN]:
# Adjust the position to account for the fact that we can't roll off the stage
position = min(position, stages.edgegroundposition(stage))
position = max(position, -stages.edgegroundposition(stage))
return position
# If we get a key error, just assume this animation doesn't go anywhere
except KeyError:
return character_state.x
# We can derive the direction we're supposed to be moving by xor'ing a few things together...
# 1) Current facing
# 2) Facing changed in the frame data
# 3) Is backwards roll
facingchanged = self.framedata[character_state.character][character_state.action][character_state.action_frame]["facing_changed"]
backroll = character_state.action in [Action.ROLL_BACKWARD, Action.GROUND_ROLL_BACKWARD_UP, \
Action.GROUND_ROLL_BACKWARD_DOWN, Action.BACKWARD_TECH]
if not (character_state.facing ^ facingchanged ^ backroll):
distance = -distance
position = character_state.x + distance
if character_state.action not in [Action.TECH_MISS_UP, Action.TECH_MISS_DOWN]:
# Adjust the position to account for the fact that we can't roll off the stage
position = min(position, stages.edgegroundposition(stage))
position = max(position, -stages.edgegroundposition(stage))
return position
# If we get a key error, just assume this animation doesn't go anywhere
except KeyError:
return character_state.x