Exemple #1
0
def travelFunction(game, destination):

    distance = common_functions.getDistance(game.coords, destination.coords)
    travelDaysNeeded = int(distance / 25) + 1
    daysTraveled = 0

    #in lieu of trig, this is the easier way to move the player day by day
    xDiff = destination.coords[0] - game.coords[0]
    yDiff = destination.coords[1] - game.coords[1]
    xChange = int(xDiff / travelDaysNeeded)
    yChange = int(yDiff / travelDaysNeeded)

    while daysTraveled < travelDaysNeeded:
        #can eventually make this more complicated so you arrive in town at a time related
        #to how many miles you had to travel on the last day
        travelEvent(game)
        daysTraveled += 1
        if daysTraveled < travelDaysNeeded:
            game.coords = (game.coords[0] + xChange, game.coords[1] + yChange)
            game.time = 20.5
            campScreen(game)

    game.coords = destination.coords
    game.time = 20
    return destination
def movePlayer(player, destination):

    distance = common_functions.getDistance(player.coords, destination)
    time = int(distance / 25) + 1

    xDiff = destination.coords[0] - player.coords[0]
    yDiff = destination.coords[1] - player.coords[1]

    xChange = int(xDiff / time)
    yChange = int(yDiff / time)

    player.coords = (player.coords[0] + xChange, player.coords[1] + yChange)
def travelFunction(player, destination):

    distanceRemaining = common_functions.getDistance(player.coords,
                                                     destination.coords)
    daysTraveled = 0
    time = int(distanceRemaining / 25) + 1

    xDiff = destination.coords[0] - player.coords[0]
    yDiff = destination.coords[1] - player.coords[1]
    xChange = int(xDiff / time)
    yChange = int(yDiff / time)

    while distanceRemaining > 0:

        travelEvent()
        distanceRemaining -= 25
        if distanceRemaining > 0:
            player.coords = (player.coords[0] + xChange,
                             player.coords[1] + yChange)
            campScreen(player)
    print('you have arrived')
    player.coords = destination.coords
    return destination
Exemple #4
0
def travelFunction(player, destination):

    distance = common_functions.getDistance(player.coords, destination.coords)
    travelDaysNeeded = int(distance / 25) + 1
    daysTraveled = 0

    #i dont have advanced trig knowledge, so this is the easier way to move the player day by day
    xDiff = destination.coords[0] - player.coords[0]
    yDiff = destination.coords[1] - player.coords[1]
    xChange = int(xDiff / travelDaysNeeded)
    yChange = int(yDiff / travelDaysNeeded)

    while daysTraveled < travelDaysNeeded:

        travel_event.travelEvent(player)
        daysTraveled += 1
        if daysTraveled < travelDaysNeeded:
            player.coords = (player.coords[0] + xChange, player.coords[1] + yChange)
            player.time = 20.5
            campScreen(player)

    player.coords = destination.coords
    player.time = 20
    return destination
Exemple #5
0
def displayConfirmTravelMenu(player, destination):
    """ displays the info related to a potential travel choice and returns a choice of accepting or canceling. """

    currentLocation = 'Wilderness'  #later ill make this say the closest hub, but thats just decoration
    for i in hubs.HUBLIST:
        if i.coords == player.coords:
            currentLocation = i.name

    distance = common_functions.getDistance(
        player.coords, destination.coords
    )  #gets the distance between current location and destination
    time = int(
        distance / 25
    ) + 1  #for now simply set so you travel 25 miles a day. later this will invoke your stats

    actions = ['Start Trip', 'Cancel']

    menuBackSurf = pygame.Surface((600, 350))
    menuBackSurf.fill(cfg.BLUE)
    menuBackSurf.set_alpha(220)
    menuBackRect = menuBackSurf.get_rect()
    menuBackRect.topleft = (100, 125)

    cfg.DISPLAYSURF.blit(menuBackSurf, menuBackRect)
    pygame.draw.rect(cfg.DISPLAYSURF, cfg.BLACK, menuBackRect, 2)

    headerSurf = cfg.AR25.render('Confirm Trip', True, cfg.WHITE)
    headerRect = headerSurf.get_rect()
    headerRect.midtop = (menuBackRect.centerx, menuBackRect.top + 5)
    cfg.DISPLAYSURF.blit(headerSurf, headerRect)
    pygame.draw.line(cfg.DISPLAYSURF, cfg.WHITE,
                     (menuBackRect.left + 25, headerRect.bottom + 4),
                     (menuBackRect.right - 25, headerRect.bottom + 4), 1)

    fromSurf = cfg.BASICFONT.render('Traveling from: %s' % currentLocation,
                                    True, cfg.WHITE)
    fromRect = fromSurf.get_rect()
    fromRect.topleft = (menuBackRect.left + 10, headerRect.bottom + 10)
    toSurf = cfg.BASICFONT.render('Traveling to:     %s' % destination.name,
                                  True, cfg.WHITE)
    toRect = toSurf.get_rect()
    toRect.topleft = (menuBackRect.left + 10, fromRect.bottom + 10)
    cfg.DISPLAYSURF.blit(fromSurf, fromRect)
    pygame.draw.line(cfg.DISPLAYSURF, cfg.WHITE,
                     (menuBackRect.left + 5, fromRect.bottom + 5),
                     (headerRect.centerx + 25, fromRect.bottom + 5), 1)
    cfg.DISPLAYSURF.blit(toSurf, toRect)
    pygame.draw.line(cfg.DISPLAYSURF, cfg.WHITE,
                     (menuBackRect.left + 5, toRect.bottom + 5),
                     (headerRect.centerx + 25, toRect.bottom + 5), 1)

    distanceSurf = cfg.BASICFONT.render('Total Distance: %s miles' % distance,
                                        True, cfg.WHITE)
    distanceRect = distanceSurf.get_rect()
    distanceRect.topleft = (menuBackRect.left + 10, toRect.bottom + 12)
    cfg.DISPLAYSURF.blit(distanceSurf, distanceRect)
    pygame.draw.line(cfg.DISPLAYSURF, cfg.WHITE,
                     (menuBackRect.left + 5, distanceRect.bottom + 5),
                     (headerRect.centerx + 25, distanceRect.bottom + 5), 1)

    timeSurf = cfg.BASICFONT.render('Estimated Travel Time: %s days' % time,
                                    True, cfg.WHITE)
    timeRect = timeSurf.get_rect()
    timeRect.topleft = (menuBackRect.left + 10, distanceRect.bottom + 12)
    cfg.DISPLAYSURF.blit(timeSurf, timeRect)
    pygame.draw.line(cfg.DISPLAYSURF, cfg.WHITE,
                     (menuBackRect.left + 5, timeRect.bottom + 5),
                     (headerRect.centerx + 25, timeRect.bottom + 5), 1)

    x = menuBackRect.right - 15
    y = menuBackRect.bottom - 5
    for i in actions[::-1]:
        actionSurf = cfg.BASICFONT.render(i, True, cfg.WHITE)
        actionRect = actionSurf.get_rect()
        actionRect.bottomright = (x, y)
        if actionRect.collidepoint(cfg.mouseX, cfg.mouseY):
            actionSurf = cfg.BASICFONT.render(i, True, cfg.RED)
            if cfg.mouseClicked:
                return i
        cfg.DISPLAYSURF.blit(actionSurf, actionRect)
        x -= 100