Beispiel #1
0
 def draw(self, cr, width, height):
     middle = vector(0.5,0.5)
     self.centerShift(middle)
     graphics.drawWorld(cr, self.objects, self.springs, width, height)
Beispiel #2
0
		self.heightMap = heightMap #numpy matrix, saves the terrain's height data
		# Position?
	
	def boundingBox(self):
		try: return ( len(self.tiles[0])*26, len(self.tiles)*14 )
		except: return (0,0)

class World:
	""" The world this engine models. """
	def __init__(self, chunks = [], tileSize = (26,14), chunkSize = (1,1)):
		self.chunks = chunks # Chunks are parts of the map of a moderate size, which are loaded into memory when displayed
		self.tileSize = tileSize
		self.chunkSize = chunkSize
		
	def boundingBox(self):
		return (len(self.chunks)*self.chunkSize[0]*self.tileSize[0], len(self.chunks[0])*self.chunkSize[1]*self.tileSize[1])


# Unit test
if __name__ == "__main__":
	display = graphics.initGraphics()
	
	testLayer = Layer(texture = "grass.png")
	testTile = Tile(layers = [testLayer])
	testChunk = Chunk(id = 1, tiles = numpy.matrix( [ [testTile] ] ))
	testWorld = World(chunks = numpy.matrix( [[testChunk]] ))
	
	print testWorld.boundingBox()
	
	graphics.drawWorld(testWorld, display)