aboutsummaryrefslogtreecommitdiff
path: root/renderer.py
diff options
context:
space:
mode:
authorGravatar rcoh <rcoh@mit.edu>2011-08-29 01:46:55 -0400
committerGravatar rcoh <rcoh@mit.edu>2011-08-29 01:46:55 -0400
commit507ca19df23b4e22fc0261bcc6c1275cd2ceef47 (patch)
treeb75411dffe19d181be9ce91a48ab39593a6fcbb7 /renderer.py
parent37af70803573d93fd2793d5333fc23a9d8f1e4c2 (diff)
some style changes in tetris.
Diffstat (limited to 'renderer.py')
-rw-r--r--renderer.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/renderer.py b/renderer.py
index 1e40c7b..e67c6eb 100644
--- a/renderer.py
+++ b/renderer.py
@@ -41,7 +41,7 @@ class PygameRenderer(Renderer):
for (x,y) in game_board:
disp_x = x
if x >= 10:
- disp_x+=3
+ disp_x+=3
x0 = self.OFFSET[0] - self.SCALE/2 - 3
y0 = self.OFFSET[1] - 10
x1 = self.OFFSET[0]+8 + 9*self.SCALE
@@ -79,7 +79,8 @@ class LedRenderer(Renderer):
self.sockets[ip].send(final_packet, 0x00)
except:
print 'failure sending packet'
-
+ def color_deref(self, color):
+ return (255, 0, 0)
def map_to_packets(self, game_board):
"""
Performs the mapping between a game_board and a list of (port,packet) pairs. The port,packet
@@ -93,13 +94,14 @@ class LedRenderer(Renderer):
section_height = 5
for board_x_min in [0, 10]:
packet = []
- for y_start in [20, 15, 10, 5]:
+ for board_y_min in [20, 15, 10, 5]:
strip = zeros((50,3),'ubyte')
index = 0
- for y in range(board_y_min+section_height, board_y_min, -1):
+ for y in range(board_y_min, board_y_min-section_height, -1):
for x in range(board_x_min+section_width, board_x_min, -1):
- strip[index] = self.color_deref(game_board[(x,y)])
+ if (x,y) in game_board:
+ strip[index] = self.color_deref(game_board[(x,y)])
packet.append((1+len(packet), strip))
- packets.append(packet)
-
+ index += 1
+ packets += packet
return packets