Home Game Development box2d – Change display measurement in PyBox2D

box2d – Change display measurement in PyBox2D

0
box2d – Change display measurement in PyBox2D

[ad_1]

I want to use pybox2d‘s Framework class to visualise the simulation. However, the default display / home windows measurement is 640 x 480 pixels and I do not discover a solution to change it. I want to know the way I can change the display measurement. The code beneath is a minimal working instance:

enter image description here

from Box2D.examples.framework import Framework, major
from Box2D import b2EdgeShape, b2FixtureDef, b2PolygonShape, b2Vec2, b2Color


class TestObject(Framework):

    def __init__(self):
        tremendous(TestObject, self).__init__()

        # World
        self.world.gravity = (0.0, -10.0)
        self.world.CreateStaticBody(
            shapes=[
                    b2EdgeShape(vertices=[(-10, 0), (10, 0)]),
                    b2EdgeShape(vertices=[(-10, 0), (-20, 20)]),
                    b2EdgeShape(vertices=[(10, 0), (20, 20)]),
                ]
        )

        obj_vertices = [(0.5, 0.5), (-0.5, 0.5), (-0.5, -0.5), (0.5, -0.5)]

        # Create object
        place = b2Vec2(12, 20)
        linear_velocity = (0.0, -10.0)
        self.obj = self.world.CreateDynamicBody(place=place, linearVelocity=linear_velocity, allowSleep=False)

        density = 1
        peak, width = 6, 4
        vertices = [(width * item[0], peak * merchandise[1]) for merchandise in obj_vertices]
        form = b2PolygonShape(vertices=vertices)
        fixture_def = b2FixtureDef(form=form, density=density)
        self.obj.CreateFixture(fixture_def)

    def Step(self, settings):
        tremendous(TestObject, self).Step(settings)


if __name__ == "__main__":
    major(TestObject)

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here