Example #1
0
 def tick(self, ms):
     if controller.btn_event('select'):
         c = self._choices[self._choice]
         return c[1], c[2]
     elif controller.btn_event('down'):
         self._choice = (self._choice + 1) % len(self._choices)
     elif controller.btn_event('up'):
         self._choice = (self._choice - 1) % len(self._choices)
     # draw the whole screen
     pview.fill('black')
     for i, choice in enumerate(self._choices):
         ptext.draw(choice[0], T(200, 200 + i * 100), fontsize=T(70))
     ptext.draw('>', T(150, 200 + self._choice * 100), fontsize=T(70))
     ptext.draw('F11: toggle fullscreen\nEsc: quit',
                T(10, 10),
                fontsize=T(20))
     pg.display.flip()
     return None, {}  # no next scene to return
Example #2
0
 def tick(self, ms):
     # process player inputs
     if controller.btn_event('select'):
         return SCN_MENU, {
             'can_resume': 1
         }  # add "Resume Game" to menu scene
     if controller.btn_event('left'):
         self.model.choose('left')
         self._set_renderers_stale()
     if controller.btn_event('right'):
         self.model.choose('right')
         self._set_renderers_stale()
     if self.model.game_status == GST_LOST:
         return SCN_OVER, {'enc_seen': self.model.encounters_seen}
     # tick renderers
     self.enc.tick(ms)
     self.hud.tick(ms)
     return None, {}
Example #3
0
    def tick(self, ms):
        """ process player inputs and draw """
        if controller.btn_event(BUPP):
            self.level.move(DIRN)
        if controller.btn_event(BDWN):
            self.level.move(DIRS)
        if controller.btn_event(BLFT):
            self.level.move(DIRW)
        if controller.btn_event(BRGT):
            self.level.move(DIRE)
        if controller.btn_event(BRST):
            self.level.reset()
        if controller.btn_event(BMNU):
            return SCN_MENU, {'current_level': self.level.level_num}

        if self.level.is_complete():
            # TODO: dance
            return SCN_GAME, {'level': self.level.level_num + 1}

        self._draw()
        return None, {}
Example #4
0
 def tick(self, ms):
     if controller.btn_event('select'):
         return SCN_MENU, {}
     self._draw()
     return None, {}
Example #5
0
    def tick(self, ms):
        # process inputs: play selected level or quit
        if controller.btn_event(BSLC):
            c = self._choices[self._choice]
            if c[1] and c[2]['level'] == self._ongoing_level:
                return SCN_GAME, {
                    'resume_level': True
                }  # key matters, not value
            else:
                return c[1], c[2]
        if controller.btn_event(BMNU):  # press menu button when in menu: exit
            return SCN_QUIT, {}

        # process inputs: move level cursor
        cursor_row = self._choice // self._page_w
        max_row = len(self._choices) // self._page_w - 1
        if controller.btn_event(BDWN) and cursor_row < max_row:
            self._choice += self._page_w
        elif controller.btn_event(BUPP) and cursor_row > 0:
            self._choice -= self._page_w
        elif controller.btn_event(BLFT) and self._choice > 0:
            self._choice -= 1
        elif controller.btn_event(
                BRGT) and self._choice < len(self._choices) - 1:
            self._choice += 1

        # draw bg
        pview.fill((86, 55, 35))

        # adjust page start if needed
        cursor_row = self._choice // self._page_w
        cursor_col = self._choice % self._page_w
        if cursor_row > self._page_start_row + self._page_h - 1:
            self._page_start_row += 1
        if cursor_row < self._page_start_row:
            self._page_start_row -= 1

        # draw level numbers
        start_choice = self._page_start_row * self._page_w
        end_choice = start_choice + self._page_h * self._page_w
        visible_choices = self._choices[start_choice:end_choice]
        for i, choice in enumerate(visible_choices):
            x = 150 + (i % self._page_w) * 100
            y = 150 + (i // self._page_w) * 100
            ptext.draw(choice[0],
                       T(x, y),
                       fontsize=T(50),
                       color=(185, 122, 87))

        # draw pointer
        x = 115 + cursor_col * 100
        y = 140 + (cursor_row - self._page_start_row) * 100
        ptext.draw('>', T(x, y), fontsize=T(70), color=(0, 162, 232))

        # draw command tips
        ptext.draw('F11: toggle fullscreen\nEsc: quit',
                   T(10, 10),
                   fontsize=T(20),
                   color=(185, 122, 87))

        pg.display.flip()
        return None, {}  # no next scene to return