Esempio n. 1
0
 def on_init(self, Game):
     try:
         fName = self.name.replace(" ", "")
         path = displaylib.getpath("Assets", (fName + ".txt"))
         with open(path, "r") as f:
             for line in f:
                 line = line.strip('\n')
                 path = displaylib.getpath("Assets", line)
                 nwIm = displaylib.image(path, 0)
                 #nwIm._image_surf = pygame.transform.smoothscale(nwIm._image_surf, ((1366/2),768))
                 w = (Game.windowSize[1] / nwIm.h() * .9) * nwIm.w()
                 nwIm._image_surf = pygame.transform.smoothscale(
                     nwIm._image_surf,
                     (int(w), int(Game.windowSize[1] * .9)))
                 if ("path" in path):
                     self.pathImages.append(nwIm)
                 elif ("sky" in path):
                     self.skyImage = nwIm
                 elif ("hud" in path):
                     self.hudImage = nwIm
                 elif (("/" + self.name.replace(" ", "")) in path):
                     self.mountImages.append(nwIm)
                 else:
                     self.other.append(nwIm)
     except:
         print(pygame.get_error())
         print("Could not load the mountain images")
Esempio n. 2
0
    def on_init(self):
        try:
            levelList = []
            path = displaylib.getpath("Assets", "mountains.txt")
            with open(path, "r") as self.fallLength:
                for line in self.fallLength:
                    levelList.append(line.rstrip('\n'))
        except:
            print("Could not load the level")
        for i in levelList:
            info = (i.split(";"))
            name = info[0]
            height = float(info[1].rstrip('\n'))
            difficulty = float(info[2].rstrip('\n'))
            routelen = float(info[3].rstrip('\n'))
            diffs = info[4].rstrip('\n')
            otherRendering = info[5].rstrip('\n').split(",")
            #diffs = [ x[0] for x in info[4]]

            mount = Mountain(name, height, difficulty, routelen, diffs,
                             otherRendering)
            mount.on_init(self.game)
            self.mounts.append(mount)
            self.resear.append(0)
        try:
            self.walksequence.append(
                displaylib.animation(self.game, self, [
                    self.newchar.images[0], self.newchar.images[1],
                    self.newchar.images[2], self.newchar.images[3]
                ], 0.1))
            self.walksequence.append(
                displaylib.animation(self.game, self, [
                    self.newchar.images[4], self.newchar.images[5],
                    self.newchar.images[6]
                ], 0.1))
        except:
            self.walksequence.append(
                displaylib.image(displaylib.getpath("Assets", "leftfoot.png"),
                                 0))
            self.walksequence.append(
                displaylib.image(displaylib.getpath("Assets", "rightfoot.png"),
                                 0))

        try:
            Ws = []
            path = displaylib.getpath("Assets", "walksounds.txt")
            with open(path, "r") as f:
                for line in f:
                    Ws.append(line.rstrip('\n'))
        except:
            print("could not load walking sounds")

        for i in Ws:
            path = displaylib.getpath("Assets", i)
            newSound = displaylib.sound(path)
            self.walksounds.append(newSound)
Esempio n. 3
0
    def success(self, ev, mount):
        self.clock.tick_busy_loop()
        self.play = False
        self.win = True
        self.newchar.mountsClimbed += 1
        self.newchar.setPosition(0)
        path = displaylib.getpath("Assets", "success.png")
        winim = displaylib.image(path, 0)
        mounttext = displaylib.font(24, mount.name, (255, 255, 255), True)
        routetext = displaylib.font(
            20, "You climbed: " + str(mount.routeLength) + " m",
            (255, 255, 255), False)
        # timetext = displaylib.font(24, ("Time: {0:.2f} minutes").format(self.clock.get_time()), (255,255,255), False)

        while (True):
            for event in pygame.event.get():
                ev.on_event(event, self.game, self)
                self.game._display_surf.fill([0, 0, 0])
                self.game._display_surf.blit(
                    mounttext.text_surf, ((self.game.windowSize[0] / 2 -
                                           mounttext.text_surf.get_width()),
                                          self.game.windowSize[1] / 2))
                self.game._display_surf.blit(
                    routetext.text_surf, ((self.game.windowSize[0] / 2 -
                                           routetext.text_surf.get_width()),
                                          self.game.windowSize[1] / 2 + 30))
                #        self.game._display_surf.blit(timetext.text_surf, ((
                #           self.game.windowSize[0]/2 - timetext.text_surf.get_width()), self.game.windowSize[1]/2 + 60))
                pygame.display.update()
            if (self.game.onHomeScreen == True):
                break
Esempio n. 4
0
 def on_init(self):
     self.onHomeScreen = True
     pygame.init()
     pygame.mixer.init()
     
     pygame.display.set_caption("Ascension (demo)")
     self._display_surf = pygame.display.set_mode(
         (1280, 720),  pygame.HWSURFACE | pygame.DOUBLEBUF | pygame.RESIZABLE)
     if os.name == 'nt':
         hwnd = win32gui.GetForegroundWindow()
         win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
     self.windowSize = [
         self._display_surf.get_width(), self._display_surf.get_height()]
     self._running = True
     self.openingMusic = displaylib.music(displaylib.getpath("Assets","tobias_weber_-_Between_Worlds_(Instrumental).mp3"))
     openPath = displaylib.getpath("Assets", "ascensionopenscreen.png")
     self.openingScreen = displaylib.image(openPath, 0)
     self.Ascensiontitletext = displaylib.font(
         75, "Ascension", (0, 0, 0), False)
     self.startleveltext = displaylib.font(
         30, "Press Enter to start level", (0, 0, 0), False)
Esempio n. 5
0
    def on_init(self):
        array = []
        try:
            path = displaylib.getpath("Assets", self.fileName)
            with open(os.path.join(path), "r") as self.fallLength:

                for line in self.fallLength:
                    array.append(line.rstrip('\n'))
        except:
            print("Could not load the character")
        self.name = array[0]
        self.mountsClimbed = int(array[1])
        self.totalmetersclimbed = float(array[2])
        if (array != None):
            for i in array:
                path = displaylib.getpath("Assets", i)
                nImage = displaylib.image(path, 0)
                if (nImage._image_surf != None):
                    w = (self.game.windowSize[1] / nImage.h() *
                         .9) * nImage.w()
                    nImage._image_surf = pygame.transform.smoothscale(
                        nImage._image_surf,
                        (int(w), int(self.game.windowSize[1] * .9)))
                    self.images.append(nImage)
Esempio n. 6
0
    def rest(self, ev, climber, mount):
        restpath = displaylib.getpath("Assets", "resting.png")
        restimage = displaylib.image(restpath, 0)
        mnttxt = displaylib.font(20, "Resting on " + mount.name,
                                 (255, 255, 255), True)
        self.isResting = True
        w = (self.game.windowSize[1] / restimage.h() * 1.5) * restimage.w()
        restimage._image_surf = pygame.transform.scale(
            restimage._image_surf, (int(w), int(self.game.windowSize[1] * .9)))

        while (self.isResting):
            for event in pygame.event.get():
                ev.on_event(event, self.game, self)

    #    while(climber.getHealth() < 100):
            resttxt = displaylib.font(
                20, "Your Health... " + str(climber.getHealth()),
                (255, 255, 255), True)
            self.game._display_surf.fill([0, 0, 0])
            self.game._display_surf.blit(restimage._image_surf, (300, 100))
            self.game._display_surf.blit(mnttxt.text_surf,
                                         ((self.game.windowSize[0] * .6), 0))
            self.game._display_surf.blit(resttxt.text_surf,
                                         ((self.game.windowSize[0] * .2), 0))
            pygame.display.update()
            pygame.time.delay(1200)
            self.resnum = self.progress.calcRestProg(climber)
            print("Resting Players Health... " + str(self.resnum))

            climber.setHealth(self.resnum)
            if (climber.getHealth() >= 100):

                fresttxt = displaylib.font(20, "Your health is full",
                                           (255, 255, 255), True)
                print("Climber's Health is already at Max ")
                climber.setHealth(100)
                self.game._display_surf.fill([0, 0, 0])
                self.game._display_surf.blit(
                    fresttxt.text_surf, ((self.game.windowSize[0] * 3), 0))
                pygame.display.update()
                self.isResting = False