How do I draw lines with physic behavior?

0 favourites
  • 6 posts
From the Asset Store
solution for games like "fruit ninja" and drawing applications
  • Hi,

    I was wondering if it would be possible to reproduce the gameplay of drawing physics games.

    For example:

    Crayon Physics Deluxe

    Subscribe to Construct videos now
  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • The main challenge that I am seeing is how you would allow the user to create a sprite shape and then the computer will dynamically know the boundary of that shape. I know you can create any shape you want and change the bounding box to fit that shape. But that customization of the bounding box is done by the designer of the game. I'm not sure if it's possible to give the user the ability to do that on the fly.

    But to answer your initial question of how to draw lines with physics behavior, it sounds like you are asking two different questions. If the question was just how do you add physic characteristics to a line, than that's easy as you would just draw a sprite that looks like a line and give it the behavior or physics. But you're probably asking more about the drawing part meaning how does a user dynamically create a sprite with a fitted bounding box and that's of course the hard part.

    So to answer your question, I don't know. But I'd be interested if it can be done.

  • alight, here is a commentary, and a solution for you too look deeper for a better solution if possible.

    When manually writing game code for BOX2D and other physics engines. The programmer has the ability to set vector points for the collision shape. I don't know if C2 allows for setting collision shapes during run time. However you might be able find a plugin. If not you can try to use the answer below.

    10px lines.

    As you have your mouse(or touch) start drawing. draw graphical lines with no physics. These lines are done in 10px spurts burts by startx/y when first touching and when the mouse move a distance of 11px away lock the fgx line in start a new 10px line. keep this up until the player released or some other limit is met.

    when then player released the mouse, iterate through each of the 10px lines and create a new line which is a PhysicsLine and joint each pLine to the previous. Now you have a physics shape.

    you might be able to get away with more than 10px. Experiment as you would like.

  • guys! thanks for answering and sorry for delaying on feedback due to vacations!

    well...

    : you are right, I know how to handle with physics on C2, my question is more about drawing lines and then turn then physic objects.

    jayderyu: you approach seems very reasonable. I tried before something like this but I didnt use a 10px threshold. I will give a shot on this suggestion and then I report my results.

    Thanks again!

  • It's very possible, there another HTML5 version of this game.

    http://scotland.proximity.on.ca/asalga/crayonphysics/

    I doubt if it can be done by loop, i couldn't help you.

    Anyways, there a quick and dirty trick to create static physic objects according to this

    http://www.scirra.com/forum/plugin-unistroke-gesture-recognizer_topic48720.html

  • Joannesalfa Nice example!

    Unitroke plugin also may give some lead... maybe the way would be create a plugin for that... (of course I am procrastinating it, but may be the time to show that I am a man not a rat).

    Thanks!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)