Beispiel #1
0
 def __init__(self, engine):
     super(Screen, self).__init__()
     
     # Handles
     self.engine = engine
     self.size = engine.screen_size
     self.fullscreen = engine.fullscreen
     
     # Empty holders
     self.image_cache = {}
     self.state = [[-1 for x in range(9)] for x in range(9)]
     
     # This is the title drawn at the top of the window
     self.name = "Tic Tac Toe"
     
     # FPS
     self._next_redraw = time.time()
     self._redraw_delay = ttt_screen_lib.set_fps(self, 30)
     
     # CPS
     self._next_update = time.time()
     self._update_delay = ttt_screen_lib.set_fps(self, 30)
     
     # Saved variables
     self.mouse_is_down = False
     self.keys_down = {}
     self.mouse = [0,0]
     self.mouse_down_at = [0,0]
     
     self.scroll_x, self.scroll_y = 0, 0# Current location scrolled to
     
     # If image == None the colour is used instead
     self.background_colour  = (200, 200, 200)# Default to a grey background
     
     # Used for working out double click stuff
     self._last_mouseup = [None, -1]
     self._double_click_interval = 0.25
     
     # Transition stuff
     self.transition = None
     self.transition_frame = -1
     self.on_transition = None
     self.on_transition_args = None
     self.on_transition_kwargs = None
     
     if self.fullscreen:
         self.switch_to_fullscreen()
Beispiel #2
0
    def __init__(self, *args, **kwargs):
        Server.__init__(self, *args, **kwargs)

        # Game state
        self.state = [[-1 for x in range(9)] for x in range(9)]
        self.board = Board(boardsize=9)  # FIXME
        self.turn = 0

        self.users = {}  # maps user names to Chat instances

        self.timeout = 0
        self.running = True

        self.players = []

        self._next_update = time.time()
        self._update_delay = ttt_screen_lib.set_fps(self, 30)

        self.address, self.port = kwargs["localaddr"]
        print("Server started at {} at port {}".format(self.address, str(self.port)))