I’ve long wondered about the possibility of making a rudimentary fake-3D-physics simulator in Codea.
I think I don’t have the time or the math or the Codea/Lua chops for it, but I’ll describe my concept and hopefully find out from you guys if it would theoretically work.
As far as I’ve figured it out, it can only work with spheres. Here’s what you do.
First, on your 2D physics simulator, you make 2 circles of the same size that can’t touch each other, that won’t collide, that will just pass right through each other, BUT that are constrained to always share the same y value.
You make each of them bouncy and make them bounce off the sides of the screen too.
Then in 3D space you define two planes that are perpendicular to each other, and that intersect in the middle, so that from overhead they’d look like an x. Let’s call them plane A and plane B.
Then you create a sphere of the same size as the circles, and you define x value of the the circle in plane A as the x value of this sphere, and the x value of the circle in plane B as the Z value of the sphere, and the common Y value as the sphere’s y.
Then when you ran the thing, you would see a 3D ball appearing to bounce around in a box… right?
I think you could also define another ball that would collide with the first–again you give it two 2D circles to map its x and z values to, but you make the new sphere’s x circle only collide with the other sphere’s x circle, and its z circle only collide with the other z circle. Then the new sphere would know whenever it collided with the other one on either axis, and you’d see two balls bouncing around in a box, and bouncing off of each other to boot.
I’ve never gone to the trouble to build this, partially because I don’t think it’s good for much beyond this simple trick, and partially because I’m not totally sure it would work.
Would it work?