Szymon Wróblewski avatar Szymon Wróblewski committed 9e1c9f3

added tubes module (not working yet)

Comments (0)

Files changed (3)

alchemymadness/main.py

 import resources
 import layout
 import potion
+import tubes
 import blocks
 
 def main():
     pot = potion.Potion()
     pot.set_formula(3, 5, 3)
     sprites = pygame.sprite.LayeredDirty(pot)
+    tbs = tubes.Tubes(sprites)
+    tbs.set_colors(((255,0,0),(0,255,0),(0,0,255),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0),(0,0,0)))
     sprites.clear(screen, resources.background)
 
     grds = blocks.Grids(sprites)

alchemymadness/sprite.py

 class Node(object):
     def __init__(self, *args, **kwargs):
         super(Node, self).__init__(*args, **kwargs)
+        print self, args
         self._parent = None
-        self._children = set()
+        self._children = set() # unordered !!
 
     @property
     def parent(self):
     def children(self):
         return self._children
 
+    def add(self, node):
+        node.parent = self
+
+    def discard(self, node):
+        node.parent = None
+
 
 class MaskedSprite(DirtySprite):
     """ Sprite with color

alchemymadness/tubes.py

+
+import layout
+import resources
+from sprite import MaskedSprite, Node
+
+class Tubes(Node):
+    def __init__(self, *groups):
+        super(Tubes, self).__init__()
+        for i, r in enumerate(layout.Main.tube_rects):
+            self.add(Tube(i, r, *groups))
+
+    def set_colors(self, colors):
+        for t in self.children:
+            t.mix_color(colors[t.id], 1.)
+
+class Tube(Node, MaskedSprite):
+    def __init__(self, tid, rect, *groups):
+        super(Tube, self).__init__((255,255,255), *groups)
+        self.id = tid
+        self.rect = rect
+        self.t_image = resources.background_mask.subsurface(self.rect)
+        self.dirty = 1
+
+    def update(self, time):
+        super(Tube, self).update(time)
+        print 't update'
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.