def make_game_full_grid(self): game = Blockies.Game(1) squares = [] for i in range(const.SQ_COLUMNS): for j in range(const.SQ_COLUMNS): squares.append((i, j)) for square in squares: game.grid.set_square( square, Blockies.Piece('square', 1, 1, square, const.BLUE)) return game
def make_basic_game_grid(self): game = Blockies.Game(2) blue_squares = [(0, 0), (1, 1), (2, 2)] green_squares = [(9, 9), (8, 8), (7, 7)] for square in blue_squares: game.grid.set_square( square, Blockies.Piece('square', 1, 1, square, const.BLUE)) for square in green_squares: game.grid.set_square( square, Blockies.Piece('square', 1, 1, square, const.GREEN)) return game
def test_square_from_pos(self): # init constants with 2 person game Blockies.Game(2) test_values = { (0, 0): (0, 0), (0, 0): (-57, -57), (0, 0): (-57, 57), (0, 0): (3, 57), (0, 0): (57, 57), (0, 0): (57, 3), (1, 0): (83, 57), (2, 3): (163, 240), } for square, point in test_values.items(): self.assertEqual( square, Blockies.square_from_pos(point), 'point in wrong square: {} on a {} square size grid'.format( point, const.SQ_SIZE))
if event.type == pygame.QUIT: # User clicked close quit(0) elif event.type == pygame.KEYDOWN: if pygame.key.get_pressed()[pygame.K_1]: num_players = 1 elif pygame.key.get_pressed()[pygame.K_2]: num_players = 2 elif pygame.key.get_pressed()[pygame.K_3]: num_players = 3 elif pygame.key.get_pressed()[pygame.K_4]: num_players = 4 elif pygame.key.get_pressed()[pygame.K_q]: quit(0) else: continue game = Blockies.Game(num_players) screen.fill((0, 0, 0)) total_height = begin_title.get_height() + begin_prompt.get_height() screen.blit(begin_title, ((const.SCREEN_SIZE / 2) - begin_title.get_width() // 2, begin_title.get_height())) screen.blit(begin_prompt, ((const.SCREEN_SIZE / 2) - begin_prompt.get_width() // 2, (const.SCREEN_SIZE / 2) + 25 - total_height // 2)) screen.blit(quit_prompt, ((const.SCREEN_SIZE / 2) - quit_prompt.get_width() // 2, (const.SCREEN_SIZE / 2) + 100 - total_height // 2))
def make_empty_game_grid(self): return Blockies.Game(2)