Skip to content

Commit

Permalink
optimized game speed
Browse files Browse the repository at this point in the history
  • Loading branch information
K0626089 committed Jun 10, 2017
1 parent d74132e commit 2313ddb
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions pytris.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ def is_stackable(mino):
if event.type == QUIT:
done = True
elif event.type == USEREVENT:
pygame.time.set_timer(pygame.USEREVENT, 300)

draw_board(next_mino, hold_mino, score, level, goal)

pause_text = ui_variables.h2_b.render("PAUSED", 1, ui_variables.white)
Expand Down Expand Up @@ -387,6 +389,8 @@ def is_stackable(mino):
dy += 1
hard_drop = True
pygame.time.set_timer(pygame.USEREVENT, 8)
draw_mino(dx, dy, mino, rotation)
draw_board(next_mino, hold_mino, score, level, goal)
elif event.key == K_LSHIFT:
if hold == False:
ui_variables.move_sound.play()
Expand All @@ -399,6 +403,8 @@ def is_stackable(mino):
dx, dy = 3, 0
rotation = 0
hold = True
draw_mino(dx, dy, mino, rotation)
draw_board(next_mino, hold_mino, score, level, goal)
elif event.key == K_UP:
if is_turnable(dx, dy, mino, rotation):
ui_variables.move_sound.play()
Expand All @@ -417,16 +423,20 @@ def is_stackable(mino):
rotation += 1
if rotation == 4:
rotation = 0
draw_mino(dx, dy, mino, rotation)
draw_board(next_mino, hold_mino, score, level, goal)
elif event.key == K_LEFT:
if not is_leftedge(dx, dy, mino, rotation):
ui_variables.move_sound.play()
dx -= 1
draw_mino(dx, dy, mino, rotation)
draw_board(next_mino, hold_mino, score, level, goal)
elif event.key == K_RIGHT:
if not is_rightedge(dx, dy, mino, rotation):
ui_variables.move_sound.play()
dx += 1
draw_mino(dx, dy, mino, rotation)
draw_board(next_mino, hold_mino, score, level, goal)
draw_mino(dx, dy, mino, rotation)
draw_board(next_mino, hold_mino, score, level, goal)

pygame.display.update()

Expand Down

0 comments on commit 2313ddb

Please sign in to comment.