From c9c1bf98579995c673b56e79ea973d269320fac5 Mon Sep 17 00:00:00 2001 From: Leah Alpert Date: Sun, 28 Aug 2011 21:45:21 -0700 Subject: Added divider between level and timer. Reduced num levels to 6; game is now faster. --- tetris.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tetris.py b/tetris.py index 53d174f..885c97f 100644 --- a/tetris.py +++ b/tetris.py @@ -19,16 +19,15 @@ from ddrinput import DIRECTIONS import pygame TIME_LIMIT = 4 * 60 #seconds -LINES_TO_ADVANCE = 5 #num lines needed to advance to next level -LEVEL_SPEEDS = [800,700,600,500,400,300,200,150,100,70] +LINES_TO_ADVANCE = 8 #num lines needed to advance to next level +LEVEL_SPEEDS = [700,550,400,250,150,110] MAXX = 10 MAXY = 18 (LEFT, RIGHT, UP, DOWN) = range(4) COLORS = ["orange", "red", "green", "blue", "purple", "yellow", "magenta"] -LEVEL_COLORS = ["red", "orange red", "orange", "yellow", - "green yellow", "green", "turquoise", "blue", "blue violet", "purple"] +LEVEL_COLORS = ["red", "orange", "yellow", "green", "blue", "purple"] class Board(): """ @@ -329,8 +328,7 @@ class TetrisGame(object): else: self.board_animation(winner_board,"outline","yellow") self.update_gui() - for i in range(250): - print i, + sleep(3) def create_shapes(self,design): #in progress..... shapes = {} -- cgit v1.2.3 From f806f3e8eef433774d844461ad9cd344d59b840e Mon Sep 17 00:00:00 2001 From: Leah Alpert Date: Sun, 28 Aug 2011 22:08:22 -0700 Subject: Allow shape to be rotated and moved even if it will go off the top of the board. most noticeable on blue line pieces. --- tetris.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tetris.py b/tetris.py index 885c97f..fd67ae2 100644 --- a/tetris.py +++ b/tetris.py @@ -118,13 +118,14 @@ class Board(): That is; if there is a 'landed' block there or it is outside the board boundary, then return False, otherwise return true. """ - if x < 0 or x >= self.max_x or y < 0 or y >= self.max_y: + if x < 0 or x >= self.max_x or y < -3 or y >= self.max_y: return False elif self.landed.has_key( (x, y) ): return False else: return True + #represents a player. each player has a board, other player's board, #current shape, score, etc class Player(): @@ -371,7 +372,8 @@ class TetrisGame(object): if p.shape: blocks = p.shape.blocks for b in blocks: - d[(b.x+offset*n,b.y)] = b.color + if b.y >= 0: + d[(b.x+offset*n,b.y)] = b.color #score score = p.score -- cgit v1.2.3 From a62926dd1e304cd75066811425de108f340926f6 Mon Sep 17 00:00:00 2001 From: Leah Alpert Date: Sun, 28 Aug 2011 22:14:07 -0700 Subject: Added score/time divider for real --- renderer.py | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/renderer.py b/renderer.py index d96f6e0..2e13707 100644 --- a/renderer.py +++ b/renderer.py @@ -33,23 +33,28 @@ class PygameRenderer(Renderer): def render_game(self, game_board): self.background.fill(Color(0,0,0)) + x0 = self.OFFSET[0] - self.SCALE/2 - 3 + y0 = self.OFFSET[1] - 10 + x1 = self.OFFSET[0]+8 + 9*self.SCALE + y1 = self.OFFSET[1]+8 + 19*self.SCALE + b2 = self.SCALE * 13 #x offset for second board + line_endpoints = [((x0,y0), (x0,y1)), ((x0,y1), (x1,y1)), ((x1,y1), (x1,y0)), ((x1,y0), (x0,y0)), + ((x0,y1 - 16), (x1,y1 - 16)), ((x0,y1 - 31), (x1,y1 - 31))] + for p1,p2 in line_endpoints: + pygame.draw.line(self.background, self.color_deref("white"), p1, p2) + pygame.draw.line(self.background, self.color_deref("white"), (p1[0]+b2,p1[1]),(p2[0]+b2,p2[1])) + + x_mid = (x0+x1)/2 + self.SCALE + pygame.draw.line(self.background, self.color_deref("white"), (x_mid,y1 - 16),(x_mid,y1 - 31)) + pygame.draw.line(self.background, self.color_deref("white"), (x_mid+b2,y1 - 16),(x_mid+b2,y1 - 31)) + for (x,y) in game_board: disp_x = x if x >= 10: disp_x+=3 - x0 = self.OFFSET[0] - self.SCALE/2 - 3 - y0 = self.OFFSET[1] - 10 - x1 = self.OFFSET[0]+8 + 9*self.SCALE - y1 = self.OFFSET[1]+8 + 19*self.SCALE - b2 = self.SCALE * 13 #x offset for second board - line_endpoints = [((x0,y0), (x0,y1)), ((x0,y1), (x1,y1)), ((x1,y1), (x1,y0)), ((x1,y0), (x0,y0)), - ((x0,y1 - 16), (x1,y1 - 16)), ((x0,y1 - 31), (x1,y1 - 31))] - for p1,p2 in line_endpoints: - pygame.draw.line(self.background, self.color_deref("white"), p1, p2) - pygame.draw.line(self.background, self.color_deref("white"), (p1[0]+b2,p1[1]),(p2[0]+b2,p2[1])) - pygame.draw.circle(self.background, self.color_deref(game_board[(x,y)]), (self.OFFSET[0] + disp_x*self.SCALE, self.OFFSET[1] + y*self.SCALE), self.RADIUS) + self.screen.blit(self.background, (0,0)) pygame.display.flip() -- cgit v1.2.3