Giter VIP home page Giter VIP logo

Comments (2)

soulwire avatar soulwire commented on June 10, 2024

CoffeePhysics isn't a rigid body engine, so it doesn't currently handle polygon collisions in that way.

One option you have is to make your square from 4 particles, connected by very stiff springs. Connect them around the perimeter of the square and in a cross. Something like:

var squareSise = 50;

// Corners
var tl = new Particle();
var tr = new Particle();
var br = new Particle();
var bl = new Particle();

// Perimeter
var s1 = new Spring(tl, tr, 50, 1.0);
var s2 = new Spring(tr, br, 50, 1.0);
var s3 = new Spring(br, bl, 50, 1.0);
var s4 = new Spring(bl, tl, 50, 1.0);

// Cross
var s5 = new Spring(tl, br, 50, 1.0);
var s6 = new Spring(bl, tr, 50, 1.0);

This will bounce off walls, thought there might be some slight elasticity as the springs compress. Also, collisions between squares won't be handled if 2 rotated squares intersect.

If you need this kind of behaviour, I suggest you use a rigid body engine like Box2d :)

from coffee-physics.

noobiept avatar noobiept commented on June 10, 2024

Hey, thanks for the help.

I tried doing that but the collision detection isn't working. I'm trying to have the ball stop at the platform. If you could give this a look, I'd really appreciate it.

https://gist.github.com/4121971

(I'm using createjs, don't know if you're familiar, but I can explain if you don't understand)

from coffee-physics.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.