Skip to content

Commit

Permalink
add pause function
Browse files Browse the repository at this point in the history
  • Loading branch information
K0626089 committed Jun 9, 2017
1 parent 41bea65 commit 717710e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ More on [How to play](https://github.com/k0626089/PYTRIS/wiki/How-to-play)
- [Sound effects](https://github.com/k0626089/PYTRIS/wiki/Resources#sound-source)
- [Game over when the board is full](https://github.com/k0626089/PYTRIS/wiki/Things-that-work#game-over-when-the-board-is-full)
- [Ghost](https://github.com/k0626089/PYTRIS/wiki/Things-that-work#Ghost)
- [Pause](https://github.com/k0626089/PYTRIS/wiki/Things-that-work#pause)

## Things that don't work
Everything seem to work for now

## Future plans
- [T-spin](https://github.com/k0626089/PYTRIS/wiki/Future-plans#t-spin-support)
- [High score system](https://github.com/k0626089/PYTRIS/wiki/Future-plans#high-score-system)
- [Pause](https://github.com/k0626089/PYTRIS/wiki/Future-plans#pause)

## Screenshots
<img src="assets/images/title.png" width="300">
Expand Down
26 changes: 23 additions & 3 deletions pytris.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ def is_stackable(mino):
# Initial values
blink = True
start = False
pause = False
done = False
game_over = False

Expand All @@ -264,8 +265,25 @@ def is_stackable(mino):
###########################################################

while not done:
# Pause screen
if pause:
for event in pygame.event.get():
if event.type == QUIT:
done = True
elif event.type == USEREVENT:
draw_board(next_mino, hold_mino, score, level, goal)

pause_text = ui_variables.h2.render("PAUSED", 1, ui_variables.white)
screen.blit(pause_text, (47, 100))

pygame.display.update()
elif event.type == KEYDOWN:
erase_mino(dx, dy, mino, rotation)
if event.key == K_ESCAPE:
pause = False

# Game screen
if start:
elif start:
for event in pygame.event.get():
if event.type == QUIT:
done = True
Expand Down Expand Up @@ -340,12 +358,14 @@ def is_stackable(mino):

elif event.type == KEYDOWN:
erase_mino(dx, dy, mino, rotation)
if event.key == K_SPACE:
if event.key == K_ESCAPE:
pause = True
elif event.key == K_SPACE:
ui_variables.drop_sound.play()
while not is_bottom(dx, dy, mino, rotation):
dy += 1
hard_drop = True
pygame.time.set_timer(pygame.USEREVENT, 5)
pygame.time.set_timer(pygame.USEREVENT, 8)
elif event.key == K_LSHIFT:
if hold == False:
ui_variables.move_sound.play()
Expand Down

0 comments on commit 717710e

Please sign in to comment.