def Move(): global player_x_coord, player_y_coord old_x, old_y = player_x_coord, player_y_coord if is_player_moving: if player_move_direction == DIR_NORTH: player_y_coord -= player_speed elif player_move_direction == DIR_NORTH_EAST: player_y_coord -= player_speed * DIAGONAL_LONG player_x_coord += player_speed * DIAGONAL_LONG elif player_move_direction == DIR_EAST: player_x_coord += player_speed elif player_move_direction == DIR_SOUTH_EAST: player_y_coord += player_speed * DIAGONAL_LONG player_x_coord += player_speed * DIAGONAL_LONG elif player_move_direction == DIR_SOUTH: player_y_coord += player_speed elif player_move_direction == DIR_SOUTH_WEST: player_y_coord += player_speed * DIAGONAL_LONG player_x_coord -= player_speed * DIAGONAL_LONG elif player_move_direction == DIR_WEST: player_x_coord -= player_speed elif player_move_direction == DIR_NORTH_WEST: player_y_coord -= player_speed * DIAGONAL_LONG player_x_coord -= player_speed * DIAGONAL_LONG x_diff = math.trunc(old_x) - math.trunc(player_x_coord) if x_diff > 0: World.CalcChunk((player_x_coord, player_y_coord), "west") elif x_diff < 0: World.CalcChunk((player_x_coord, player_y_coord), "east") y_diff = math.trunc(old_y) - math.trunc(player_y_coord) if y_diff > 0: World.CalcChunk((player_x_coord, player_y_coord), "north") elif y_diff < 0: World.CalcChunk((player_x_coord, player_y_coord), "south")
def EventManager(event): #Event de pygame global player_x_coord, player_y_coord if event.type == pygame.KEYDOWN: if (event.key == pygame.K_UP) or (event.key == pygame.K_RIGHT) or (event.key == pygame.K_DOWN) or (event.key == pygame.K_LEFT): ChangeDirection(event.key) if event.key == pygame.K_UP: player_y_coord -= 0.5 World.CalcChunk((player_x_coord, player_y_coord), "north") elif event.key == pygame.K_RIGHT: player_x_coord += 0.5 World.CalcChunk((player_x_coord, player_y_coord), "east") elif event.key == pygame.K_DOWN: player_y_coord += 0.5 World.CalcChunk((player_x_coord, player_y_coord), "south") elif event.key == pygame.K_LEFT: player_x_coord -= 0.5 World.CalcChunk((player_x_coord, player_y_coord), "west")