draw_line() (Game Maker)

draw_line()

(Game Maker 6.1, 7)

draw_line - draw a line between two points

Description

draw_line ( x1, y1, x2, y2 )

  • x1 - x-position of point one
  • y1 - y-position of point one
  • x2 - x-position of point two
  • y2 - y-position of point two

draw_line() draws a line between two points in the current drawing color.

Examples

Example of Use

draw_set_color(c_red);
draw_line(0,0,room_width,room_height);

The code in this example will draw a red, diagonal line from the top/left of the a [[room]] to the bottom/right corner.

Missile Line / Trail

draw_set_color(c_white);
draw_line(xstart,ystart,x,y);

The code in this example will draw a white line from a missile's starting position to its current position. Useful for games like Missile Command.

Lazer

draw_set_color(c_aqua);
draw_line(x,y,mouse_x,mouse_y);

The code in this example will draw an aqua line between the object executing the code and the mouse location. Useful for mouse controlled lasers.

Related Pages

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution 2.5 License.