Changeset View
Changeset View
Standalone View
Standalone View
scripts/breakout.py
| Show First 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | for y in range(height + 2): | ||||
| grid[y][0] = grid[y][-1] = wall | grid[y][0] = grid[y][-1] = wall | ||||
| ship = Ship(width / 2, height - 5) | ship = Ship(width / 2, height - 5) | ||||
| entities.append(ship) | entities.append(ship) | ||||
| colors = [ 1, 3, 2, 6, 4, 5 ] | colors = [ 1, 3, 2, 6, 4, 5 ] | ||||
| h = height / 10 | h = height / 10 | ||||
| for x in range(1, width / 7 - 1): | for x in range(1, width / 7 - 1): | ||||
| for y in range(1, 7): | for y in range(1, 7): | ||||
| entities.append(Block(x * 7, y * h + x / 2 % 2, 7, h, colors[y - 1])) | entities.append(Block(x * 7, | ||||
| y * h + x / 2 % 2, | |||||
| 7, | |||||
| h, | |||||
| colors[y - 1])) | |||||
| while True: | while True: | ||||
| while select.select([ sys.stdin ], [], [], 0)[0]: | while select.select([ sys.stdin ], [], [], 0)[0]: | ||||
| key = game.getch() | key = game.getch() | ||||
| if key == curses.KEY_LEFT or key == ord('a') or key == ord('A'): | if key == curses.KEY_LEFT or key == ord('a') or key == ord('A'): | ||||
| ship.shift(-1) | ship.shift(-1) | ||||
| elif key == curses.KEY_RIGHT or key == ord('d') or key == ord('D'): | elif key == curses.KEY_RIGHT or key == ord('d') or key == ord('D'): | ||||
| ship.shift(1) | ship.shift(1) | ||||
| Show All 39 Lines | |||||