[pypy-svn] r62399 - pypy/trunk/pypy/lang/gameboy

cami at codespeak.net cami at codespeak.net
Mon Mar 2 16:14:03 CET 2009


Author: cami
Date: Mon Mar  2 16:14:02 2009
New Revision: 62399

Modified:
   pypy/trunk/pypy/lang/gameboy/video.py
   pypy/trunk/pypy/lang/gameboy/video_sprite.py
Log:
added first extraction test for the scan_sprite method


Modified: pypy/trunk/pypy/lang/gameboy/video.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/video.py	Mon Mar  2 16:14:02 2009
@@ -563,8 +563,9 @@
             x = sprite.x
             y = sprite.y
             if sprite.hidden: continue
+            if not sprite.intersects_current_line(self): continue
             tile = sprite.tile_number
-            y    = self.line_y - y + 2 * SPRITE_SIZE
+            y    = sprite.current_line_y(self)
             if self.control.big_sprite_size_selected:
                 # 8x16 tile size
                 tile_size = 15
@@ -572,7 +573,6 @@
             else:
                 # 8x8 tile size
                 tile_size = 7
-            if y < 0 or y > tile_size: continue
             if sprite.y_flipped:
                 y = tile_size - y
             # TODO: build an object abstraction?

Modified: pypy/trunk/pypy/lang/gameboy/video_sprite.py
==============================================================================
--- pypy/trunk/pypy/lang/gameboy/video_sprite.py	(original)
+++ pypy/trunk/pypy/lang/gameboy/video_sprite.py	Mon Mar  2 16:14:02 2009
@@ -132,9 +132,19 @@
     def overlaps_on_line(self, sprite, line):
         return False
     
+    def get_tile_size(self, video):
+         if video.control.big_sprite_size_selected:
+            return 15
+         else:
+            return 7
+        
     def intersects_current_line(self, video):
-        return line >= self.y and line <= self.y + self.get_height()
+        y = self.current_line_y(video)
+        return y >= 0 and y <= self.get_tile_size(video)
     
+    def current_line_y(self, video):
+        return video.line_y - self.y + 2 * SPRITE_SIZE
+        
     def draw(self):
         pass
     



More information about the Pypy-commit mailing list