Comments (2)
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.
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)
- Canvas renderer caching
- Example in README doesn't work HOT 1
- Attraction and Repulsion increased HOT 1
- Demos are all broken HOT 3
- Existing example without canvas
- Custom renderer for Framer
- Time-Corrected Verlet Integrator HOT 1
- images in experimental-webgl HOT 1
- Collision Behaviour Index Out of bounds bug HOT 1
- Sats not defined
- performance.now support
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from coffee-physics.