def game_map_bump_correct( arrow, play_map ): # Is arrow near grid center that need to check current grid bound arrow_grid = play_map.detect_grid( arrow.position ) grid_position = play_map.grid_center( arrow_grid ) if ( cal.unit( cal.vector( grid_position, arrow.position ) ) == arrow.direction ): # convert vector to wall definition arrow_bump_wall = game_map.direction_to_wall( arrow.direction ) # arrow bumps wall if ( arrow_bump_wall & play_map.grids[arrow_grid[1]*play_map.map_size[0]+arrow_grid[0]] != 0 ): arrow.set_position( grid_position )
def game_arrow_encounter(arrow_p1, arrow_p2): # arrow encounter detect and handle if( cal.distance(arrow_p1.position, arrow_p2.position) < res.distance_collision): # pygame.draw.rect(gameDisplay, res.color_obj, [0,0,30,30], 5) if(arrow_p1.direction == arrow_p2.direction): return res.game_brokeback elif(arrow_p1.direction == cal.reverse(arrow_p2.direction)): arrow_p1.set_direction( cal.reverse(arrow_p1.direction) ) arrow_p1.position = (arrow_p1.position[0]+arrow_p1.direction[0]*res.distance_collision, arrow_p1.position[1]+arrow_p1.direction[1]*res.distance_collision) arrow_p2.set_direction( cal.reverse(arrow_p2.direction) ) arrow_p2.position = (arrow_p2.position[0] + arrow_p2.direction[0]*res.distance_collision, arrow_p2.position[1] + arrow_p2.direction[1]*res.distance_collision) return res.game_collision else: # if p1 bumps p2 if ( arrow_p1.direction == cal.unit( cal.vector(arrow_p1.position, arrow_p2.position) ) ): arrow_p1.set_direction( cal.reverse(arrow_p1.direction) ) else: arrow_p2.set_direction( cal.reverse(arrow_p2.direction) ) return res.game_side_collision