GameMaker draw_rectangle Outline is being drawn at a y+1 offset [SOLVED. Sorta.]

AnalogF6

Member
I swear this feels like a bug in GMS 2. I can't reproduce it in other project files, but in my main project I have the following code:

Code:
           draw_set_color(c_aqua)
           draw_rectangle(x-4,y-13,x+4,y-3,false)
           
           
           draw_set_color(c_yellow)
           draw_rectangle(x-4,y-13,x+4,y-3,true)
The result is... nonsensical. The rectangle without an outline is drawn at the expected location, but if it has an outline, it draws the rectangle offset down one pixel. I can change the yellow rectangle in the code to draw one pixel higher and it draws as expected.

If I copy the same code into another project, though, this does not happen.

upload_2019-7-19_14-40-10.png

As you can see here, the c_aqua rectangle is visible one pixel over the c_yellow rectangle, despite both using the same coordinates.

I know that the coordinate isn't actually changing between these steps, because I've tried writing all the coordinates to the debug output at each point in the code, and the numbers never change. It's just when GMS2 attempts to write to the screen that it handles the outline rectangle differently from the solid one.

Any ideas? This is absolutely baffling to me.
 

AnalogF6

Member
I actually may have found the answer, funnily enough. Sorry for the quick post, but it doesn't entirely explain the behavior IMO.

I changed the window/camera/port height from 77 to 78, and that resolved the issue. That was after finding this thread:

https://forum.yoyogames.com/index.p...sting-thing-about-draw-line-or-outline.50714/

Apparently, these draw functions happen at the intersection of pixels and round up to the pixel. I was also able to replicate this with a view height that was an odd number.

So, lesson learned. For some reason, gamemaker studio (2) places outlines on draw functions "between" pixels, so if you are working with an odd number, it can sometimes draw using the next pixel. It can't "draw" on an in-between pixel, after all.
 
Top