Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Body stops after getting beyond 800x600 square #146

Closed
kirtangajjar opened this issue Aug 28, 2015 · 2 comments
Closed

Body stops after getting beyond 800x600 square #146

kirtangajjar opened this issue Aug 28, 2015 · 2 comments

Comments

@kirtangajjar
Copy link

I was trying to make my game fullscreen, so i changed the Renderer.options.width and height.

However, when i started my game, the ball struct whenever it tried to get out of the initial square.

I tried changing Body.bound on the ball, however, no luck.

Also is there a way to set global bounds so that i do not have to do it on every object?

Here is my code -

            function Start(){
            var Engine = Matter.Engine,
            World = Matter.World,
            Bodies = Matter.Bodies,
            Renderer = Matter.Renderer;

            Renderer = {
                    options:{
                        wireframes: true,
                        width: window.innerWidth,
                        height: window.innerHeight
                    }};

            // create a Matter.js engine
            var engine = Engine.create(document.body,{render: Renderer});

            engine.world.gravity.x = 0;
            engine.world.gravity.y = 0;

            // create two boxes and a ground
            var ball = Bodies.circle(400, 200, 20,
                { 
                    inertia: Infinity,
                    restitution: 1,
                    friction: 0,
                    frictionAir: 0,
                    force: {x:0.03, y:0.03}
                });

            var offset = 10;

            ball.bounds = {
                max: { x: Renderer.options.width, y: Renderer.options.height},
                min: { x: offset, y: offset}
            }

            var ceiling   = Bodies.rectangle(Renderer.options.width/2,      -offset, Renderer.options.width + 2 * offset, 50.5, { isStatic: true });
            var ground    = Bodies.rectangle(Renderer.options.width/2, Renderer.options.height + offset, Renderer.options.width + 2 * offset, 50.5, { isStatic: true });
            var rightSide = Bodies.rectangle(Renderer.options.width + offset, Renderer.options.height/2, 50.5, Renderer.options.height + 0.5 + 2 * offset, { isStatic: true });
            var leftSide  = Bodies.rectangle(-offset, Renderer.options.height/2, 50.5, Renderer.options.width + 0.5 + 2 * offset, { isStatic: true });

            // add all of the bodies to the world
            World.add(engine.world, [ball, ceiling, ground, leftSide, rightSide]);

            // run the engine
            Engine.run(engine);
            }
@liabru
Copy link
Owner

liabru commented Aug 29, 2015

Please see #67, if you use the latest master build this should be resolved.

@kirtangajjar
Copy link
Author

Thanks, that helped

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants