Shapes currently supported: Rectangles, Lines, Circles, Ellipses
Shapes I plan on adding: Triangles
Make rotating 2D shapes EASY with these scripts!
Features:
- Fast and easy using regular game maker's built in draw_ functions
- Rotate to any angle (0-360)
- Change the point of rotation
- If the last argument: 'show marker' is set to true, a small red cross is drawn at the point of rotation, making it easy for you to check where you want your point of rotation to be used
Note that most scripts in places have 'width' and 'height' instead of x2 and y2.
The Scripts
//use as: draw_rectangle_rotated(x,y,width,height,outline,
//angle,rotatepoint_x,rotatepoint_y,show_marker);
//argument0 = x
//argument1 = y
//argument2 = width
//argument3 = height
//argument4 = outlined rectangle? (true/false: use false for a filled rectangle)
//argument5 = angle of rotation
//argument6 = x co-ordinate of the point of rotation (relative)
//argument7 = y co-ordinate of the point of rotation (relative)
//argument8 = mark rotation point? (true/false: use false for no marker)
//NOTE: rotation point(argument2/2,arguemnt3/2) is the center
{
//Set the rotation
d3d_transform_set_rotation_z(argument5);
//Set the translation
d3d_transform_add_translation(argument0,argument1,0);
//Draw the rectangle
draw_rectangle(-argument6,-argument7,argument2-argument6,argument3-argument7,argument4);
//Set identity
d3d_transform_set_identity();
//Draw the point of rotation when needed
if (argument8)
{
var oldcol;
oldcol=draw_get_color();
draw_set_color(c_red);
draw_line(argument0-8,argument1,argument0+8,argument1);
draw_line(argument0,argument1-8,argument0,argument1+8);
draw_set_color(oldcol);
}
}//use as: draw_line_rotated(x,y,width,angle
//,rotatepoint_x,rotatepoint_y,show_marker);
//argument0 = x
//argument1 = y
//argument2 = width
//argument3 = angle of rotation
//argument4 = x co-ordinate of the point of rotation (relative)
//argument5 = y co-ordinate of the point of rotation (relative)
//argument6 = mark rotation point? (true/false: use false for no marker)
//NOTE: rotation point(argument2/2,0) is the center
{
//Set the rotation
d3d_transform_set_rotation_z(argument3);
//Set the translation
d3d_transform_add_translation(argument0,argument1,0);
//Draw the line
draw_line(-argument4,-argument5,argument2-argument4,-argument5);
//Set identity
d3d_transform_set_identity();
//Draw the point of rotation when needed
if (argument6)
{
var oldcol;
oldcol=draw_get_color();
draw_set_color(c_red);
draw_line(argument0-8,argument1,argument0+8,argument1);
draw_line(argument0,argument1-8,argument0,argument1+8);
draw_set_color(oldcol);
}
}//use as: draw_circle_rotated(x,y,radius,outline,angle
//,rotatepoint_x,rotatepoint_y,show_marker);
//argument0 = x
//argument1 = y
//argument2 = radius
//argument3 = outlined circle? (true/false: use false for a filled circle)
//argument4 = angle of rotation
//argument5 = x co-ordinate of the point of rotation (relative)
//argument6 = y co-ordinate of the point of rotation (relative)
//argument7 = mark rotation point? (true/false: use false for no marker)
//NOTE: rotation point(0,0) is the center
{
//Set the rotation
d3d_transform_set_rotation_z(argument4);
//Set the translation
d3d_transform_add_translation(argument0,argument1,0);
//Draw the circle
draw_circle(-argument5,-argument6,argument2,argument3);
//Set identity
d3d_transform_set_identity();
//Draw the point of rotation when needed
if (argument7)
{
var oldcol;
oldcol=draw_get_color();
draw_set_color(c_red);
draw_line(argument0-8,argument1,argument0+8,argument1);
draw_line(argument0,argument1-8,argument0,argument1+8);
draw_set_color(oldcol);
}
}//use as: draw_ellipse_rotated(x,y,width,height,outline
//,angle,rotatepoint_x,rotatepoint_y,show_marker);
//argument0 = x
//argument1 = y
//argument2 = width
//argument3 = height
//argument4 = outlined ellipse? (true/false: use false for a filled rectangle)
//argument5 = angle of rotation
//argument6 = x co-ordinate of the point of rotation (relative)
//argument7 = y co-ordinate of the point of rotation (relative)
//argument8 = mark rotation point? (true/false: use false for no marker)
//NOTE: rotation point(argument2/2,arguemnt3/2) is the center
{
//Set the rotation
d3d_transform_set_rotation_z(argument5);
//Set the translation
d3d_transform_add_translation(argument0,argument1,0);
//Draw the ellipse
draw_ellipse(-argument6,-argument7,argument2-argument6,argument3-argument7,argument4);
//Set identity
d3d_transform_set_identity();
//Draw the point of rotation when needed
if (argument8)
{
var oldcol;
oldcol=draw_get_color();
draw_set_color(c_red);
draw_line(argument0-8,argument1,argument0+8,argument1);
draw_line(argument0,argument1-8,argument0,argument1+8);
draw_set_color(oldcol);
}
}Downloads
Download example (gm8): mirror1|mirror2|mirror3
Download example (gm7): mirror1|mirror2|mirror3
Download example (gm6): mirror1|mirror2|mirror3
Download example (gmres): mirror1|mirror2|mirror3
Download scripts (gml): mirror1|mirror2|mirror3
Download all as zip: mirror1|mirror2|mirror3
This topic probably could be a load better, But this the first piece of work I've published on the GMC, so you might expect that
Feedback would be great!, The Glutex Master
Credit not needed, but it would be nice
Edited by Glutex Master, 08 January 2011 - 09:34 PM.












