Physics Sandbox

This is a physics sandbox idea, using the debugDraw from the demo projects. You can draw circles, triangles, rectangles and lines. Additionally lines create joints in the following:

  • a single line will freeze an object in place
  • crossed lines will make a revolving joint. If this is inside one object that object will rotate around a pinned spot, if it is inside two objects it is a free floating joint between those objects
  • three lines like an upper case I create a rope joint. If the crosses are in objects they are free floating, otherwise they are fixed in space

The code is very messy and could do with a lot of refactoring, I was surprised how much of a headache turning drawn lines into primitive shapes was to do, this is all implemented in the “drawnObject” class.

Screen controls, the button bottom middle pauses and resumes, the clear button clears. The other button, bottom right switches between draw mode (arrow left) and drag objects mode (arrow right). This needs proper icons, but I was just using the ones out of cargobot…

No code yet as the forum doesn’t seem to like me… it’s too long for a post, what’s the easiest way for me to put it up?

It seems really interesting !
That’s weird you can’t post the code. Normally you just have to paste it between 2 “~~~”
I really want to test it!

I think this might work for code as long as I haven’t made it private or something…

It works thank you!

amazing +.+

The way you transform drawn lines into objects is really impressive. Very cool demo.

Doesnt work on codea 1.5? I just see a black screen…

I like it a lot! Thanks for sharing

.@Jmv38 it should work, FPSReporter is not included in the gist so you’ll have to comment out the use of the “myFPSReporter” variable (used in Main in the setup() function, and at the end of the draw() function.)

Very cool demo, love the way you can draw objects

Cheers !

I’ve tweaked the gist code to remove the FPSReporter (I import this from a seperate project to keep an eye on performance). I’ve also adjusted my todo’s a little and will hopefully get back onto this shortly.

My plan is to do my first couple of todos around touch handling (being able to touch lines/small objects) and improve shape detection, mainly around the fact you can’t create thin rectangles.

Then I’m going to do some heavy refactoring, as the code has got quite messy and I need to clean it up before I can come up with new things to add.

I’m interested in any ideas people have for features to add beyond that, things I can add to my todo list.

This really strange: i seem to be the only one who gets a black screen when i copy paste your code in a codea project…??? Is it ipad one?

No it’s the comments with the – in front u have to delete al those I learns that if u take from a gist it’s weird

Weird, it works for me if I copy if back from the gist, are you on an older IOS version perhaps? @Jmv38 I am running an iPad 2.

In fact iPad 1 doesn’t go to IOS 6, maybe there’s a safari issue with gist’s on IOS 5…

I’m ipad2,4 ios 6.1.2

.@Mnjk78lg thanks for the suggestion. But do you mean all comments? there is huge bunch of them…

I just ran the demo without doing anything to it. Copy from gist, paste in project, run. I’m running an iPad 1, 16gb.

Works for me too
iPad 2,1 ios 6.1.2

Well it might just be an ipad2,4 but I don’t know I just know once I deleted it , it worked the only way to less is that I realized you could delete and leave 3 lines of the comments in a row

--(random comments
--(random comments
--(random comments
{insert code here}
--(random comments
--(random comments
--(random comments

Only way it works for me hope that’s helpful
Steps I tried

  1. Delete some of comments the reput it back didn’t work
  2. Cut all comments and repaste worked but took longer