Esempio n. 1
0
def main():

    cfg = LwjglApplicationConfiguration()
    cfg.title = "PyGdx";
    cfg.width = 800
    cfg.height = 480

    LwjglApplication(PyGdx(), cfg)
Esempio n. 2
0
def main():

    cfg = LwjglApplicationConfiguration()
    cfg.title = "PyGdx";
    cfg.width = WIDTH
    cfg.height = HEIGHT

    LwjglApplication(DropGame(), cfg)
Esempio n. 3
0
def main():
    """
    This shouldnt be run, it should be happening from __run__ module.
    """
    cfg = LwjglApplicationConfiguration()
    cfg.title = "PyGdx";
    cfg.width = 800
    cfg.height = 480
    
    LwjglApplication(PyGdx(), cfg)
Esempio n. 4
0
                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)

    def render(self):
        Gdx.gl.glClearColor(100.0 / 255.0, 100.0 / 255.0, 250.0 / 255.0, 1.0)
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
        self.camera.update()
        self.renderer.setView(self.camera)
        self.renderer.render()
        self.batch.begin()
        self.font.draw(self.batch,
                       'FPS: ' + str(Gdx.graphics.getFramesPerSecond()), 10,
                       20)
        self.batch.end()


if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 640
    config.height = 480
    config.title = 'Tiled Map Bench Test'
    config.forceExit = False
    LwjglApplication(TiledMapBench(), config)
Esempio n. 5
0
            bd = BodyDef()
            bd.type = BodyType.DynamicBody
            bd.position.set(-8.0 + 8.0 * i, 12.0)
            body = world.createBody(bd)
            body.createFixture(fd)

            shape.dispose()

        for i in range(2):
            shape = CircleShape()
            shape.setRadius(0.5)

            fd = FixtureDef()
            fd.shape = shape
            fd.density = 1.0

            bd = BodyDef()
            bd.type = BodyType.DynamicBody
            bd.position.set(-6.0 + 6.0 * i, 10.0)
            body = world.createBody(bd)
            body.createFixture(fd)
            shape.dispose()

if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 640
    config.height = 480
    config.title = 'Cantilever Test'
    config.forceExit = False
    LwjglApplication(Cantilever(), config)
            jd.localAnchorB.set(0, 0)
            jd.bodyA = ground
            jd.bodyB = body
            jd.collideConnected = True
            jd.maxForce = mass * gravity
            jd.maxTorque = mass * radius * gravity

            world.createJoint(jd)

        shape.dispose()

    def keyDown(self, keyCode):
        if keyCode == Keys.W:
            print 'Hit W!'
            f = self.m_body.getWorldVector(self.tmp.set(0, -200))
            p = self.m_body.getWorldPoint(self.tmp.set(0, 2))
            self.m_body.applyForce(f, p, True)
        if keyCode == Keys.A: self.m_body.applyTorque(50, True)
        if keyCode == Keys.D: self.m_body.applyTorque(-50, True)

        return False


if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 640
    config.height = 480
    config.title = 'Apply Force Test'
    config.forceExit = False
    LwjglApplication(ApplyForce(), config)
        fd.shape = shape
        fd.density = 20.0
        body.createFixture(fd)
        shape.dispose()

        bd = BodyDef()
        bd.position.set(3, 5)
        bd.type = BodyType.DynamicBody
        bd.fixedRotation = True
        bd.allowSleep = False

        body = world.createBody(bd)

        shape = CircleShape()
        shape.setRadius(0.5)

        fd = FixtureDef()
        fd.shape = shape
        fd.density = 20.0
        body.createFixture(fd)
        shape.dispose()


if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 1280
    config.height = 960
    config.title = 'Character Collision Test'
    config.forceExit = False
    LwjglApplication(CharacterCollision(), config)
Esempio n. 8
0
        circleShapeDef = FixtureDef()
        circleShapeDef.shape = circle
        circleShapeDef.density = 1.0

        circleShapeDef.filter.groupIndex = self.k_smallGroup
        circleShapeDef.filter.categoryBits = self.k_circleCategory
        circleShapeDef.filter.maskBits = self.k_circleMask

        circleBodyDef = BodyDef()
        circleBodyDef.type = BodyType.DynamicBody
        circleBodyDef.position.set(5, 2)

        body5 = world.createBody(circleBodyDef)
        body5.createFixture(circleShapeDef)

        circle.setRadius(2)
        circleShapeDef.filter.groupIndex = self.k_largeGroup
        circleBodyDef.position.set(5, 6)

        body6 = world.createBody(circleBodyDef)
        body6.createFixture(circleShapeDef)

if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 1280
    config.height = 960
    config.title = 'Collision Filtering Test'
    config.forceExit = False
    LwjglApplication(CollisionFiltering(), config)
Esempio n. 9
0
        shape.dispose()

    def keyDown(self, keyCode):
        if keyCode == Keys.D: self.m_platform.setType(BodyType.DynamicBody)
        if keyCode == Keys.S: self.m_platform.setType(BodyType.StaticBody)
        if keyCode == Keys.K:
            self.m_platform.setType(BodyType.KinematicBody)
            self.m_platform.setLinearVelocity(self.tmp.set(-self.m_speed, 0))
            self.m_platform.setAngularVelocity(0)

        return False

    def render(self):
        if type(self.m_platform) == BodyType.KinematicBody:
            p = self.m_platform.getTransform().getPosition()
            v = self.m_platform.getLinearVelocity()

            if (p.x < -10 and v.x > 0) or (p.x > 10 and v.x > 0):
                v.x = -v.x
                self.m_platform.setLinearVelocity(v)

        super(BodyTypes, self).render()

