Resources > Coding

[Example / Listing] GM's circles

(1/2) > >>

mit:
Wondering why this forum is so empty, I thought I'd post something interesting. While I was slightly bored yesterday, I decided to write a script that would draw lines of different thicknesses. Here it is:

--- Code: ---//draw_line_ext(x1,y1,x2,y2,thickness)
var iiiii;
for (iiiii=-(argument4/2);iiiii<=(argument4/2);iiiii+=0.5)
draw_line(argument0+lengthdir_x(iiiii,point_direction(argument0,argument1,argument2,argument3)+90),argument1+lengthdir_y(iiiii,point_direction(argument0,argument1,argument2,argument3)+90),argument2+lengthdir_x(iiiii,point_direction(argument0,argument1,argument2,argument3)+90),argument3+lengthdir_y(iiiii,point_direction(argument0,argument1,argument2,argument3)+90))
draw_circle(argument0,argument1,argument4/2,0)
draw_circle(argument2,argument3,argument4/2,0)
--- End code ---
So that works nice and dandy.
However, while I tested that, I noticed that the circles on each end were... not circles. It appears Game Maker isn't drawing circles, but drawing a polygon of 26 sides. For normal purposes this seems fine, yet, when you want it bigger than the screen, which is not often, it looks quite uncircular.

Therefore, I cam up with a "real circle" script, which was terribly fond of drawing flowers. So I ditched it and asked Atrius to make one, here it is:

--- Code: ---var dx,dy,w;
for(dy=round(argument1-argument2);dy<=round(argument1+argument2);dy+=1;) {
w=cos(arcsin((dy-argument1)/argument2))*argument2
dx=argument0-w
draw_line(round(dx),dy,round(dx+w*2),dy) }

--- End code ---

some_damn_canadian:
Wow they look pretty good. I tried them but they didn't work. I don't know if there is something I'm supposed to do to make them work but they didn't work for me. The second code is a division by 0. =/

mit:
Well, if you get division by 0, that means you've set the radius to 0. They're scripts, so you add a script and put it in and call it something like draw_realcircle and then somewhere call
--- Code: ---draw_realcircle(x,y,100)
--- End code ---


Erm, there's an example of the line drawing script here.

some_damn_canadian:

--- Quote from: mit on April 05, 2006, 05:34:59 pm ---Well, if you get division by 0, that means you've set the radius to 0. They're scripts, so you add a script and put it in and call it something like draw_realcircle and then somewhere call
--- Code: ---draw_realcircle(x,y,100)
--- End code ---


Erm, there's an example of the line drawing script here.

--- End quote ---

Ahhhh, no wonder nothing was working for me. I'll edit my post with what I get. n__n

EDIT : The second script worked for me, it's great. n__n But I just couldn't get the first to work. =/

mit:
There's an example of the first one, here: http://www.kousougames.co.uk/stuff/draw_line_ext.zip

Navigation

[0] Message Index

[#] Next page


Contact Us | Legal | Advertise Here
2013 © ZFGC, All Rights Reserved



Go to full version