Beispiel #1
0
    def update(self, time):
        if self.queue_dialog:
            if self.cleared:
                sd.start(self.queue_dialog)
                self.queue_dialog = None
                self.cleared = False

        else:

            try:
                text = self.dialogs.pop()
            except IndexError:
                sd.done()
                return

            if text[:6] == "#image":
                fill = False
                tag, path = text.split(":")

                if path[0] == "+":
                    fill = True
                    path = path[1:]

                if tag[-8:] == "colorkey":
                    image = res.loadImage(path, colorkey=1)
                elif tag[-5:] == "alpha":
                    image = res.loadImage(path, alpha=1)
                else:
                    image = res.loadImage(path)

                rect = image.get_rect()
                if fill:
                    size = [int(i) for i in sd.get_size()]
                    x = size[0] - rect.w
                    y = size[1] - rect.h
                    r = float(rect.w) / rect.h
                    if x > y:
                        rect = pygame.Rect((0, 0, size[0], size[1] * r))
                    else:
                        rect = pygame.Rect((0, 0, size[0] * r, size[1]))

                    rect.center = size[0] / 2, size[1] / 2
                    image = pygame.transform.smoothscale(image, rect.size)
                else:
                    rect.topleft = ((sd.get_size()[0] / 2) - (rect.width / 2),
                                    10)

                self.queue_image = (image, rect)
                self.cleared = False

            elif text[:6] == "#music":
                tag, path = text.split(":")
                self.queue_music = path

            else:
                self.queue_dialog = TextDialog(text)
Beispiel #2
0
    def update(self, time):
        if self.queue_dialog:
            if self.cleared:
                sd.start(self.queue_dialog)
                self.queue_dialog = None
                self.cleared = False

        else:

            try:
                text = self.dialogs.pop()
            except IndexError:
                sd.done()
                return

            if text[:6] == "#image":
                fill = False
                tag, path = text.split(":")

                if path[0] == "+":
                    fill = True
                    path = path[1:]

                if tag[-8:] == "colorkey":
                    image = res.loadImage(path, colorkey=1)
                elif tag[-5:] == "alpha":
                    image = res.loadImage(path, alpha=1)
                else:
                    image = res.loadImage(path)
     
                rect = image.get_rect()
                if fill:
                    size = [ int(i) for i in sd.get_size() ]
                    x = size[0] - rect.w
                    y = size[1] - rect.h
                    r = float(rect.w) / rect.h
                    if x > y:
                        rect = pygame.Rect((0,0,size[0],size[1]*r))
                    else:
                        rect = pygame.Rect((0,0,size[0]*r,size[1]))

                    rect.center = size[0] / 2, size[1] / 2
                    image = pygame.transform.smoothscale(image, rect.size)
                else:
                    rect.topleft = ((sd.get_size()[0]/2)-(rect.width/2), 10)
                
                self.queue_image = (image, rect)
                self.cleared = False

            elif text[:6] == "#music":
                tag, path = text.split(":")
                self.queue_music = path

            else:
                self.queue_dialog = TextDialog(text)
Beispiel #3
0
    def activate(self):
        self.activated = True

        res.fadeoutMusic()

        self.maps = []
        self.change_delay = 2000        # seconds until map moves to next point
        self.map_fadeout = 60.0         # must be a float
        self.last_update = 0
        self.surfaceQueue = queue()
        self.subpixelQueue = queue()

        self.hotspots = cycle(([300,500], [750, 800], [350, 260], [700, 340], [120, 1000], [800, 830], [480, 900]))
        
        self.overworld = res.loadImage("overworld.png")

        self.menu = cMenu(Rect((42,20), sd.get_size()),
            20, 5, 'vertical', 100,
            [('New Game', self.new_game),
            ('Load Game', self.load_game),
            ('Introduction', self.show_intro),
            ('Quit Game', self.quit_game)],
            font="northwoodhigh.ttf", font_size=24)

        self.menu.ready()
        self.change_map()
Beispiel #4
0
    def update(self, time):

        for i in self.maps:
            i[0] += i[2]
            i[1] += i[3]
            if i[4] > 0:
                i[4] += 1

        self.last_update += time
        if self.last_update >= self.change_delay:
            self.change_map()
            self.last_update -= self.change_delay

        try:
            image = self.subpixelQueue.get(0)
        except Empty:
            pass

        else:
            if not len(self.maps) == 0:
                self.maps[0][4] = 1  # mark it for fadeout

            w0, h0 = sd.get_size()
            w1, h1 = image.get_size()

            self.maps.insert(0, [-(w1-w0)/2, -(h1-h0)/2,
                             round(uniform(-0.08, 0.08), 3),
                             round(uniform(-0.08, 0.08), 3), 0, image])

            self.subpixelQueue.task_done()

        self.maps = [ i for i in self.maps if i[4] < self.map_fadeout ][:2]