if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 640
    config.height = 480
    config.title = 'Action Test'
    config.forceExit = False
    LwjglApplication(BodyTypes(), config)
        instance.transform.setToTranslation(MathUtils.random(-10, 10),
                                            MathUtils.random(-10, 10),
                                            MathUtils.random(-10, 10))
        instance.transform.rotate(Vector3.X, MathUtils.random(-180, 180))
        instance.transform.rotate(Vector3.Y, MathUtils.random(-180, 180))
        instance.transform.rotate(Vector3.Z, MathUtils.random(-180, 180))
        self.instances.append(instance)

    def keyUp(self, keycode):
        if keycode == Keys.SPACE or keycode == Keys.MENU:
            self.onLoaded()
        return super(Benchmark3DTest, self).keyUp(keycode)

    def touchUp(self, screenX, screenY, pointer, button):
        self.onModelClicked(self.models[MathUtils.random(len(self.models) -
                                                         1)])
        return False

    def dispose(self):
        super(Benchmark3DTest, self).dispose()
        GLProfiler.disable()


if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 1280
    config.height = 960
    config.title = 'Benchmark 3D Test'
    config.forceExit = False
    LwjglApplication(Benchmark3DTest(), config)
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT)

        self.modelBatch.begin(self.cam)
        self.modelBatch.render(self.instance, self.environment)
        self.modelBatch.end()

    def dispose(self):
        self.modelBatch.dispose()
        self.model.dispose()

    def needsGl20(self):
        return True

    def resume(self):
        pass

    def resize(self, width, height):
        pass

    def pause(self):
        pass


if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 1280
    config.height = 960
    config.title = 'Basic 3D Test'
    config.forceExit = False
    LwjglApplication(Basic3DTest(), config)
Esempio n. 12
0
        fd.friction = 0.2

        jd = RevoluteJointDef()
        jd.collideConnected = False

        y = 25.0
        prevBody = ground

        for i in range(30):
            bd = BodyDef()
            bd.type = BodyType.DynamicBody
            bd.position.set(0.5 + i, y)
            body = world.createBody(bd)
            body.createFixture(fd)

            anchor = Vector2(i, y)
            jd.initialize(prevBody, body, anchor)
            world.createJoint(jd)
            prevBody = body

        shape.dispose()


if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 640
    config.height = 480
    config.title = 'Chain Test'
    config.forceExit = False
    LwjglApplication(Chain(), config)
Esempio n. 13
0
            body = world.createBody(bd)
            body.createFixture(fd)

            shape.dispose()

        for i in range(3):
            shape = CircleShape()
            shape.setRadius(0.5)

            fd = FixtureDef()
            fd.shape = shape
            fd.density = 1.0

            bd = BodyDef()
            bd.type = BodyType.DynamicBody
            bd.position.set(-6.0 + 6.0 * i, 10.0)

            body = world.createBody(bd)
            body.createFixture(fd)

            shape.dispose()


if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 640
    config.height = 480
    config.title = 'Bridge Test'
    config.forceExit = False
    LwjglApplication(Bridge(), config)
            elif id.startswith('block'):
                self.blocks.append(instance)
            elif id.startswith('invader'): self.invaders.append(instance)

        self.loading = False

    def render(self):
        if self.loading and self.assets.update(): self.doneLoading()
        self.camController.update()

        Gdx.gl.glViewport(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight())
        Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT)

        self.modelBatch.begin(self.cam)
        for instance in self.instances:
            self.modelBatch.render(instance, self.lights)
        if self.space: self.modelBatch.render(self.space)
        self.modelBatch.end()

    def dispose(self):
        self.modelBatch.dispose()
        self.assets.dispose()

if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 1280
    config.height = 960
    config.title = 'Basic 3D Scene Test'
    config.forceExit = False
    LwjglApplication(Basic3DSceneTest(), config)
Esempio n. 15
0
            self.character = ModelInstance(self.assets.get('../../data/g3d/knight.g3db', Model))
            bbox = BoundingBox()
            self.character.calculateBoundingBox(bbox)
            self.character.transform.setToRotation(Vector3.Y, 180).trn(0, -bbox.min.y, 0)
            self.instances.append(self.character)
            self.animation = AnimationController(self.character)
            self.animation.animate('Idle', -1, 1.0, None, 0.2)
            self.status = self.idle
            for anim in self.character.animations:
                Gdx.app.log('Test', anim.id)
            self.ship = self.assets.get('../../data/g3d/ship.obj', Model).nodes.get(0).copy()
            self.ship.detach()
            self.ship.translation.x = 10.0
            self.ship.rotation.set(Vector3.Z, 90.0)
            self.ship.scale.scl(5.0)
            self.ship.parts.get(0).enabled = False
            self.character.getNode('sword').addChild(self.ship)

    def dispose(self):
        super(Animation3DTest, self).dispose()
        self.floorModel.dispose()
        self.shadowLight.dispose()

if __name__ == '__main__':
    config = LwjglApplicationConfiguration()
    config.width = 1280
    config.height = 960
    config.title = 'Animation 3D Test'
    config.forceExit = False
    LwjglApplication(Animation3DTest(), config)