def __init__(self, x1, y1, w, h, dal): """ Constructor - passes dimension of screen size. Parameters: x1 - x - coord y1 - y - coord w - width h - height """ self._dal = dal self._screen_size = Rect(x1, y1, w, h) self._facade = Facade.facade_layer() self.checked_out = False # RGB Colors for the colours we are using self.BLACK = ( 0, 0, 0) self.WHITE = (255, 255, 255) self.BLUE = ( 0, 0, 255) self.GREEN = ( 0, 255, 0) self.RED = (255, 0, 0) self.YELLOW = (250, 167, 74) self.PURPLE = (242, 102, 230) self.OTHER = (240,204,7)
def __init__(self, x1, y1, w, h, dal, profile_mode=False): """ Constructor - passes dimension of screen size. Parameters: x1 - x - coord y1 - y - coord w - width h - height """ self._profile_mode = profile_mode self._dal = dal self._yellow = (250, 167, 74) self._red = (255, 0, 0) self._form = [] self._validation_messages = [] self._form_index = 0 self._text_color = (22, 22, 54) self._username = None self._password = None self._forename = None self._surname = None self._email = None self._confirm = None self._screen_size = Rect(x1, y1, w, h) self._facade = Facade.facade_layer() self._submit_button = Rect(443, 904, 176, 47) self._cancel_button = Rect(683, 906, 187, 46)
def __init__(self): """ default constructor """ self._login_color = 0, 0, 0 self._register_color = 0, 0, 0 self._quit_color = 0, 0, 0 self._help_color = 0, 0, 0 self._x = 0 self._y = 0 self._selected_option = "" self._file = "MenuPointer.png" self._main_dir = os.path.split(os.path.abspath(__file__))[0] self._file = os.path.join(self._main_dir, 'images', self._file) self._login_link = Rect(78, 366, 243, 134) self._register_link = Rect(62, 554, 451, 109) self._quit_link = Rect(80, 724, 205, 147) self._help_link = Rect(80, 824, 205, 147) self._image = pygame.image.load(self._file).convert_alpha() # Fetch the rectangle object that has the dimensions of the image. self._rect = self._image.get_rect() self._width = self._rect.width self._height = self._rect.height self._move_to_login() self._facade = Facade.facade_layer() self._help_processed = False
def __init__(self, screen, dal): """ default constructor """ self._screen = screen self._dal = dal self._facade = Facade.facade_layer() #### PROFILE BUTTON STATES self._btn_profile_mouseover = self._facade.loadImage( "your_profile_white_mouseover.png") self._btn_profile_normal = self._facade.loadImage( "your_profile_white_normal.png") self._btn_profile_selected = self._facade.loadImage( "Your Profile_mousedown.png") #### LEAST HITS BUTTON STATES self._btn_least_hits_mouseover = self._facade.loadImage( "least_hits_mouseover.png") self._btn_least_hits_normal = self._facade.loadImage( "least_hits_normal.png") self._btn_least_hits_selected = self._facade.loadImage( "least_hits_mousedown.png") #### LEAST TIME BUTTON STATES self._btn_least_time_mouseover = self._facade.loadImage( "least time_mouseover.png") self._btn_least_time_normal = self._facade.loadImage( "least time_normal.png") self._btn_least_time_selected = self._facade.loadImage( "least time_mousedown.png") #### MOST WINS BUTTON STATES self._btn_most_wins_mouseover = self._facade.loadImage( "most wins_mouseover.png") self._btn_most_wins_normal = self._facade.loadImage( "most wins_normal.png") self._btn_most_wins_selected = self._facade.loadImage( "most wins_mousedown.png") #### EXIT BUTTON STATES self._btn_exit_mouseover = self._facade.loadImage("exit_mouseover.png") self._btn_exit_normal = self._facade.loadImage("exit_normal.png") self._btn_exit_selected = self._facade.loadImage("exit_mousedown.png") #### TABLE and YOUR PROFILE self._table = self._facade.loadImage("table.png") self._your_profile_screen = self._facade.loadImage("your_profile.png") self._your_profile = Rect(0, 198, 322, 124) self._least_hits = Rect(0, 344, 322, 124) self._least_time = Rect(0, 480, 322, 124) self._most_wins = Rect(0, 618, 322, 124) self._exit = Rect(0, 738, 322, 124) self._your_profile_rect = Rect(378, 241, 863, 449) self._table_rect = Rect(347, 334, 904, 503) self._current_button = MenuOptionButton.LEAST_TIME self._current_selected = MenuOptionButton.YOUR_PROFILE
def __init__(self, x1, y1, w, h): """ Constructor - passes dimension of screen size. Parameters: x1 - x - coord y1 - y - coord w - width h - height """ self._screen_size = Rect(x1, y1, w, h) self._facade = Facade.facade_layer()
def __init__(self, x1, y1, w, h, dal): """ Constructor - passes dimension of screen size. Parameters: x1 - x - coord y1 - y - coord w - width h - height """ self._dal = dal self._screen_size = Rect(x1, y1, w, h) self._facade = Facade.facade_layer() self._play_button = Rect(426, 656, 207, 58) self._quit_button = Rect(686, 662, 207, 58)
def __init__(self, x1, y1, w, h, dal): """ Constructor - passes dimension of screen size. Parameters: x1 - x - coord y1 - y - coord w - width h - height """ self._dal = dal self._screen_size = Rect(x1, y1, w, h) self._facade = Facade.facade_layer() # MORE CONSTANTS self.YELLOW = (250, 167, 74) self.WHITE = (255, 255, 255) self.GREEN = (0, 255, 0)
def __init__(self, screen, dal): #CONSTANTS self._BLACK = (0, 0, 0) self._WHITE = (255, 255, 255) self._BLUE = (0, 0, 255) self._GREEN = (0, 255, 0) self._RED = (255, 0, 0) self._YELLOW = (250, 167, 74) self._PURPLE = (242, 102, 230) self._OTHER = (240, 204, 7) self._COORD_COLOR = (170, 240, 114) self._X_AXIS_RANGE = 14 # number of squares across self._Y_AXIS_RANGE = 12 # number of squares down self.BOARD_WIDTH = 14 self.BOARD_HEIGHT = 12 # Class Instance Variables self._screen = screen self._origin_x = randint(0, 13) self._origin_y = randint(0, 12) self._pixels_per_column = 50 self.x_axis_labels = list(range( -20, 40)) # create an array prefilled with numbers from -20 to 59 self.y_axis_labels = list(range( -20, 40)) # create an array prefilled with numbers from -20 to 59 # I know that the 20th Element is a zero i.e. the origin of the coordinate axis # These are now the starting points for documenting the axes self.x_axis_starting_point = 20 - self._origin_x self.y_axis_starting_point = 20 - self._origin_y # Create the facade layer so we can draw the labels to screen changed self._facade = Facade.facade_layer() self._dal = dal self._hit_image = self._facade.loadImage('explosion.png') self._miss_image = self._facade.loadImage('explosion_miss.png') self.crossing_out = self._facade.loadImage('crossout.png') self.next_button = self._facade.loadImage('next.png') self._easter_egg = False
def __init__(self, x1, y1, w, h, dal, player=1): """This is the constructor for the class: - parameters :param x1: x pos of screen definition :param y1: y pos of screen deinition :param w: width of screen :param h: height of screen :param dal: a reference to the Data Access Object :param player: which player the screen is for player 1 or 2 - type of parameters :type x1: int :type y1: int :type w: int :type h: int :type dal: DataAccess Object :type player: int - return :return: none since its a constructor - return type :rtype: not applicable """ self._dal = dal self._form = [] self._form_index = 0 self._text_color = (22, 22, 54) self._username = None self._password = None self._screen_size = Rect(x1, y1, w, h) self._player = player self._facade = Facade.facade_layer() self._submit_button = Rect(426, 656, 207, 58) self._cancel_button = Rect(686, 662, 207, 58)
def __init__(self): self._dal = DataAccessLayer.DataAccessLayer() self._facade = Facade.facade_layer()
def __init__(self, player_pos): #CONSTANTS self._VERTICAL = 0 self._HORIZONTAL = 1 self.SQUARE_HIT = 'K' self.SQUARE_MISS = 'M' # these are the sizes or number of squares that the ships will take up self.BATTLESHIP_SIZE = 4 self.CARRIER_SIZE = 5 self.CRUISER_SIZE = 3 self.SUBMARINE_SIZE = 4 self.DESTROYER_SIZE = 2 # This is the reference used for each ship type self.BATTLESHIP_NAME = 'B' self.CARRIER_NAME = 'C' self.CRUISER_NAME = 'R' self.SUBMARINE_NAME = 'S' self.DESTROYER_NAME = 'D' self.BOARD_WIDTH = 14 self.BOARD_HEIGHT = 12 # RGB Colors for the colours we are using self.BLACK = (0, 0, 0) self.WHITE = (255, 255, 255) self.BLUE = (0, 0, 255) self.GREEN = (0, 255, 0) self.RED = (255, 0, 0) self.YELLOW = (250, 167, 74) self.PURPLE = (242, 102, 230) self.OTHER = (240, 204, 7) ############################# self._player_position = player_pos # This defines each square of the board as 50 x 50 self._pixels_per_column = 50 # This is the 2 dimensional array used for the board self._board = [['_' for x in range(self.BOARD_WIDTH)] for y in range(self.BOARD_HEIGHT)] self._facade = Facade.facade_layer() # call this private member to setup the board and allocate the ships at startup self._allocate_board(self._board) # set aside the initial lives of ships and use these to keep track of whether they exist or are sunk self._battleship_lives = 4 self._carrier_lives = 5 self._cruiser_lives = 3 self._submarine_lives = 4 self._destroyer_lives = 2 ### set these intiall to -1 to indicate we have not yet had a shot self._last_shot_row = -1 self._last_shot_col = -1 self._number_of_shots_taken = 0
def __init__(self): """ default constructor """ self._PLAYER2 = 2 self._login_color = 255, 0, 0 self._facade = Facade.facade_layer() self._btn_simulation_off = self._facade.loadImage( "simulation_button_off.png") self._btn_simulation_on = self._facade.loadImage( "simulation_button_on.png") self._btn_simulation_pos = Rect(26, 140, 322, 72) self._btn_opponent_off = self._facade.loadImage( "opponent_button_off.png") self._btn_opponent_on = self._facade.loadImage( "opponent_button_on.png") self._btn_opponent_pos = Rect(26, 240, 322, 72) self._btn_profile_off = self._facade.loadImage( "profile_button_off.png") self._btn_profile_on = self._facade.loadImage("profile_button_on.png") self._btn_profile_pos = Rect(26, 340, 322, 72) self._btn_ships_log_off = self._facade.loadImage( "ships_log_button_off.png") self._btn_ships_log_on = self._facade.loadImage( "ships_log_button_on.png") self._btn_ships_log_pos = Rect(26, 440, 322, 72) self._btn_help_off = self._facade.loadImage("help_button_off.png") self._btn_help_on = self._facade.loadImage("help_button_on.png") self._btn_help_pos = Rect(26, 540, 540, 72) self._btn_quit_off = self._facade.loadImage("quit_button_off.png") self._btn_quit_on = self._facade.loadImage("quit_button_on.png") self._btn_quit_pos = Rect(26, 915, 322, 72) self._instruction_box_simulation = self._facade.loadImage( "instructions_box_simulation.png") self._instruction_box_ships_log = self._facade.loadImage( "instructions_box_ships_log.png") self._instruction_box_opponent = self._facade.loadImage( "instructions_box_opponent.png") self._instruction_box_profile = self._facade.loadImage( "instructions_box_profile.png") self._instruction_box_help = self._facade.loadImage( "instructions_box_help.png") self._play_button = self._facade.loadImage("play_button.png") self._login_button = self._facade.loadImage("login_button.png") self._edit_button = self._facade.loadImage("edit_button.png") self._play_button_pos = Rect(950, 875, 198, 63) self._login_button_pos = Rect(436, 875, 198, 63) self._instruction_box_pos = Rect(436, 32, 804, 422) self._edit_button_pos = Rect(436, 875, 198, 63) self._current_button = Button.SIMULATION self._current_selected = Button.SIMULATION self._screen_size = Rect( 0, 0, 1280, 1024, )