def __init__(self, downstream_game): super(GameScreen, self).__init__(downstream_game, dimensions=downstream_game.screen_size, fullscreen=downstream_game.fullscreen ) self._next_update = time.time() self._update_delay = screen_lib.set_fps(self, 30) self.background = (0,0,0) self.network = None self.controls["network_map"] = network_map.NetworkMap( size = (300, 300), position = (10, 10), network = self.network, screen = self, ) self.controls["player_job_list"] = job_list.JobList( size = (300, downstream_game.screen_size[1]/2-20), position = (downstream_game.screen_size[0] - 310, 10), fill_colour = (50,50,50), text_colour = (255, 255, 255), network = self.network, screen = self, source = "Player0", ) self.controls["node_job_list"] = job_list.JobList( size = (300, downstream_game.screen_size[1]/2-10), position = (downstream_game.screen_size[0] - 310, downstream_game.screen_size[1]/2), fill_colour = (50,50,50), text_colour = (255, 255, 255), network = self.network, screen = self, source = "Node", ) self.controls["node_info"] = node_info.NodeInfo( size = (300, 390), position = (10, 320), fill_colour = (50,50,50), selected_colour = (50, 50, 100), text_colour = (255, 255, 255), network = self.network, screen = self, ) self.tick = 0 self.player = ""
def __init__(self, engine): super(BattleScreen, self).__init__(engine) self.image_cache = {} # Defaults to drawing to the screen sizes, this gets overriden later # it's used to work out what size rectangle to draw to for the # battlefield (so taking into account panels and menus) self.draw_area = (0, 0, engine.window_width, engine.window_height) # The margins that are used for things like menus and panels, we don't # want to draw battlefield stuff to these self.draw_margin = [0, 0] self.background_image = pygame.Surface((1,1)) self.background = pygame.Surface((1,1)) self.selected_actors = [] self._next_redraw = time.time() self._redraw_delay = 0 screen_lib.set_fps(self, 40) self.terrain = {} self.bullets = [] self.effects = [] self.place_image = None self.panels = {} self.redraw_count = [0, 0] self._current_actor_id = 0 # This is switched instead of a function call because it's possible # that we may alter the selection several times in a row and it would # be a waste to rebuild menus several times self._selection_has_changed = False
def __init__(self, engine): super(BattleScreen, self).__init__(engine) self.image_cache = {} # Defaults to drawing to the screen sizes, this gets overriden later # it's used to work out what size rectangle to draw to for the # battlefield (so taking into account panels and menus) self.draw_area = (0, 0, engine.window_width, engine.window_height) # The margins that are used for things like menus and panels, we don't # want to draw battlefield stuff to these self.draw_margin = [0, 0] self.background_image = pygame.Surface((1, 1)) self.background = pygame.Surface((1, 1)) self.selected_actors = [] self._next_redraw = time.time() self._redraw_delay = 0 screen_lib.set_fps(self, 40) self.terrain = {} self.bullets = [] self.effects = [] self.place_image = None self.panels = {} self.redraw_count = [0, 0] self._current_actor_id = 0 # This is switched instead of a function call because it's possible # that we may alter the selection several times in a row and it would # be a waste to rebuild menus several times self._selection_has_changed = False
def __init__(self, engine, dimensions, fullscreen=False): super(Screen, self).__init__() self.fullscreen = fullscreen if dimensions == None: self.fullscreen = True self.actors = {} self.controls = {} self.name = "" self.engine = engine self.size = dimensions # FPS self._next_redraw = time.time() self._redraw_delay = screen_lib.set_fps(self, 30) self.image_cache = {} self.mouse_is_down = False self.keys_down = {} self.scroll_x, self.scroll_y = 0, 0 self.mouse = [0,0] self.mouse_down_at = [0,0] self.background_image = None self.background = (200, 200, 200)# Default to a grey background self.surf = pygame.Surface(dimensions) if self.fullscreen: self.switch_to_fullscreen() self._last_mouseup = [None, -1] self._double_click_interval = 0.25 self.transition = None self.transition_frame = -1 self.on_transition = None self.on_transition_args = None self.on_transition_kwargs = None
def __init__(self, engine): super(BattleIO, self).__init__((engine.window_width, engine.window_height)) # Used to translate key pushes into orders (e.g. M for move) # Note: These are the keyboard locations, not the letters # it will work with the same buttons (not letters) on a Dvorak as # it will on a Qwerty self.hotkeys = { K_m: "move", K_s: "stop", K_a: "attack", # K_a: "aid", K_h: "hold", K_p: "patrol", K_b: "build", 53: "unselect"# 53 = esc } # Used to modify the order given when the mouse it clicked self.key_mod = None self.have_scrolled = False self.scroll_speed = 15 self.scroll_up_key = K_UP self.scroll_down_key = K_DOWN self.scroll_right_key = K_RIGHT self.scroll_left_key = K_LEFT self.allow_mouse_scroll = False # Defines how far we can scroll in any direction self.scroll_boundaries = (-100, -100, 0, 0) # Ctrl + N to assign, N to select self.control_groups = {} for i in NUMBERS: self.control_groups[i] = [] self.scroll_boundary = 100 self.drag_rect = None self._next_redraw = time.time() self._redraw_delay = 0 screen_lib.set_fps(self, 40) # Used to store orders for X steps later # http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php self.orders = {} self.q_orders = {}# Orders that get added to the actor's order queue self.tick = 0 self.tick_jump = 3 for i in range(self.tick_jump+1): self.orders[i] = [] self.q_orders[i] = [] self.mouseup_callback = None self.mouseup_callback_args = [] self.next_scroll = 0 self.scroll_delay = 0.01 # This is switched instead of a function call because it's possible # that we may alter the selection several times in a row and it would # be a waste to rebuild menus several times self._selection_has_changed = False
def __init__(self, engine): super(BattleIO, self).__init__( (engine.window_width, engine.window_height)) # Used to translate key pushes into orders (e.g. M for move) # Note: These are the keyboard locations, not the letters # it will work with the same buttons (not letters) on a Dvorak as # it will on a Qwerty self.hotkeys = { K_m: "move", K_s: "stop", K_a: "attack", # K_a: "aid", K_h: "hold", K_p: "patrol", K_b: "build", 53: "unselect" # 53 = esc } # Used to modify the order given when the mouse it clicked self.key_mod = None self.have_scrolled = False self.scroll_speed = 15 self.scroll_up_key = K_UP self.scroll_down_key = K_DOWN self.scroll_right_key = K_RIGHT self.scroll_left_key = K_LEFT self.allow_mouse_scroll = False # Defines how far we can scroll in any direction self.scroll_boundaries = (-100, -100, 0, 0) # Ctrl + N to assign, N to select self.control_groups = {} for i in NUMBERS: self.control_groups[i] = [] self.scroll_boundary = 100 self.drag_rect = None self._next_redraw = time.time() self._redraw_delay = 0 screen_lib.set_fps(self, 40) # Used to store orders for X steps later # http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php self.orders = {} self.q_orders = {} # Orders that get added to the actor's order queue self.tick = 0 self.tick_jump = 3 for i in range(self.tick_jump + 1): self.orders[i] = [] self.q_orders[i] = [] self.mouseup_callback = None self.mouseup_callback_args = [] self.next_scroll = 0 self.scroll_delay = 0.01 # This is switched instead of a function call because it's possible # that we may alter the selection several times in a row and it would # be a waste to rebuild menus several times self._selection_has_changed = False
def __init__(self, engine): super(BattleScreen, self).__init__((engine.window_width, engine.window_height)) # Used to translate key pushes into orders (e.g. M for move) # Note: These are the keyboard locations, not the letters # it will work with the same buttons (not letters) on a Dvorak as # it will on a Qwerty self.hotkeys = { K_m: "move", K_s: "stop", K_a: "attack", K_a: "defend", K_h: "hold", K_p: "patrol", K_b: "build", } # Used to modify the order given when the mouse it clicked self.key_mod = None # Defaults to drawing to the screen sizes, this gets overriden later # it's used to work out what size rectangle to draw to for the # battlefield (so taking into account panels and menus) self.draw_area = (0, 0, engine.window_width, engine.window_height) # The margins that are used for things like menus and panels, we don't # want to draw battlefield stuff to these self.draw_margin = [0, 0] self.background_image = pygame.Surface((1,1)) self.background = pygame.Surface((1,1)) self.have_scrolled = False self.scroll_speed = 15 self.scroll_up_key = K_UP self.scroll_down_key = K_DOWN self.scroll_right_key = K_RIGHT self.scroll_left_key = K_LEFT self.allow_mouse_scroll = False # Defines how far we can scroll in any direction self.scroll_boundaries = (-100, -100, 0, 0) # Ctrl + N to assign, N to select self.control_groups = {} for i in NUMBERS: self.control_groups[i] = [] self.scroll_boundary = 100 self.selected_actors = [] self.drag_rect = None self._next_redraw = time.time() self._redraw_delay = 0 screen_lib.set_fps(self, 40) self.terrain = {} self.bullets = [] self.effects = [] # Used to store orders for X steps later # http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php self.orders = {} self.q_orders = {}# Orders that get added to the actor's order queue self.tick = 0 self.tick_jump = 3 for i in range(self.tick_jump+1): self.orders[i] = [] self.q_orders[i] = [] self.place_image = None self.mouseup_callback = None self.mouseup_callback_args = [] self.panels = {} self.redraw_count = [0, 0] self.next_scroll = 0 self.scroll_delay = 0.01 self._current_actor_id = 0 # This is switched instead of a function call because it's possible # that we may alter the selection several times in a row and it would # be a waste to rebuild menus several times self._selection_has_changed = False