• 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!

Surface makes sprite look worse

Rivo

7014
Here is a pic of what my inventory looks like when drawn to the room without the surface:
Screenshot_185.jpg
Here's what it looks like when drawn to a surface:
Screenshot_186.jpg

The sprites are drawn separate. It can't be an issue with them overlapping since they are placed next to each other pixel perfect. So why is this happening? I know the difference is only small but I need it to be perfect. Can someone please help?

Code:
/// Draw inventory to surface

if !surface_exists(InvSurf) {InvSurf = surface_create(view_wview, view_hview);}
surface_set_target(InvSurf);

// draw base
draw_sprite(sBase, 0, view_xview+(view_wview)/2, view_yview+(view_hview)/4);

// draw descriptions
draw_sprite(sTLDescription, 0, ((view_xview+(view_wview)/2)-85)-55, view_yview+(view_hview)/4);
draw_sprite(sBLDescription, 0, ((view_xview+(view_wview)/2)-85)-55, (view_yview+(view_hview)/4)+64);

// draw scroll bar
draw_sprite(sScrollBar, 0, ((view_xview+(view_wview)/2)+85), (view_yview+(view_hview)/4)+28);

// draw exit button
draw_sprite(sExitButton, 0, ((view_xview+(view_wview)/2)+85), (view_yview+(view_hview)/4)-1);

surface_reset_target();

// draw surface
draw_surface(InvSurf, view_xview, view_yview);
 

Simon Gust

Member
Something that definetly strikes my brain is that you supply view coordinates when drawing to a surface.
You should also make sure to call
Code:
draw_clear_alpha(0, 0);
after you set the surface target and before you draw anything to the surface.
 

Rivo

7014
Okay then so, here's some new code I tried
Code:
if !surface_exists(InvSurf) {InvSurf = surface_create(room_width, room_height);}
surface_set_target(InvSurf);

draw_clear_alpha(0, 0);

// draw base
draw_sprite(sBase, 0, view_xview+(view_wview)/2, view_yview+(view_hview)/4);

// draw descriptions
draw_sprite(sTLDescription, 0, ((view_xview+(view_wview)/2)-85)-55, view_yview+(view_hview)/4);
draw_sprite(sBLDescription, 0, ((view_xview+(view_wview)/2)-85)-55, (view_yview+(view_hview)/4)+64);

// draw scroll bar
draw_sprite(sScrollBar, 0, ((view_xview+(view_wview)/2)+85), (view_yview+(view_hview)/4)+28);

// draw exit button
draw_sprite(sExitButton, 0, ((view_xview+(view_wview)/2)+85), (view_yview+(view_hview)/4)-1);

surface_reset_target();

// draw surface
draw_surface(InvSurf, 0, 0);
Still doesn't work :/
 

Simon Gust

Member
Try this
Code:
if !surface_exists(InvSurf) {InvSurf = surface_create(view_wview, view_hview);}
surface_set_target(InvSurf);

draw_clear_alpha(0, 0);

// draw base
draw_sprite(sBase, 0, view_wview / 2, view_hview / 4);

// draw descriptions
draw_sprite(sTLDescription, 0, (view_wview / 2 - 85) - 55, view_hview / 4);
draw_sprite(sBLDescription, 0, (view_wview / 2 - 85) - 55, view_hview / 4 + 64);

// draw scroll bar
draw_sprite(sScrollBar, 0, view_wview / 2 + 85, view_hview / 4 + 28);

// draw exit button
draw_sprite(sExitButton, 0, view_wview / 2 + 85, view_hview / 4 - 1);

surface_reset_target();

// draw surface
draw_surface(InvSurf, 0, 0);
And then draw the surface in the draw GUI event
 

Rivo

7014
Yeah that didn't work either. I need it drawn on a normal draw event anyway.
I like to use surface_save() when debugging surfaces. It can help nail down whether the glitch is happening as you're drawing sprites to the surface, or when you're drawing the surface to the screen.

https://docs.yoyogames.com/source/dadiospice/002_reference/surfaces/surface_save.html

It's an odd glitch indeed. Try rounding all your coords just to see.
I'll try rounding the coords then I guess, and see what happens...
 

Rivo

7014
Last edited:
Top