# draw_rectangle solid?

M

#### MUZZY

##### Guest
is it possible to make a rectangle with the draw_rectangle function, that will be solid(like an instance)?

thanks!

Last edited by a moderator:

#### Jordan Robinson

##### Member
What do you mean by solid? As in coloured in? Or that other instances can collide with it?

#### FredFredrickson

##### Member
GMC Elder
Yes, just set the last argument to false.

For the record, you should always check the manual for these sorts of things - it will show you what all the arguments for each function do, and give you some code samples.

M

#### MUZZY

##### Guest
What do you mean by solid? As in coloured in? Or that other instances can collide with it?
an instance

M

#### MUZZY

##### Guest
Yes, just set the last argument to false.

For the record, you should always check the manual for these sorts of things - it will show you what all the arguments for each function do, and give you some code samples.
i'm sorry, i was unclear. i ment solid, like an instance. a thing you can collide with

A

#### Aura

##### Guest
Welcome~

Please provide more information on what you are trying to do. As a rough idea, you want to check for collisions with an instance. If it is so, you can use point_in_rectangle() and give it the parameters that you used in the draw_rectangle() call. For instance, if you drew a rectangle between (200, 200) and (400, 450), you may do this:

Code:
``````if (point_in_rectangle(obj_player.x, obj_player.y, 200, 200, 400, 450))
{
// ...
}``````
Again we can't give an accurate response unless enough information is provided.

M

#### MUZZY

##### Guest
Welcome~

Please provide more information on what you are trying to do. As a rough idea, you want to check for collisions with an instance. If it is so, you can use point_in_rectangle() and give it the parameters that you used in the draw_rectangle() call. For instance, if you drew a rectangle between (200, 200) and (400, 450), you may do this:

Code:
``````if (point_in_rectangle(obj_player.x, obj_player.y, 200, 200, 400, 450))
{
// ...
}``````
Again we can't give an accurate response unless enough information is provided.

thank you very much!

#### stainedofmind

##### Member
You can also use an invisible instance (for example, the one that's doing the drawing of the rectangle!) and use 'image_xscale' and 'image_yscale' to make it be the size of the drawn rectangle. For example:

For this example, the mask of the instance will be 32x32 in size.

Create Event:
Code:
``````// The size of the drawn rectangle
size_x = 512;
size_y = 64;

// Ideally, you'll either want to create a constant for the '32' value, or use 'sprite_get_width/height' to dynamically obtain the value, but this is just an example
image_xscale = size_x / 32;
image_yscale = size_y / 32;``````
Draw Event:
Code:
``draw_rectangle(x, y, x + size_x, y + size_y, false);``
... And that's it! You should be able to collide with your drawn rectangle as if it were a normal instance with a sprite. You can even make it change size by updating the image scaling values in the step event.