How to draw objects and apply physics to it

0 favourites
  • 7 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hi guys, Am complete beginner to construct 2. I want to develop a platform game where players will draw objetcs (basic shapes) and physics will be applied to it.

    I found similar drawing and physics game: "http://armorgames.com/play/4673/test-pilot".

    If anyone can tell where to get started and is it possible in construct 2 or not, it'll be great.

    Thanks

  • There is nothing in place to help with that. With the physics behavior the shapes need to be defined in the editor before the game is run. You could use the canvas or paster plugins to draw the object though.

    One idea could be to build the shapes out of a bunch of simpler objects and join them together with joints, but that does have some issues. Namely objects joined together with joints behave a bit spongy.

    A better solution is to work with the physics engine at a lower level using javascript, although you can't really do this along with the physics behavior. More on this in a moment.

    The basic flow of your game would be to:

    1. when you draw the shape a list of points is made.

    2. Those points make up a polygon. This needs to be converted to a list of triangles or at least convex polygons. This is mainly for the physics engines which generally don't work with concave polygons.

    3. find the center of mass by averaging the point locations.

    4. create the physics object with that shape.

    That may vary depending on what a given physics engine does for you.

    Here's one possible example of using javascript to access a physics engine instead of using the behavior:

    https://www.dropbox.com/s/314g422gfjlv2 ... .capx?dl=1

    /5426011/examples34/jsPhysics.capx

    On another note you did say simple objects. You probably could use some gesture recognition to see if the object is close to a circle, square or triangle. Then add a sprite with that shape and size and orient it to approximately match the area drawn. The gesture recognition is something a plugin may be able to help you with, or maybe even some other capx on the forum.

  • There is nothing in place to help with that. With the physics behavior the shapes need to be defined in the editor before the game is run. You could use the canvas or paster plugins to draw the object though.

    One idea could be to build the shapes out of a bunch of simpler objects and join them together with joints, but that does have some issues. Namely objects joined together with joints behave a bit spongy.

    A better solution is to work with the physics engine at a lower level using javascript, although you can't really do this along with the physics behavior. More on this in a moment.

    The basic flow of your game would be to:

    1. when you draw the shape a list of points is made.

    2. Those points make up a polygon. This needs to be converted to a list of triangles or at least convex polygons. This is mainly for the physics engines which generally don't work with concave polygons.

    3. find the center of mass by averaging the point locations.

    4. create the physics object with that shape.

    That may vary depending on what a given physics engine does for you.

    Here's one possible example of using javascript to access a physics engine instead of using the behavior:

    https://dl.dropboxusercontent.com/u/542 ... ysics.capx

    On another note you did say simple objects. You probably could use some gesture recognition to see if the object is close to a circle, square or triangle. Then add a sprite with that shape and size and orient it to approximately match the area drawn. The gesture recognition is something a plugin may be able to help you with, or maybe even some other capx on the forum.

    Thanks a lot.

    Yes shapes are basic (Circle, Rectangle, Triangle or upto 5 faces max).

    Since, shapes has to be defined, is it possible that through canvas or paster, player defines a shape. There will be start button, then once player presses it, those shapes will be given physics behavior. Then some simulation happens. Can this be done ??

  • All the paster and canvas give you is an image. There collision shape is fixed as a box.

    Physics will have to done in another way. The example above is one, making a bunch of different sized sprites beforehand is another I guess.

    In short, basically anything can be done. In this case it's not something that's not made simple with existing things in C2 so instead you have to use some inginuity to get it working.

  • Have you seen this, vinigames ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks a lot R0J0hound and

    Polygon is interesting for what I'm doing. As R0J0hound suggested will have to work in JavaScript or underlying layers. With Polygon plugin, I must be able to achieve what I intend to do.

  • I have to check this out. I was trying to make something similar, on touch draw a dot. On hold every x seconds draw another. On release set them to "on"... this makes loads of physics balls appear and fall independently .. pin does nothing for physics objects.haven't tried joints however, would a joint connecting each joint to the rest make this more solid perhaps?

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