changeset 96:42a4ef9956e4

Try to fix gravity thing... failed.
author Rene Dudfield <renesd@gmail.com>
date Sun, 08 Jul 2012 17:01:24 +0200
parents e9d3ed7d477c
children 8ce25533406d
files zrpn/board.py zrpn/display.py
diffstat 2 files changed, 30 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/zrpn/board.py	Sun Jul 08 15:59:39 2012 +0200
+++ b/zrpn/board.py	Sun Jul 08 17:01:24 2012 +0200
@@ -2,6 +2,7 @@
 # -*- coding: utf-8 -*-
 
 import random
+from pprint import pprint
 
 
 class Board(object):
@@ -32,12 +33,28 @@
                         self.board[y][x] = random.randint(1, 5)
                         self.cells[y][x] = self.id_next
                         net_adds.append([x, y, self.board[y][x], self.cells])
+                        #thing_added(x, y, self.board[y][x], self.cells)
                         self.id_next += 1
 
-            animations.extend(self.apply_gravity(turns))
+            #animations.extend(self.apply_gravity(turns))
+            #TODO: change net_adds to account for gravity, give correct x,y
+
             if not killed:
+                self.printit()
                 return animations, extra, net_adds
 
+
+
+    def printit(self):
+        print ("cells")
+        for c in self.cells:
+            print (c)
+        print ("board")
+        for c in self.board:
+            print (c)
+
+
+
     def apply_gravity(self, turn):
         animations = []
         has_holes = True
--- a/zrpn/display.py	Sun Jul 08 15:59:39 2012 +0200
+++ b/zrpn/display.py	Sun Jul 08 17:01:24 2012 +0200
@@ -10,9 +10,10 @@
 
 class Display(object):
     def __init__(self):
+
+        # give it a smaller sound buffer.
+        pygame.mixer.pre_init(22050, -16, 2, 1024)
         pygame.init()
-        pygame.font.init()
-
         self.screen = sgc.surface.Screen((800, 600))
         self.screen.fill((0x33, 0x33, 0x33))
         self.background = self.screen.copy()
@@ -27,8 +28,13 @@
         self.ninja = pygame.mixer.Sound(data_dir("ninja.ogg"))
         self.skeleton = pygame.mixer.Sound(data_dir("ninja.ogg"))
 
-        self.sound_types = dict(enumerate([None, self.ninja, self.pirate, self.robot, self.skeleton, self.zombie]))
-
+        # a mapping between the type of sprites, and the sounds.
+        self.kinds_sounds = dict(enumerate([None, 
+                                           self.ninja, 
+                                           self.pirate, 
+                                           self.robot, 
+                                           self.skeleton, 
+                                           self.zombie]))
     def load_board(self, board, board_ids):
         for y, line in enumerate(board):
             for x, cell in enumerate(line):
@@ -50,8 +56,8 @@
             else:
                 if kind == 'die':
                     sprite.die(turn)
-                    if sprite.kind in self.sound_types:
-                        self.sound_types[sprite.kind].play()
+                    if sprite.kind in self.kinds_sounds:
+                        self.kinds_sounds[sprite.kind].play()
                 elif kind == 'fall':
                     sprite.fall(turn)