Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFran Rogers <fran@dumetella.net>2010-02-01 18:33:09 (GMT)
committer Fran Rogers <fran@dumetella.net>2010-02-01 18:33:09 (GMT)
commitb5483ac67defce67cb5dffb9e6b6c8ecb4ee0b2a (patch)
treec2315f6148247dd0c6f16b6a52e19b324b30fd96
parentaae454983c6e33958ebed01035e269812a19e012 (diff)
A start at the game's data structures
-rw-r--r--blocku.py44
-rw-r--r--blocku_activity.py2
2 files changed, 18 insertions, 28 deletions
diff --git a/blocku.py b/blocku.py
index 7744871..058eb93 100644
--- a/blocku.py
+++ b/blocku.py
@@ -2,16 +2,26 @@
import pygame
#import gtk
-class BlockuGame:
+class Block:
+ pass
+
+class Puzzle:
+ def __init__(self, width, height, rule, edges, blocks=None):
+ self.width = width
+ self.height = height
+ self.rule = rule
+ self.edges = edges
+ self.blocks = blocks or []
+
+ def add_block(self, block):
+ self.blocks.push(block)
+
+class Game:
def __init__(self):
# Set up a clock for managing the frame rate.
self.clock = pygame.time.Clock()
- self.x = -100
- self.y = 100
-
- self.vx = 10
- self.vy = 0
+ self.puzzle = Puzzle()
self.paused = False
@@ -44,27 +54,7 @@ class BlockuGame:
elif event.type == pygame.VIDEORESIZE:
pygame.display.set_mode(event.size, pygame.RESIZABLE)
- # Move the ball
- if not self.paused:
- self.x += self.vx
- if self.x > screen.get_width() + 100:
- self.x = -100
-
- self.y += self.vy
- if self.y > screen.get_height() - 100:
- self.y = screen.get_height() - 100
- self.vy = -self.vy
-
- self.vy += 5;
- # Clear Display
- screen.fill((255,255,255)) #255 for white
-
- # Draw the ball
- pygame.draw.circle(screen, (255,0,0), (self.x, self.y), 100)
-
- # Flip Display
- pygame.display.flip()
# Try to stay at 30 FPS
self.clock.tick(30)
@@ -74,7 +64,7 @@ class BlockuGame:
def main():
pygame.init()
pygame.display.set_mode((0, 0), pygame.RESIZABLE)
- game = BlockuGame()
+ game = Game()
game.run()
if __name__ == '__main__':
diff --git a/blocku_activity.py b/blocku_activity.py
index 841bd83..f5856e1 100644
--- a/blocku_activity.py
+++ b/blocku_activity.py
@@ -18,7 +18,7 @@ class BlockuActivity(sugar.activity.activity.Activity):
self.paused = False
# Create the game instance.
- self.game = blocku.BlockuGame()
+ self.game = blocku.Game()
# Build the activity toolbar.
self.build_toolbar()