Fixing Distorted Pixels?

D

dodash

Guest
Hi!

I started working with Game Maker just the other day. So far the experience has been completely engrossing, I love it! And so I thought it would be a good idea to join this forum.

I am currently working on my very first project. It is still no more than an experiment really, where I get to play around and learn the basics of developing in game maker. However I do have some perfectionistic tendencies and there is one thing I just cannot stand, even for a play-around, first time project. Distorted pixels.

So basically what I have so far is one room, one controllable character and some other objects for scenery. The room is 3200x480 pixels and scrolls sideways as the character moves. I have set the view of the room to be 920x480 pixels. Eventually I will want it to be scaled up by a factor of 2 but for now this is fine. I have not changed any settings or used any commands related to resolution, scaling, etc.

What happens when I run the game is that it gets scaled up by 125%. The view is, as mentioned above, set to 920x480 but the game is displayed at 1200x600. I actually measured the pixels. In no way have I requested this scaling from the program and it's really killing my pixel art. The pixels are all blurred so some interpolation seems to be used. Why does this happen?

I have tried to change the view size to 80% of what I mentioned above to compensate for this scaling. Still blurred pixels. I also tried messing around with the application_surface using some surface commands. More specifically I used:

application_surface_draw_enabled(false);
surface_resize(application_surface,920,480);

on the create event of an object in the room and then

draw_surface_ext(application_surface,480,240,1,1,0,c_white,1);

on the step event of the same object. I read in a guide on this forum that you could do this to assure pixel perfect display. However, what happens with this when I run the game is that I get an error immediately that reads:

Trying to use non-existing surface.
at gml_Object_obj_spawner_StepNormalEvent_1 (line 3) - draw_surface_ext(application_surface,480,240,1,1,0,c_white,1);

I also tried using only surface_resize(application_surface,920,480); and this did nothing. The game ran as usual at 125% the size.

Does anyone have an idea on how to fix this? It need not be fancy by any means and if you could, please explain it simply. Most info on the internet about this is way to complex for me to understand and implement, hence me writing here.

Thanks in advance!

EDIT: After looking further at the game global settings I discovered a box reading "Interpolate colors between pixels". When I unchecked it, my problem was almost solved. Now all my sprites are pixel perfect and the game is displayed with the right dimensions. However, my background is still blurred, as if it had been scaled down to half it's size and then scaled back up leaving the pixels all blurred. The background in the editor looks fine and in the room editor it also has full resolution. It's only when I run the game that this happens. Note that I have also removed all code relating to the application_surface and what not.
 
Last edited by a moderator:

Simon Gust

Member
Are you using GMS 1.4 or 2?
Anyway, when the view size is not the port size pixels get scaled (of course). So you only want to have whole numbers when you divide the port by the view. The pixel blurrness is an option in the global game settings you can turn off "interpolate colors between pixels".
You can resize the application surface, but you shouldn't need to turn off automatic drawing, nor draw it in a create event. Just rescale it.
More help:
https://forum.yoyogames.com/index.php?threads/how-to-properly-scale-your-game.995/
 

TheouAegis

Member
Are you running in full-screen mode? I mean, the dimensions you said those of most people's desktop resolutions.
 
D

dodash

Guest
I am using GM 1.4. I am running the game in windowed mode. I find it easier to start with. And yes, I am aware that I can only scale pixels by integer amounts.

So I turned off the interpolation and as I wrote in my edit to my top post, it almost fixed the problem. My sprites are all fine now but the background for my room is still blurry for some weird reason.
 

mahre

Member
I am using GM 1.4. I am running the game in windowed mode. I find it easier to start with. And yes, I am aware that I can only scale pixels by integer amounts.

So I turned off the interpolation and as I wrote in my edit to my top post, it almost fixed the problem. My sprites are all fine now but the background for my room is still blurry for some weird reason.

Check if your textures pages is higher than your background's dimension.
 
D

dodash

Guest
Changing the texture page size to 4096x4096 fixed the issue now. Thanks so much for all your help!
 
Top