Jump to content

Restricted area


Yura
 Share

Recommended Posts

All good day from the start I want to apologize for my English. 

I need to create a pool and now I'm focused on the problem of when to make the play area. How best to do this?
What I found - a rectangular area. I also need to know where this should be done in pixi.js or physical framework (like p2.js or physics.js)
Thank you for your reply;)

 

f4f453a9e8.png

Link to comment
Share on other sites

27 minutes ago, xerver said:

Pixi doesn't have anything to help you with this, it is just for drawing (for the most part). You can do it yourself, or use something like p2.js for a more "accurate" physics feel.

Unfortunately, I did not find the desired functionality of these libraries. You can not tell me about some api?

Thanks for the answer)

Link to comment
Share on other sites

  • 3 weeks later...
On 10/31/2016 at 8:41 PM, xerver said:

Not sure what you mean, p2.js is a full physics simulation with everything necessary for a game of pool. What was missing?

https://github.com/schteppe/p2.js

http://schteppe.github.io/p2.js/demos/restitution.html

 

Thank you for your response.
I have one question: how to use p2.js plane as in billiards (like the camera to turn down) because most demos p2.js made in the form side.

Link to comment
Share on other sites

12 hours ago, xerver said:
world = new p2.World();
         // Add a box
         boxShape = new p2.Box({ width: 2, height: 1 });
         boxBody = new p2.Body({
             mass: 1,
             position:[0, 1],
             angularVelocity:1
         });

         // Turn off global gravity
         world.applyGravity=false;

         // Keep track of which bodies you want to apply gravity on:
         var gravityBodies=[boxBody];

         // And just before running world.step(), do this:
         var gravity = p2.vec2.fromValues(0, -110),
             gravityForce = p2.vec2.create();
         for(var i=0; i<gravityBodies.length; i++){
             var b =  gravityBodies[i];
             p2.vec2.scale(gravityForce,gravity,b.mass); // F_gravity = m*g
             p2.vec2.add(b.force,b.force,gravityForce);  // F_body += F_gravity
         }

         boxBody.addShape(boxShape);
         world.addBody(boxBody);
         // Add a plane
         planeShape = new p2.Plane();
         planeBody = new p2.Body();
         planeBody.addShape(planeShape);
         world.addBody(planeBody);

Thank you. You really helped me.
If you will have some free time, please tell us why, after the code block, though came across the border

When I commented code width the plane, everything looks good.

KQNMD4arjL4.jpg

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...