commit:9dbc1d73cdefd67819aa653647be4804affcdea7
author:Chip Black
committer:Chip Black
date:Sun Jul 27 04:13:02 2008 -0500
parents:65edab8337744d230022bb71f20a1be56204ab48
Merged Stage into Level
diff --git a/Richter/Level.py b/Richter/Level.py
line changes: +83/-4
index 365780a..f621d9d
--- a/Richter/Level.py
+++ b/Richter/Level.py
@@ -4,7 +4,7 @@ import imp
 import yaml
 from Collage import Collage
 from Surface import SurfaceSet
-from Stage import Stage, Layer
+from OpenGL.GL import *
 
 classpath = ['classes']
 for path in classpath:
@@ -22,9 +22,50 @@ def findClass(classname):
 		mod[0].close()
 
 
+class Layer:
+	"""Container for layer data.
+
+	collage - A Collage object defining the visuals of the layer
+	scale - A float value for the size of the background layer
+	parallax - A float value specifying the relative scroll speed (where
+		   1.0 is typically the playfield scroll speed, >1.0 is faster,
+		   and <1.0 is slower)"""
+
+	def __init__(self, collage=None, surfaces=None, scale=1.0, parallax=1.0):
+		self.collage = collage
+		self.surfaces = surfaces
+		self.scale = scale
+		self.parallax = parallax
+		self.position = (0, 0)
+		self.things = []
+
+
+	def add(self, thing):
+		self.things.append(thing)
+
+
+	def moveTo(self, x, y):
+		self.position = (x * self.parallax, y * self.parallax)
+
+
+	def draw(self):
+		glPushMatrix()
+		if self.scale != 1.0:
+			glScalef(self.scale, self.scale, self.scale)
+		glTranslatef(-self.position[0], -self.position[1], 0)
+		self.collage.draw()
+		for t in self.things:
+			t.draw()
+		glPopMatrix()
+
+
 class Level:
 	def __init__(self, dir):
+		self.layers = []
+		self.position = (0, 0)
+		self.drawsurfaces = False
 		self.env = {}
+
 		self.load(dir)
 
 
@@ -33,8 +74,6 @@ class Level:
 		layers = yaml.safe_load(f)
 		f.close()
 
-		self.stage = Stage()
-
 		for layer in layers:
 			collage = None
 			surfaces = None
@@ -53,7 +92,7 @@ class Level:
 					parallax = layer['properties']['parallax']
 
 			new_layer = Layer(collage, surfaces, scale, parallax)
-			self.stage.addLayerBack(new_layer)
+			self.addLayerBack(new_layer)
 
 			if layer.has_key('things'):
 				self.compileThings(new_layer, layer['things'])
@@ -69,3 +108,43 @@ class Level:
 			properties['surfaces'] = layer.surfaces
 			self.env[name] = c(**properties)
 			layer.add(self.env[name])
+
+
+	def addLayerBack(self, layer):
+		self.layers.insert(0, layer)
+
+
+	def addLayerFront(self, layer):
+		self.layers.append(layer)
+
+
+	def setSurfaces(self, datafile):
+		self.surfaces = SurfaceSet(datafile)
+
+
+	def drawSurfaces(self):
+		self.drawsurfaces = True
+
+
+	def hideSurfaces(self):
+		self.drawsurfaces = False
+
+
+	def toggleDrawSurfaces(self):
+		self.drawsurfaces = not self.drawsurfaces
+
+
+	def moveTo(self, x, y):
+		self.position = [x,y]
+		for l in self.layers:
+			l.moveTo(x, y)
+
+
+	def draw(self):
+		for l in self.layers:
+			l.draw()
+		if self.drawsurfaces:
+			glPushMatrix()
+			glTranslate(-self.position[0], -self.position[1], 0)
+			self.surfaces.draw()
+			glPopMatrix()

diff --git a/Richter/Stage.py b/Richter/Stage.py
line changes: +0/-90
index de41578..0000000
--- a/Richter/Stage.py
+++ /dev/null
@@ -1,90 +0,0 @@
-from Collage import *
-from Surface import *
-
-class Layer:
-	"""Container for layer data.
-
-	collage - A Collage object defining the visuals of the layer
-	scale - A float value for the size of the background layer
-	parallax - A float value specifying the relative scroll speed (where
-		   1.0 is typically the playfield scroll speed, >1.0 is faster,
-		   and <1.0 is slower)"""
-
-	def __init__(self, collage=None, surfaces=None, scale=1.0, parallax=1.0):
-		self.collage = collage
-		self.surfaces = surfaces
-		self.scale = scale
-		self.parallax = parallax
-		self.position = (0, 0)
-		self.things = []
-
-
-	def add(self, thing):
-		self.things.append(thing)
-
-
-	def moveTo(self, x, y):
-		self.position = (x * self.parallax, y * self.parallax)
-
-
-	def draw(self):
-		glPushMatrix()
-		if self.scale != 1.0:
-			glScalef(self.scale, self.scale, self.scale)
-		glTranslatef(-self.position[0], -self.position[1], 0)
-		self.collage.draw()
-		for t in self.things:
-			t.draw()
-		glPopMatrix()
-
-
-class Stage:
-	layers = None
-	surfaces = None
-	drawsurfaces = False
-	position = None
-
-	def __init__(self):
-		self.layers = []
-		self.position = (0, 0)
-		self.env = {}
-
-
-	def addLayerBack(self, layer):
-		self.layers.insert(0, layer)
-
-
-	def addLayerFront(self, layer):
-		self.layers.append(layer)
-
-
-	def setSurfaces(self, datafile):
-		self.surfaces = SurfaceSet(datafile)
-
-
-	def drawSurfaces(self):
-		self.drawsurfaces = True
-
-
-	def hideSurfaces(self):
-		self.drawsurfaces = False
-
-
-	def toggleDrawSurfaces(self):
-		self.drawsurfaces = not self.drawsurfaces
-
-
-	def moveTo(self, x, y):
-		self.position = [x,y]
-		for l in self.layers:
-			l.moveTo(x, y)
-
-
-	def draw(self):
-		for l in self.layers:
-			l.draw()
-		if self.drawsurfaces:
-			glPushMatrix()
-			glTranslate(-self.position[0], -self.position[1], 0)
-			self.surfaces.draw()
-			glPopMatrix()