Пример #1
0
from boat import Boat
from waypoint import Waypoint

# PART A ======================================================================

boat = Boat()

#  moves = ['F10', 'N3', 'F7', 'R90', 'F11']
moves = open('input.txt', 'r').readlines()
for move in moves:
    boat.move(move)

d = boat.dist(0, 0)
print(f"A :: Distance to origin: {d}")

# PART B ======================================================================

way = Waypoint()
for move in moves:
    way.move(move)

d = way.dist()
print(f"B :: Distance to origin: {d}")
Пример #2
0
def control(boat):
 
    print(boat)
    
    sail = input('set sail, captain:')
    try:
        boat.sail = int(sail) * np.pi/ 180   
    except:
        if sail == 'exit':
            print('\n\033[31m' + 'game over' + '\033[30m')
            exit()
    
    wheel = input('set wheel, captain:')
    try:
        boat.wheel = int(wheel) * np.pi/ 180   
    except:
        pass
    
    return True


boat = Boat()

for t in range(1000):
    if t%10 == 0: 
        print('\n\033[31m' + '--- control session --- (print exit to exit)---'+'\033[30m')
        print('wind = ', env.wind, ', apparent wind =', env.wind - boat.speed)
        control(boat)
    boat.move(env)
Пример #3
0
while not dead:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            dead = True
            sys.exit()
        if event.type == pygame.KEYDOWN:
            if event.key in utils.DIRECTIONS:
                if event.key not in direction_list:
                    direction_list.append(event.key)
            elif event.key == pygame.K_SPACE:
                boat.startCapturing()
        if event.type == pygame.KEYUP:
            if event.key in utils.DIRECTIONS:
                if event.key in direction_list:
                    direction_list.remove(event.key)
    if len(direction_list) != 0:
        boat.move(direction_list[0],game_area)

    shark.move(game_area)

    screen.fill(utils.COLORS['white'])
    gray_background.drawOnDisplay(game_area)
    active_background.drawOnDisplay(game_area)
    game_area.blit(shark.getSurface(), shark.getPos())
    if boat.capture and len(boat.capturing) > 1:
        pygame.draw.lines(game_area.getSurface(), utils.COLORS['green'],False, boat.capturing, utils.PADDING)
    pygame.draw.polygon(game_area.getSurface(), utils.COLORS['green'], game_area.getPlayerCircuit(), utils.PADDING)
    game_area.blit(boat.getSurface(), boat.getDrawPos())
    screen.blit(game_area.getSurface(), game_area_start)
    pygame.display.flip()
    clock.tick(60)