Beispiel #5
0
    def activate(self):
        self.activated = True

        res.fadeoutMusic()

        self.maps = []
        self.change_delay = 2000  # seconds until map moves to next point
        self.map_fadeout = 60.0  # must be a float
        self.last_update = 0
        self.surfaceQueue = queue()
        self.subpixelQueue = queue()

        self.hotspots = cycle(([300, 500], [750, 800], [350, 260], [700, 340],
                               [120, 1000], [800, 830], [480, 900]))

        self.overworld = res.loadImage("overworld.png")

        self.menu = cMenu(Rect((42, 20), sd.get_size()),
                          20,
                          5,
                          'vertical',
                          100, [('New Game', self.new_game),
                                ('Load Game', self.load_game),
                                ('Introduction', self.show_intro),
                                ('Quit Game', self.quit_game)],
                          font="northwoodhigh.ttf",
                          font_size=24)

        self.menu.ready()
        self.change_map()
Beispiel #6
0
    def update(self, time):

        for i in self.maps:
            i[0] += i[2]
            i[1] += i[3]
            if i[4] > 0:
                i[4] += 1

        self.last_update += time
        if self.last_update >= self.change_delay:
            self.change_map()
            self.last_update -= self.change_delay

        try:
            image = self.subpixelQueue.get(0)
        except Empty:
            pass

        else:
            if not len(self.maps) == 0:
                self.maps[0][4] = 1  # mark it for fadeout

            w0, h0 = sd.get_size()
            w1, h1 = image.get_size()

            self.maps.insert(0, [
                -(w1 - w0) / 2, -(h1 - h0) / 2,
                round(uniform(-0.08, 0.08), 3),
                round(uniform(-0.08, 0.08), 3), 0, image
            ])

            self.subpixelQueue.task_done()

        self.maps = [i for i in self.maps if i[4] < self.map_fadeout][:2]
Beispiel #7
0
    def change_map(self):
        pos = list(next(self.hotspots)[:])
        r = Rect((0,0), sd.get_size()).inflate((48, 48))
        r.center = pos
        clip = Surface(r.size)
        clip.blit(self.overworld, (0,0), r)

        self.surfaceQueue.put(clip)
        self.thread = SubPixelThread(self.surfaceQueue, self.subpixelQueue)
        self.thread.start()
Beispiel #8
0
    def change_map(self):
        pos = list(next(self.hotspots)[:])
        r = Rect((0, 0), sd.get_size()).inflate((48, 48))
        r.center = pos
        clip = Surface(r.size)
        clip.blit(self.overworld, (0, 0), r)

        self.surfaceQueue.put(clip)
        self.thread = SubPixelThread(self.surfaceQueue, self.subpixelQueue)
        self.thread.start()
Beispiel #9
0
    def activate(self):
        self.blank = True
        self.background = (203, 204, 177)
        self.foreground = (0, 0, 0)

        self.controller = WorldStateController(self, self.area)

        self.msgFont = pygame.font.Font((res.fontPath("volter.ttf")), 9)
        self.border = gui.GraphicBox("dialog2-h.png", hollow=True)
        self.borderFilled = gui.GraphicBox("dialog2.png")
        self.player_vector = Vec2d(0,0)

        # load the pygame and data assests for the area
        self.area.load()

        # get the root and the hero from it
        root = self.area.getRoot()
        self.hero = root.getChildByGUID(1)
        self.hero.move_speed = 1

        # add the hero to this map if it isn't already there
        if not self.area.hasChild(self.hero):
            self.area.add(self.hero)

        # attach a camera
        sw, sh = sd.get_size()
        mw = sw * .75
        mh = sh * .75
        self.camera = AreaCamera(self.area,(4,4, mw, mh),
                                 tmxdata=self.area.tmxdata)

        # define the borders
        self.mapBorder = pygame.Rect((0,0,mw+6,mh+6))
        self.msgBorder = pygame.Rect((0,mh,sw,sh-mh))
        self.hudBorder = pygame.Rect((mw,0,sw-mw,mh+6))

        # load sounds from area
        for filename in self.area.soundFiles:
            SoundMan.loadSound(filename)
Beispiel #10
0
    def activate(self):
        self.blank = True
        self.background = (203, 204, 177)
        self.foreground = (0, 0, 0)

        self.controller = WorldStateController(self, self.area)

        self.msgFont = pygame.font.Font((res.fontPath("volter.ttf")), 9)
        self.border = gui.GraphicBox("dialog2-h.png", hollow=True)
        self.borderFilled = gui.GraphicBox("dialog2.png")
        self.player_vector = Vec2d(0, 0)

        # load the pygame and data assests for the area
        self.area.load()

        # get the root and the hero from it
        root = self.area.getRoot()
        self.hero = root.getChildByGUID(1)
        self.hero.move_speed = 1

        # add the hero to this map if it isn't already there
        if not self.area.hasChild(self.hero):
            self.area.add(self.hero)

        # attach a camera
        sw, sh = sd.get_size()
        mw = sw * .75
        mh = sh * .75
        self.camera = AreaCamera(self.area, (4, 4, mw, mh),
                                 tmxdata=self.area.tmxdata)

        # define the borders
        self.mapBorder = pygame.Rect((0, 0, mw + 6, mh + 6))
        self.msgBorder = pygame.Rect((0, mh, sw, sh - mh))
        self.hudBorder = pygame.Rect((mw, 0, sw - mw, mh + 6))

        # load sounds from area
        for filename in self.area.soundFiles:
            SoundMan.loadSound(filename)