Пример #1
0
    def tick(self):
        now = millis()

        self.update_info_frame()
        # check if frame-update
        if self._animations:
            if not self._paused:
                self._sub_turn = max(0.0, (now - self._t_frame_start) /
                                     self._slider_delay)
                if self._turn >= settings.max_turns:
                    self.toggle_pause()
                    self._turn = settings.max_turns
                if self._sub_turn >= 1:
                    self._sub_turn -= 1
                    self._turn += 1
                    self.update_frame_start_time(self._t_next_frame)
                    self.turn_changed()
            subframe_t = ((now - self._t_cursor_start) %
                          render_settings.rate_cursor_blink)
            subframe_hlt = subframe_t / render_settings.rate_cursor_blink
            self.paint(self._sub_turn, subframe_hlt)
        elif now > self._t_next_frame and not self._paused:
            self._turn += 1
            self.update_frame_start_time(self._t_next_frame)
            self.turn_changed()
            self.paint()

        self.update_block_size()
Пример #2
0
    def tick(self):
        now = millis()

        self.update_info_frame()
        # check if frame-update
        if self._animations:
            if not self._paused:
                self._sub_turn = max(0.0, (now - self._t_frame_start) /
                                     self._slider_delay)
                if self._turn >= settings.max_turns:
                    self.toggle_pause()
                    self._turn = settings.max_turns
                if self._sub_turn >= 1:
                    self._sub_turn -= 1
                    self._turn += 1
                    self.update_frame_start_time(self._t_next_frame)
                    self.turn_changed()
            subframe_t = ((now - self._t_cursor_start) %
                          render_settings.rate_cursor_blink)
            subframe_hlt = subframe_t / render_settings.rate_cursor_blink
            self.paint(self._sub_turn, subframe_hlt)
        elif now > self._t_next_frame and not self._paused:
            self._turn += 1
            self.update_frame_start_time(self._t_next_frame)
            self.turn_changed()
            self.paint()

        self.update_block_size()
Пример #3
0
 def toggle_pause(self):
     self._paused = not self._paused
     # Print "paused" if self._paused else "unpaused".
     self._toggle_button.config(text='\u25B6' if self._paused else '\u25FC')
     now = millis()
     if self._paused:
         self._sub_turn = 0.0
     else:
         self.update_frame_start_time(now)
Пример #4
0
 def toggle_pause(self):
     self._paused = not self._paused
     # Print "paused" if self._paused else "unpaused".
     self._toggle_button.config(
         text=u'\u25B6' if self._paused else u'\u25FC')
     now = millis()
     if self._paused:
         self._sub_turn = 0.0
     else:
         self.update_frame_start_time(now)
Пример #5
0
 def onclick(event):
     x = (event.x - self.board_margin // 2) // self._blocksize
     y = (event.y - self.board_margin // 2) // self._blocksize
     loc = (x, y)
     if (0 <= x < settings.board_size and 0 <= y < settings.board_size):
         if loc == self._highlighted:
             self._highlighted = None
         else:
             self._highlighted = loc
         action = self._game.get_actions_on_turn(
             self.current_turn_int()).get(loc)
         if action is not None:
             self._highlighted_target = action.get("target", None)
         else:
             self._highlighted_target = None
         self.update_highlight_sprite(True)
         self.update_info_frame()
         self._t_cursor_start = millis()
Пример #6
0
 def onclick(event):
     x = (event.x - self.board_margin // 2) // self._blocksize
     y = (event.y - self.board_margin // 2) // self._blocksize
     loc = (x, y)
     if (0 <= x < settings.board_size and
             0 <= y < settings.board_size):
         if loc == self._highlighted:
             self._highlighted = None
         else:
             self._highlighted = loc
         action = self._game.get_actions_on_turn(
             self.current_turn_int()).get(loc)
         if action is not None:
             self._highlighted_target = action.get("target", None)
         else:
             self._highlighted_target = None
         self.update_highlight_sprite(True)
         self.update_info_frame()
         self._t_cursor_start = millis()
Пример #7
0
    def update_frame_start_time(self, tstart=None):
        tstart = tstart or millis()
        self._t_frame_start = tstart

        self._t_next_frame = tstart + self._slider_delay
Пример #8
0
    def update_frame_start_time(self, tstart=None):
        tstart = tstart or millis()
        self._t_frame_start = tstart

        self._t_next_frame = tstart + self._slider_delay