Ejemplo n.º 1
0
    def main_loop(self):
        self.done = False
        while not self.done and not kitchen.stop_request:
            for e in pygame.event.get():
                if e.type is pygame.QUIT:
                    kitchen.finish()
                    self.done = True
                elif e.type is pygame.MOUSEBUTTONDOWN:
                    dream = self.dream_map.get_at(e.pos)
                    if dream:
                        click_result = dream.on_click()
                        if click_result:
                            self.done = True
                elif e.type is pygame.MOUSEMOTION:
                    dream = self.dream_map.get_at(e.pos)
                    #print(e.pos, DreamButton.ghost_surf.get_at(pos)[0])
                    if dream:
                        self.hover_text = dream.on_hover()
                    else:
                        self.hover_text = None

            self.main_surface.blit(self.bg_img, [0,0])
            for b in self.buttons:
                b.update()
                b.draw(self.main_surface)
            if self.hover_text:
                center_text(self.hover_text, self.font, self.font_color, self.name_rect,
                            self.main_surface)
            pygame.time.wait(1000//15)
            pygame.display.flip()
        self.ath()
Ejemplo n.º 2
0
    def main_loop(self):
        """The player enters this location in the dating sim"""
        all_sprites = pygame.sprite.Group()
        buttons = pygame.sprite.Group()

        # generate Location-specific buttons
        LocButton.reset()
        LocButton.containers = [all_sprites, buttons]
        for name, on_click in self.button_data:
            LocButton(on_click, name)

        # generate generic menu buttons
        LocButton2.reset()
        LocButton2.containers = [all_sprites, buttons]
        dumby_fn = lambda: None

        def inventory_fn():
            text = datingsim.player.inventory.dump()
            d = CoolDialogue(text, snapshot=datingsim.snapshot())
            d.main_loop()

        def statistics_fn():
            text = datingsim.player.stats_dump()
            CoolDialogue(text, snapshot=datingsim.snapshot()).main_loop()

        LocButton2(dumby_fn, "Location Name")
        LocButton2(inventory_fn, "Inventory")
        LocButton2(statistics_fn, "Statistics")

        BackToMap.containers = [all_sprites, buttons]
        BackToMap()

        QuickSleepButton.containers = [all_sprites, buttons]
        QuickSleepButton()

        # cash and HP display text
        cash_text_loc = (200, HEIGHT - 30)
        CashHPText.containers = [all_sprites]
        CashHPText(cash_text_loc)

        # okay, and now we loop
        self.done = False
        while not self.done:
            for event in pygame.event.get():
                if event.type is pygame.QUIT:
                    import kitchen

                    kitchen.finish()
                    return
                elif event.type is pygame.MOUSEBUTTONDOWN:
                    for button in buttons:
                        if button.rect.collidepoint(event.pos):
                            # TODO: consider whether this is worth implementing
                            # if location switches, button is expected to change
                            # global variable location and return True
                            # done = button.on_click() or False
                            click_result = button.on_click()
                            if click_result == Location.STATUS_END_SCENE:
                                self.done = True
                                import kitchen

                                kitchen.remove_scene(self)
                            elif click_result == Location.STATUS_NEXT_SCENE:
                                self.done = True
                all_sprites.update()
                datingsim.screen.fill(self.WASH_COLOR)
                if self.bg_img:
                    datingsim.screen.blit(self.bg_img, [0, 0])
                all_sprites.draw(datingsim.screen)
                # blit_title()
                # update_text()
                # screen.blit(text_surf, text_loc)
                pygame.display.flip()
                pygame.time.wait(1000 // 20)