0 Favourites

How do I Draw Obstacles??

  • The concept I am trying to achieve, is to allow the user to draw lines such as if you were drawing in paint and then make these lines an object which is added to a new layout where the player must navigate around this obstacle. What is the best way to create drawing lines that are smooth and effortless, and how would this drawing be transferred into the second layout?

    Thanks guys

  • You can do it with a sprite that has it's origin at the left-center. It's height is the thickness and if you make it global it will survive till the next layout. The events to draw it is below. You can also create a circle sprite at the mouse to make the line look better at angles. You then can make the created objects solid or something.

    global number oldx=0

    global number oldy=0

    on left click

    --- set oldx to mouse.x

    --- set oldy to mouse.y

    left mouse is down

    --- create sprite at (mouse.x, mouse.y)

    --- sprite: set angle toward (oldx,oldy)

    --- sprite: set width to distace(self.x,self.y,oldx,oldy)

  • You can do it with a sprite that has it's origin at the left-center. It's height is the thickness and if you make it global it will survive till the next layout. The events to draw it is below. You can also create a circle sprite at the mouse to make the line look better at angles. You then can make the created objects solid or something.

    global number oldx=0

    global number oldy=0

    on left click

    --- set oldx to mouse.x

    --- set oldy to mouse.y

    left mouse is down

    --- create sprite at (mouse.x, mouse.y)

    --- sprite: set angle toward (oldx,oldy)

    --- sprite: set width to distace(self.x,self.y,oldx,oldy)

    Thanks for the response R0j0. see i had something like this before and the problem I get from it is that it is not a straight line it looks like this:

    Like its attached to an origin

  • Oh, right. I forgot to add these two actions to the second event:

    --- set oldx to mouse.x

    --- set oldy to mouse.y

    That should fix it.

  • Oh, right. I forgot to add these two actions to the second event:

    --- set oldx to mouse.x

    --- set oldy to mouse.y

    That should fix it.

    Thanks again for this.

    See I am running in to the same problem i had before in that it is not a smooth, but jagged and gapped.

    I have attached here what I mean:

    Thanks,

    Harraj

  • https://

    drive.google.com/open?id=0B1SSuCVV8v74ODZ4cnBMYmZuOFk

    It will still jagg if the mouse is to fast.

    How more dense sprite3 how smoother.

    R0J0hound has made a MUCH better physics plugin with better joints.

    But if i use a plugin, he aint opening my capx.

    With his plugin you can make the joints pull depending on the speed of the mouse.

    And another plus: framerate is not dropping at all, it drops when u scale, position & rotate towards.

    You can, ofcourse, make the mouse invisible with a transparant sprite set to it.

  • Make a circle Sprite whose diameter is the same as the width. Then just create one of those at the mouse while the mouse button is down.

  • Make a circle Sprite whose diameter is the same as the width. Then just create one of those at the mouse while the mouse button is down.

    I have tried creating a circle, by basically using the paint brush and drawing a dot then resizing it to the dot size, but still the same problem. Is there another way to create an actual circle as the sprite is still a square if that makes sense??

  • dl.dropboxusercontent.com/u/5426011/examples33/draw_line.capx

    Thank you so much for that!!! So I have now created it as an object, which is a boundary but now it is coding it to remember the position, so it remains on the next layout. Any clue on this or some sort of basic tutorial in which I can learn it?

    thanks,

    harraj

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • hmann128

    There are a few ways to do it. The simplest is to make the objects global so they won't be destroyed when the layout changes.

    Another idea is to store the object's info in an array, then looping over the array to re-create from that. Here's one possible example:

    This may be an overkill for what you want, but the idea is there.

  • hmann128

    There are a few ways to do it. The simplest is to make the objects global so they won't be destroyed when the layout changes.

    Another idea is to store the object's info in an array, then looping over the array to re-create from that. Here's one possible example:

    This may be an overkill for what you want, but the idea is there.

    Hey R0j0,

    what route would you recommend in this scenario:

    The player draws a route and this route is shown on the next layout in which the player must navigate the layout. Once the player has completed this layout the game finishes. The game then restarts and allow the player to draw a new route. Idk if that makes sense but im guessing making the objects global may not be able to apply to what I am trying to do?

  • Just make the objects global and destroy them at the start of the first layout.

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