def handle_key(key):
    """Handles key events in the game"""
    direction = DIRECTIONS.get(key)
    if direction:
        move(maze, direction)
    img = draw_grid(maze, tile_img, tiles)
    display.blit(img, Rect((0, 0, 384, 224)), Rect((0, 0, 384, 224)))
    pygame.display.update()
예제 #2
0
def push_crate_to_wall(direction, retezec):
    """Help function to test push to wall."""
    maze = parse_grid(retezec)
    mazepuv = maze
    move(maze, direction)
    assert maze[0] == mazepuv[0]
예제 #3
0
def move_crate(direction, plr_pos, crate_pos):
    """Help function for testing crate moves."""
    maze = parse_grid(LEVEL)
    move(maze, direction)
    assert maze[plr_pos[0]][plr_pos[1]] == '*'
    assert maze[crate_pos[0]][crate_pos[1]] == 'o'
예제 #4
0
def test_move_player(level, path, expected_x, expected_y):
    """Korektní změna pozice hráče. Více parametrů - path, expected_x, expected_y."""
    for direction in path:
        move(level,direction)
    assert level[expected_y][expected_x] == '*'
예제 #5
0
def test_paths(path, level):
    """Different paths lead to the same spot. Jeden parametr (path)."""
    for direction in path:
        move(level,direction)
    assert level[2][2] == '*'
예제 #6
0
def test_move_crate_back_forth(level):
    """Sanity check: move the top crate twice."""
    for d in [LEFT, UP, RIGHT, UP, RIGHT, RIGHT, DOWN, LEFT, LEFT, LEFT]:
        move(level, d)
    assert level [2] == list('#o*   #')
예제 #7
0
def test_move_crate_to_corner(level):
    """Move tom crate to upper left corner."""
    for d in [UP, RIGHT, UP, LEFT, LEFT, LEFT]:
        move(level, d)
    assert level [1][1] == "o"
예제 #8
0
def test_move_to_none():
    """Direction None generate an Exception."""
    maze = parse_grid(LEVEL)
    with pytest.raises(TypeError):
        move(maze, None)
예제 #9
0
def test_push_crate_to_crate():
    """Test_push_crate_to_crate."""
    maze = parse_grid('*oo')
    move(maze,RIGHT)
    assert maze ==[['*','o','o']]
예제 #10
0
 def test_move_player(self, level, path, expected_x, expected_y):
     """Player position changes correctly"""
     for direction in path:
         move(level, direction)
     assert level[expected_y][expected_x] == '*'
예제 #11
0
 def test_move_to_none(self, level):
     """direction=None generates an Exception"""
     with pytest.raises(TypeError):
         move(level, None)
예제 #12
0
 def test_move_crate_to_corner(self, level):
     """Moves top crate to upper left corner"""
     for d in [UP, RIGHT, UP, LEFT, LEFT, LEFT]:
         move(level, d)
     assert level[1][1] == 'o'
예제 #13
0
 def test_push_crate_to_crate(self):
     maze = parse_grid("*oo")
     move(maze, RIGHT)
     assert maze == [['*', 'o', 'o']]
예제 #14
0
 def test_push_crate_to_wall(self):
     maze = parse_grid("*o#")
     move(maze, RIGHT)
     assert maze[0] == ['*', 'o', '#']
예제 #15
0
 def test_move_crate(self, level, direction, plr_pos, crate_pos):
     """After move player and crate moved by one square"""
     print(direction, plr_pos, crate_pos)
     move(level, direction)
     assert level[plr_pos[0]][plr_pos[1]] == '*'
     assert level[crate_pos[0]][crate_pos[1]] == 'o'