GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2019-08-08 15:15:32

ClunkyDev
Member
Registered: 2019-08-08
Posts: 1

draw_collision_mask()

I made a script that draws a simple rectangular collision mask of an instance:

Expand/// draw_collision_mask(color)
//
//  Draws a collision mask of an instance as a rectangle
//
//      color       color of drawn mask
//
/// GMLscripts.com/license
{
	var color;
	color = argument0;
    draw_set_color(color);
	draw_set_alpha(0.1);
	draw_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,false);
	draw_set_alpha(0.3);
	draw_rectangle(bbox_left,bbox_top,bbox_right,bbox_bottom,true);
	draw_set_alpha(1);
}

Last edited by ClunkyDev (2019-08-08 15:17:34)

Offline

#2 2019-08-08 17:05:18

xot
Administrator
Registered: 2007-08-18
Posts: 1,239

Re: draw_collision_mask()

This could be really useful for debugging and maybe effects too. The only thing I'd add is some code to restore global color and alpha values.

Welcome to the forums and thanks for the script.


Abusing forum power since 1986.

Offline

#3 2022-12-16 00:43:37

felres
Game Designer
From: CR
Registered: 2021-05-22
Posts: 4
Website

Re: draw_collision_mask()

Does this work for rotated sprites?

Offline

#4 2023-03-09 19:00:03

gnysek
Member
Registered: 2011-12-29
Posts: 36

Re: draw_collision_mask()

For sure it doesn't as draw_rectangle doesn't draws rotated rectangles.

Offline

Board footer

Powered by FluxBB