• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Misaligned drawing?

LazyTomato

Member
Heya! I'm working on a platformer right now, implementing water mechanics to be precise.
What i'm doing here is using "water blocks" to mark the areas that are going to be filled with water, stretching them out, and then these blocks will draw a semi-transparent rectangle over the area they cover. So far so good, it works out perfectly.

...Except for one problem i'm having.
Since these blocks are square, i need to use multiple ones to fill in specific sections of water when the basic shape doesn't quite make the cut.
Here's an example of what i'm doing, in the room editor:
As you can see, it's a bigger water block on the left filling in the bigger vertical area, and then a second smaller water block to fill in this lower exit i've placed.
The positioning itself is perfect, and the horizontal scale of each of these blocks is also perfect integer numbers (the basic scale of each block being 64x64).

However, when i actually run the game itself, the drawing seems to be misaligned, and there's a 1-pixel overlap between the two blocks, even if it's not visible in the room editor:
(ignore the graphics, it's all placeholders for now; also the little top part of the water is an additional piece of code that draws a looping surface sprite above the water block)

As you can see, even though the positioning is pixel-perfect and there's seemingly nothing that should go wrong here, the overlap is still there and looks off with the water's inherent transparency.
Is this some sort of bug in the engine itself? Is there something i could do to fix this?

Here's the drawing code i use in these blocks, by the way:
Code:
draw_set_alpha(0.47);
watercol=make_color_rgb(0,168,232);
draw_rectangle_color(x,y,x+(image_xscale*64),y+(image_yscale*64),watercol,watercol,watercol,watercol,false);
draw_set_alpha(1);
(there's more code after this for the little extra surface sprites but it's irrelevant to the issue)

It doesn't seem like there should be anything wrong with the code itself, but the problem is still there, and persists even after clearing the asset cache.
I've also tried adding rounding functions to the drawing positions in the code but that doesn't seem to fix the issue either.
 
You could always draw it 1 pixel to the right. But another solution would be to draw the whole thing to a surface with no transparency, then draw the surface with transparency, which should eliminate the blended transparency in the overlapping sections.
 
S

Sn3akyP1xel

Guest
It doesn't seem like there should be anything wrong with the code itself, but the problem is still there, and persists even after clearing the asset cache.
I've also tried adding rounding functions to the drawing positions in the code but that doesn't seem to fix the issue either.
I have this exact same issue and have done the same as yourself with rounding/floor/ceil but all failed to resolve. I suspect it's scaling related.

edit update - Yes it's a scaling issue.
I get this when using my wip camera zoom feature, the view is trying to draw your graphic as a pixel fraction which it can't do. So it pushes the graphics 1px over the other object or away from it by 1px.
Need to make sure your view is drawing the correct number of pixels and it will be resolved.
 
Last edited by a moderator:
Top