Exemplo n.º 1
0
    def create(self):
        w = Gdx.graphics.getWidth()
        h = Gdx.graphics.getHeight()

        self.camera = OrthographicCamera()
        self.camera.setToOrtho(False, (w / h) * 320, 320)
        self.camera.update()

        self.cameraController = OrthoCamController(self.camera)
        Gdx.input.setInputProcessor(self.cameraController)

        self.font = BitmapFont()
        self.batch = SpriteBatch()

        self.tiles = Texture(
            Gdx.files.internal('../../data/maps/tiled/tiles.png'))
        splitTiles = TextureRegion.split(self.tiles, 32, 32)
        self.map = TiledMap()
        layers = self.map.getLayers()
        for l in range(20):
            layer = TiledMapTileLayer(150, 100, 32, 32)
            for x in range(150):
                for y in range(100):
                    ty = int(Math.random() * len(splitTiles))
                    tx = int(Math.random() * len(splitTiles[ty]))
                    cell = Cell()
                    cell.setTile(StaticTiledMapTile(splitTiles[ty][tx]))
                    layer.setCell(x, y, cell)
            layers.add(layer)

        self.renderer = OrthogonalTiledMapRenderer(self.map)
Exemplo n.º 2
0
	def __init__(self):
		self.batch = SpriteBatch()
		self.img = Texture("badlogic.jpg")