Exemple #1
0
    def warpPlayer(self, area, position):
        """
        move player to another map
        """

        area.add(self.hero)
        area.setPosition(self.hero, position)
        sd.push(WorldState(area))
        sd.done()
Exemple #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)
Exemple #3
0
def bodyWarp(sender, **kwargs):
    area = sender
    body = kwargs['body']
    destination = kwargs['destination']
    state = kwargs['caller']

    if state == None:
        return

    if body == state.hero:
        sd.push(WorldState(destination))
        sd.done()
Exemple #4
0
 def quit_game(self):
    sd.done() 
Exemple #5
0
 def activate(self):
     sd.done() 
Exemple #6
0
 def yes(self): sd.done()
 def no(self): sd.done()
Exemple #7
0
 def handle_commandlist(self, cmdlist):
     for cls, cmd, arg in cmdlist:
         if (cmd == P1_ACTION1) and arg:
             sd.done()   
Exemple #8
0
 def handle_commandlist(self, cmdlist):
     for cls, cmd, arg in cmdlist:
         if arg == BUTTONDOWN and cmd == P1_ACTION1 and not self.blank:
             sd.done()   
Exemple #9
0
 def handle_event(self, event):
     if event.type == pygame.locals.KEYDOWN:
         sd.done()