[pypy-svn] r62582 - in pypy/trunk/pypy/lang/gameboy: . test
tverwaes at codespeak.net
tverwaes at codespeak.net
Thu Mar 5 15:30:43 CET 2009
Author: tverwaes
Date: Thu Mar 5 15:30:40 2009
New Revision: 62582
Modified:
pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py
pypy/trunk/pypy/lang/gameboy/test/test_video.py
pypy/trunk/pypy/lang/gameboy/video.py
Log:
removing ugly indexes
Modified: pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py (original)
+++ pypy/trunk/pypy/lang/gameboy/gameboy_implementation.py Thu Mar 5 15:30:40 2009
@@ -145,7 +145,7 @@
if string:
return ["#", "%", "+", ".", " "][self.get_pixel_color(x, y)]
else:
- return self.pixels[x+self.width*y]
+ return self.pixels[y][x]
# JOYPAD DRIVER ----------------------------------------------------------------
Modified: pypy/trunk/pypy/lang/gameboy/test/test_video.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/test/test_video.py (original)
+++ pypy/trunk/pypy/lang/gameboy/test/test_video.py Thu Mar 5 15:30:40 2009
@@ -504,7 +504,7 @@
assert video.line == [0] * (8+160+8)
video.line = range(8+160+8)
- video.background.draw_clean_line(video.line_y)
+ video.background.draw_clean_line(video.line)
assert video.line == [0] * (8+160+8)
Modified: pypy/trunk/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video.py (original)
+++ pypy/trunk/pypy/lang/gameboy/video.py Thu Mar 5 15:30:40 2009
@@ -512,7 +512,7 @@
self.update_palette()
for x in range(0, GAMEBOY_SCREEN_WIDTH):
color = self.palette[self.line[SPRITE_SIZE + x]]
- self.driver.draw_pixel(x, self.line_y, color)
+ self.driver.draw_gb_pixel(x, self.line_y, color)
def update_palette(self):
if not self.dirty: return
@@ -549,20 +549,16 @@
self.clear_pixels()
def clear_pixels(self):
- self.pixels = [0] * self.width * self.height
+ self.pixels = [[0] * self.width for i in range(self.height)]
+
+ def draw_gb_pixel(self, x, y, color):
+ self.pixels[y][x] = color
- def draw_pixel(self, x, y, color):
- self.pixels[y * self.width + x] = color
-
def get_width(self):
return self.width
def get_height(self):
return self.height
- def get_pixels(self):
- return self.pixels
-
def update_display(self):
self.clear_pixels()
-
More information about the Pypy-commit
mailing list