Help - Search - Members - Calendar
Full Version: Drawing Angled Rectangle
Game Maker Community > Working with Game Maker > Advanced Users Only
davidp
so, maybe i'm missing something, but draw_rectangle comes with 5 arguments - x, y, x2, y2, boolean.

now that's cool and everything, for basic ractangles, but i want mine to be tilted (angled, whatever) and so i have four vectors calculated (junctions of a rectangle) on the run and drawn on screen - like so:

http://www.youtube.com/watch?v=r9G1NvWJjvo
(may not be processed just yet)

so, now i could go and just draw a lines from each junction to next one, but how could i, let's say fill that area? or - use angled collision rectangle?
is there any way i could save vector x and y in ONE variable and used as, let's say x1 in draw_rectangle method or it's something else?

some code i use:

step event of drawing object:
CODE
junction1_x=lengthdir_x(32,direction+135);
junction1_y=lengthdir_y(32,direction+135);

junction2_x=lengthdir_x(32,direction+225);
junction2_y=lengthdir_y(32,direction+225);

junction3_x=lengthdir_x(32,direction+315);
junction3_y=lengthdir_y(32,direction+315);

junction4_x=lengthdir_x(32,direction+45);
junction4_y=lengthdir_y(32,direction+45);


direction+=5;


draw event:
CODE
draw_sprite(centre,0,x,y);
draw_sprite(drawJunction1,0,x+junction1_x,y+junction1_y);
draw_sprite(drawJunction2,0,x+junction2_x,y+junction2_y);
draw_sprite(drawJunction3,0,x+junction3_x,y+junction3_y);
draw_sprite(drawJunction4,0,x+junction4_x,y+junction4_y);
th15
Use the draw_primitive functions. Those allow you to define a serires of points and fill the polygon with colour or even textures.
davidp
yes, i've forgot about rectangle only filling space between two points, when I actually need 4.
tnx smile.gif
ynspyred
Or the draw_triangle function, a much-overlooked yet useful function
xot
As for collisions, a pair of collision_triangle calls would do the trick. What is collsion_triangle? Read here:

http://gmc.yoyogames.com/index.php?showtop...lision_triangle

I'm biased so I like my solution, although it doesn't work exactly like the normal collision functions.

http://www.gmlscripts.com/script/collision_triangle

If you don't require pixel perfect precision, Yourself has a simple point-in-triangle script.

http://www.gmlscripts.com/script/point_in_triangle
davidp
QUOTE (xot @ Nov 3 2009, 03:27 PM) *
As for collisions, a pair of collision_triangle calls would do the trick. What is collsion_triangle? Read here:

http://gmc.yoyogames.com/index.php?showtop...lision_triangle

I'm biased so I like my solution, although it doesn't work exactly like the normal collision functions.

http://www.gmlscripts.com/script/collision_triangle

If you don't require pixel perfect precision, Yourself has a simple point-in-triangle script.

http://www.gmlscripts.com/script/point_in_triangle


awesome stuff, i was later thinking of using triangles instead of rectangle.

thanks for the links!
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.