aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-08-29 01:57:43 -0400
committerGravatar rcoh <rcoh@mit.edu>2011-08-29 01:57:43 -0400
commitcaad42bb405cb51b1fe7a66c2ca854c2d90ee85d (patch)
treea63426ba5b158a30713843305e571950f8e35135
parent507ca19df23b4e22fc0261bcc6c1275cd2ceef47 (diff)
parenta62926dd1e304cd75066811425de108f340926f6 (diff)
Merge branch 'master' of github.com:rcoh/Burton-Conner-Tetris-Battle
Conflicts: renderer.py
-rw-r--r--renderer.py18
-rw-r--r--tetris.py16
2 files changed, 25 insertions, 9 deletions
diff --git a/renderer.py b/renderer.py
index e67c6eb..bd141c8 100644
--- a/renderer.py
+++ b/renderer.py
@@ -38,6 +38,21 @@ 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:
@@ -52,9 +67,10 @@ class PygameRenderer(Renderer):
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()
diff --git a/tetris.py b/tetris.py
index 5a0b1d6..a12ce15 100644
--- a/tetris.py
+++ b/tetris.py
@@ -20,16 +20,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, DROP, DIE) = range(6)
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():
"""
@@ -120,13 +119,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():
@@ -330,8 +330,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 = {}
@@ -374,7 +373,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