0
\$\begingroup\$

I have a game where objects follow a path that resembles a circuit (f1, nascar, stock car).

Using the draw_path function, I can draw the circuit on the game screen:

enter image description here

It turns out that dash got too thin.

To thicken the drawing line and actually look like a circuit (so I don't have to sprite and put in the background) I tried the following (Draw Event):

draw_path(circuito_ovo,500,50,false);
draw_path(circuito_ovo,501,51,false);
draw_path(circuito_ovo,502,52,false);
draw_path(circuito_ovo,503,53,false);
draw_path(circuito_ovo,504,54,false);
draw_path(circuito_ovo,505,55,false);
draw_path(circuito_ovo,506,56,false);

The result was not as expected (detail I added a unit in two dimensions, I thought the secret would be this):

enter image description here

\$\endgroup\$
4
  • \$\begingroup\$ I just found a possible solution, anyway any help is valid. \$\endgroup\$ Commented Sep 30, 2019 at 23:49
  • \$\begingroup\$ Did your possible solution helped you out? If so, would you mind telling it as an answer? \$\endgroup\$
    – Steven
    Commented Oct 1, 2019 at 6:56
  • 1
    \$\begingroup\$ Did you try drawing rectangles instead? Also as @Steven noted, if your problem is resolved, make sure to put an answer explaining how you solved it. There are other readers that might have the same problem as you, and would love to know what your solution was :) \$\endgroup\$ Commented Oct 1, 2019 at 8:39
  • \$\begingroup\$ I was optimizing the solution I found, I just added an answer. \$\endgroup\$ Commented Oct 3, 2019 at 0:52

2 Answers 2

1
\$\begingroup\$

This will draw a red diagonal line, 6 pixels wide, from point (100,100) to point (200,200).

draw_set_colour(c_red);
draw_line_width(100, 100, 200, 200, 6);

Taken from: https://docs2.yoyogames.com/source/_build/3_scripting/4_gml_reference/drawing/forms/draw_line_width.html

I can foresee you will have corner issues as the adjoining lines corner won't meet up. It will become more obvious as you thicken the lines and the two angles are extreme.

That is more tricky to solve given you need to work out the corners for each line taking thickness into account and join those with the previous line corners. Quite a bit of maths and code involving atan2, cos and sin is required to make this work correctly.

\$\endgroup\$
1
  • \$\begingroup\$ Search for "graphic gems 1" and open link to pdf - jump to page 108 - the diagram on that page will show you what you will be faced with when doing it this way. \$\endgroup\$
    – John
    Commented Oct 2, 2019 at 3:12
0
\$\begingroup\$

Adding 1 to each dimension just isn't enough.

It would have to be something like:

draw_path(circuito_ovo,500,50,false);
draw_path(circuito_ovo,500,51,false);
draw_path(circuito_ovo,500,52,false);

draw_path(circuito_ovo,501,50,false);
draw_path(circuito_ovo,501,51,false);
draw_path(circuito_ovo,501,52,false);

draw_path(circuito_ovo,502,50,false);
draw_path(circuito_ovo,502,51,false);
draw_path(circuito_ovo,502,52,false);

For ease just use the repeat function (Draw Event):

repeat(5){
    repeat(5){
        draw_path(circuito_ovo,500+i,50+j,false);
        j+=1;
    }
    i+=1;
    j=0;
}

i=0;
j=0;

Initializing the variables with the value 0 (i and j), or negative (if I want the object to be walked exactly in the center of the drawing).

The number of times the repeat function will execute will be equal to the line thickness.

Result:

enter image description here

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .