Example #1
0
    def __init__(self, screen_rect, bg_color):
        """
        Initialize the display.
        screen_rect: the bounds of the screen
        bg_color: the background color
        """
        LayeredUpdates.__init__(self)
        
        if GUI.num_instances != 0:
            raise Exception("GUI: can only have one instance of a simulation")
        GUI.num_instances = 1
        
        # Set up the screen
        self.screen = pygame.display.set_mode((screen_rect.w, screen_rect.h))
        self.screen_rect = screen_rect
        
        # The rect containing the info bar
        self.bar_rect = pygame.Rect(screen_rect.w - BAR_WIDTH,
                                     0,
                                     BAR_WIDTH,
                                     screen_rect.h)
        
        # The rect containing the map view
        self.view_rect = pygame.Rect(0,
                                      0,
                                      MAP_WIDTH,
                                      screen_rect.h)
        self.bg_color = bg_color
        self.map = None

        # Set up team information
        self.num_teams = None
        self.current_turn = 0
        self.win_team = None 

        # The currently selected unit
        self.sel_unit = None
        
        # Set up GUI
        self.buttons = [
            Button(0, "MOVE", self.move_pressed, self.can_move),
            Button(1, "ATTACK", self.attack_pressed, self.can_attack),
            Button(2, "END TURN", self.end_turn_pressed, None),
            Button(3, "HEAL", self.heal_pressed, self.can_heal)]
        
        # We start in select mode
        self.mode = Modes.Select
        
        # Tiles we can move to/attack
        self._movable_tiles = set()
        self._attackable_tiles = set()

        # The targeting reticle
        self._reticle = animation.Animation("assets/reticle.png",
                                             20,
                                             20,
                                             RETICLE_RATE)
        
        # This will store effects which are drawn over everything else
        self._effects = pygame.sprite.Group()
    def __init__(self,
                 manager: UIManager,
                 width: int,
                 height: int,
                 background: Tuple[int, int, int],
                 title: str = '',
                 title_color: Tuple[int, int, int] = (0, 0, 0),
                 title_size: int = None,
                 content: str = '',
                 content_font_color: Tuple[int, int, int] = (0, 0, 0),
                 content_font_size: int = None,
                 show: bool = True):
        if height < 200:
            raise Exception('The height of UI Dialog must be larger than 200')
        if width < 200:
            raise Exception('The width of UI Dialog must be larger than 200')

        self.show = show

        # initialize components inside the UI Dialog
        self.background = UIDialogBackground(width, height, background, title,
                                             title_color, title_size, content,
                                             content_font_color,
                                             content_font_size)
        top, right = self.background.rect.topright
        self.close_button = UIDialogButton(top - UIDialogButton.BUTTON_WIDTH,
                                           right)
        LayeredUpdates.__init__(self, [self.background, self.close_button])
        UIComponent.__init__(self, manager)
    def __init__(self, *sprites):
        """initialize group.

        """
        LayeredUpdates.__init__(self, *sprites)
        self._clip = None
        self.visible = []
        self.should_update_visibility = True
Example #4
0
    def __init__(self):
        LayeredUpdates.__init__(self)
        self.started = False

        self.bg = pygame.image.load("maps/trylane.png")

        self.p0_paths = [[(0, 300), (400, 150), (700, 50), (791, 300)]]
        self.p1_paths = [[(791, 300), (400, 150), (0, 300)]]

        self.p0_units = []
        self.p1_units = []

        self.p0_sel_type = 0
        self.p1_sel_type = 0
Example #5
0
 def __init__(self, map):
     LayeredUpdates.__init__(self)
     self.Group_Players = None
     self.Group_HumainPlayers = None
     self.Group_ComputerPlayers = None
     self.Group_Grids_move_area = None
     self.Group_Grids_attack_area = None
     self.someone_selected = False
     self.selected_one = None
     self.Group_for_infoPanel = None
     self.AI_moving = 0
     map_width = map.get_width() // st.Game_Attr.INTERVAL.value
     map_heighth = map.get_height() // st.Game_Attr.INTERVAL.value
     weightedMap = numpy.ones((map_heighth,map_width))
     self.weightedMap = weightedMap
     self.map = map
Example #6
0
    def __init__(self, screen_rect, bg_color):
        """
        Initialize the display.
        screen_rect: the bounds of the screen
        bg_color: the background color
        """
        LayeredUpdates.__init__(self)

        if GUI.num_instances != 0:
            raise Exception("GUI: can only have one instance of a simulation")
        GUI.num_instances = 1

        # Set up the screen
        self.screen = pygame.display.set_mode((screen_rect.w, screen_rect.h))
        self.screen_rect = screen_rect

        # The rect containing the info bar
        self.bar_rect = pygame.Rect(screen_rect.w - BAR_WIDTH, 0, BAR_WIDTH,
                                    screen_rect.h)

        # The rect containing the map view
        self.view_rect = pygame.Rect(0, 0, MAP_WIDTH, screen_rect.h)
        self.bg_color = bg_color
        self.map = None

        # Set up team information
        self.num_teams = None
        self.current_team = 0
        self.win_team = None

        # The currently selected unit
        self.sel_unit = None
        self.moveable_tiles = []

        # Haven't determined who goes first yet.
        self.select_state = False

        # Set up GUI
        self.buttons = [
            Button(0, "Heads", self.HeadsPressed, self.can_choose),
            Button(1, "Tails", self.TailsPressed, self.can_choose),
            Button(2, "Choose Below", self.Simulation_pressed, None),
            Button(3, "EndTurn", self.end_turn_processed, None)
        ]

        # We start in select mode
        self.mode = Modes.Select
    def __init__(self):
        # Initalizes layered updates in the GUI to render all the images properly
        LayeredUpdates.__init__(self)

        # Error checking if you attempt to load multiple GUIs at once
        if GUI.instance_num != 0:
            raise Exception("Can only have one Zombie Survival Game up at a time.")
        GUI.instance_num = 1
	
        # Game properties selected by the GUI in reference to the game levels
        self.sel_level = None
        self.sel_unit = None 
        self.sel_tile = None 
        self.sel_event = None
        self.sel_gamestate = GameStage.Exploration
        
        # Initiate mapping
        self.current_node = None        
        level = 'level1'
        self.map = MAP("maps/" + level + ".txt")
Example #8
0
    def __init__(self, screen_rect, bg_color):
        """
        Set up the GUI and attach the view switch listener.
        """
        LayeredUpdates.__init__(self)

        if GUI.num_instances != 0:
            raise AssertionError("GUI: can only have one instance of a simulation")
        GUI.num_instances = 1

        self.screen = pygame.display.set_mode((screen_rect.w,
                                              screen_rect.h))
        self.bg_color = bg_color

        # The current view
        self.current_view = None
        
        # Attach the listeners
        EventManager.listener(EVENT_CHANGE_VIEW,
                              lambda event: self.switch_view(event.view))
        
        EventManager.listener(pygame.MOUSEBUTTONUP,
                              self.on_click)
Example #9
0
 def __init__(self):
     LayeredUpdates.__init__(self)
Example #10
0
 def __init__(self, *sprites):
     LayeredUpdates.__init__(self, *sprites)
     self.__dict = dict()
Example #11
0
 def __init__(self):
     LayeredUpdates.__init__(self)
Example #12
0
 def __init__(self, camera_scroll, *sprites):
     ScrollAdjustedGroup.__init__(self, camera_scroll)
     LayeredUpdates.__init__(self, *sprites)