Blijbol, happy business   Dutch English

Links About Blijbol Guestbook
Home News Games Software Game Maker
Downloaded 304 times

Regular polygons

Easily draw regular polygons


This script can be used to draw regular polygons. These polygons may exist of any number of edges and can have any size. The shape can also be drawn in different ways, and can be rotated around its center with a custom number of degrees. To discover what all parameters do, an example is also available.


draw_polygon ( x, y, edges, radius, kind [, closed [, rotation]] )
Draws a regular polygon.
x: x-co÷rdinate of the center
y: y-co÷rdinate of the center
edges: number of edges, at least 3
radius: radius in pixels
kind: one of the following values:
pr_pointlist: draws points on the edges
pr_linelist: only draws the first side of every pair of sides
pr_linestrip: draws the full perimeter
pr_trianglelist: draws separated triangles to the inside of the sides
pr_trianglestrip: draws colliding triangles to the inside of the sides
pr_trianglefan: draws the full surface
closed: whether the polygon is closed (true) or one side is open (false, default)
rotation: rotation in degrees around the center, counter-clockwise (default no rotation)
#define draw_polygon
var xpos, ypos, rot, dir, side;
xpos = argument0 - lengthdir_y(argument3, argument6);
ypos = argument1 + lengthdir_x(argument3, argument6);
rot = 360 / argument2;
dir = argument6 + rot / 2;
side = sqrt(32) * argument3 / argument2;
  draw_vertex(xpos, ypos);
  xpos += lengthdir_x(side, dir);
  ypos += lengthdir_y(side, dir);
  dir += rot;
 draw_vertex(xpos, ypos);

Version 1.0 (stable)

Release date: 20 August 2006
Language: Dutch
System requirements: Game Maker 6.0 or later (Pro/registered edition required)

Project status

A stable version of this product has been released. The project was announced at 20 August 2006.


This script has been written by Jeroen van der Gun. It is highly appreciated to mention this in the credits of your game.

More for Game Maker


No comments have been posted yet. Use the form to post one.

Add a comment

2 × 10 =
Blijbol =