May 24th, 2008
May 24th, 2008
In our last tutorial, we added some user input. Let’s make use of that input by adding more grids to our game.
Let’s start by making the screen longer:
window = pygame.display.set_mode((400, 600))
This makes the screen 2 times as tall as it was before.
Now let’s make the grid longer:
grid = [
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' '],
[' ', ' ', ' ', ' ', ' ']
]
This makes our grid 5 columns wide and 15 rows long.
Now we’re going to add some more stuff to our game. Add these grids just below the main grid. Now you’ll finally see what kind of game you’re actually working on:
tetro_o = [ ['x', 'x'], ['x', 'x'], ] tetro_i = [ ['x'], ['x'], ['x'], ['x'] ] tetro_s = [ [' ', 'x', 'x'], ['x', 'x', ' '] ] tetro_z = [ ['x', 'x', ' '], [' ', 'x', 'x'] ] tetro_l = [ ['x', ' ', ' '], ['x', 'x', 'x'] ] tetro_j = [ [' ', ' ', 'x'], ['x', 'x', 'x'] ] tetro_t = [ [' ', 'x', ' '], ['x', 'x', 'x'] ]
These are the standard tetrominoes (rhymes with dominoes) for the game Tetris.
The next tutorial will cover drawing our new grids.