GameMaker Scrolling background

S

Sdrex

Guest
Hello,

I'm new to the forums and have been using Game maker studio 2 for some time now,

I am sorry if this is the wrong board, or if I put the wrong prefix to this thread...

In a project I am working on, I am using a fixed image as background which scrolls downward as you progress through the game, the problem with this is that no matter what speed i set the scrolling, when the image scrolls a tick down, the game does something horrific (like it tries to redraw everything and "lags" a little in doing so, the effect is increased as you increase the speed and decreases but never truly disappears...)

I tried a lot of things (surely not everything, or I would have probably solved this 🤔) but with no results...

To obtain the scrolling, I followed a tutorial which had me use two scripts in the game controller object, which are:

GML:
var _cam_x = camera_get_view_x(view_camera[0]) ;
layer_x("Background", _cam_x * 0.25);
and
GML:
var lay_id = layer_get_id("Background");
var back_id = layer_background_get_id(lay_id);
layer_background_vtiled(back_id, true);
I'm sorry if this was already asked and answered, I did a search on this for a long time, but all solutions seems to not work with this issue...

Thanks for your kind replies,
Best regards.
 
S

Sdrex

Guest
Hi!
Thanks for your reply,
Actually I forgot to mention that this is a vertical scrolling background, so it is right that hspeed is left untouched I think

Here I captured the screen to give you an example of what I'm talking about:
If you look closely on the borders of stuff you can see what I am talking about x.x
 

TsukaYuriko

☄️
Forum Staff
Moderator
That looks like what happens when you try to draw stuff at fractional coordinates. Given the "0.25" in the opening post, we can put 2 and 2 together and have found our most likely culprit.

Ensure that you are drawing exclusively at integer coordinates. You could facilitate this by rounding the position before assigning it. If you want things to scroll at a non-integer speed, keep track of the "real" position separately and assign a rounded version of it to what you're drawing every step.
 
S

Sdrex

Guest
Hi,
Thanks for your reply,

Actually for the video I used 1 as the speed as I wanted for it to show a little more (I will surely keep in mind your advice as it is very useful!)

Here another video with the printscreen of the actual vspeed (sorry I actually turned it off by mistake):


And here an example with the speed set at 2:


I tried using a fractional as I noticed that lowering the speed also seemed to lower the "blur-lag" effect ><
 

TsukaYuriko

☄️
Forum Staff
Moderator
If we're talking about blur here instead of just distortion, there may be a different cause. Since the medium of demonstration you've chosen is a video, which is naturally compressed and therefore blurry, we unfortunately won't be able to use it to analyze the issue further. That would be like finding hay in a haystack. :p

Please take a screenshot of your game while it is exhibiting the behavior you described. I'm hoping that you will be unable to do this and that the issue will not be visible in any screenshot you take, as that would clearly identify the cause, but let's see how it goes and we'll continue exploring options based on the results.
 
S

Sdrex

Guest
I cannot capture this on a screenshot, as when the screen is "still" the issue is not present...

I called that blur but it was a mistake, it's actually more of a rippling effect on the border, and it seems like it also happens if you have a still background (so no "auto-scrolling") and you move around with the camera following you (when the background "scrolls" to follow your sprite it "ripples" the edges of stuff)

Thank you very much for your help ><
 

TsukaYuriko

☄️
Forum Staff
Moderator
Then I have good news and bad news for you. The good news is that there's no way it's caused by anything in your code, as it would otherwise be visible in a screenshot, so you can rest assured that you did nothing wrong.

The cause seems pretty clear to me at this point - more than likely, it's your monitor. There are various types of panels used in monitor displays, some of which are very susceptible to creating motion blurs or trailing. You can check whether this is the case here: https://www.testufo.com/
If THAT looks anything less than 100% crisp and fluid, your monitor is susceptible to blurring.

The bad news is that there's no way around it aside from buying a better monitor.
 
S

Sdrex

Guest
Mmmm... we're making these tests on several monitors just to be sure about this (as the display on my dell g3 notebook and both of my asus gaming monitor all reproduce the problem...)

I never experienced this problem on any game or anything else x.x

So there's no way around that at all from the designer side?><
 

TsukaYuriko

☄️
Forum Staff
Moderator
Feel free to send me a compiled version of the game via DM and I'll be the judge. I can test on a BenQ Zowie XL2546S, an Acer XB321HK, an EIZO 2416W and a bunch of cheaper Dell ones. If my diagnosis of the problem was correct, the issue should not be present on the Zowie but very likely present on all the others. If it turns out that I was wrong - and I'll be damned if I was, because that would be the absolute first time this problem appears, doesn't show up in screenshots but IS caused by code - we can further explore what caused it.
 
D

Deleted member 13992

Guest
Also check your monitor menu settings and disable anything that is an "enhancement". A lot of monitors come with blur/edge/motion/contrast enhancement on as a default which for the life of me I cannot understand why, since it makes everything look worse in my experience. Those types of monitor effects are a nightmare for us content creators.
 
Last edited by a moderator:
S

Sdrex

Guest
Feel free to send me a compiled version of the game via DM and I'll be the judge. I can test on a BenQ Zowie XL2546S, an Acer XB321HK, an EIZO 2416W and a bunch of cheaper Dell ones. If my diagnosis of the problem was correct, the issue should not be present on the Zowie but very likely present on all the others. If it turns out that I was wrong - and I'll be damned if I was, because that would be the absolute first time this problem appears, doesn't show up in screenshots but IS caused by code - we can further explore what caused it.
Thanks, sent!
Also check your monitor menu settings and disable anything that is an "enhancement". A lot of monitors come with blur/edge/motion/contrast enhancement on as a default which for the life of me I cannot understand why, since it makes everything look worse in my experience. Those types of monitor effects are a nightmare for us content creators.
Also thanks for this tip too, I will make sure to check as soon as I can!
 

TsukaYuriko

☄️
Forum Staff
Moderator
Good news: We were both wrong. :D

I've performed a bunch of tests on the compiled version you sent me. Initially, I was unable to reproduce the issue, but didn't want to settle with just flagging down my initial diagnosis as correct without exhausting every possibility.

Once I switched my primary monitor to a 1080p one and opened the game on it, I saw what I believe to be the type of "rippling" you're describing. This actually does show up in a screenshot, though, albeit rather hard to notice when not in motion.



This close-up of a rock clearly demonstrates the problem:



The red and white bar indicates the height of each row of pixels. The 2 pixel tall row in the middle is what's leading to the illusion of movement (as you called it, ripples) taking place as the displayed pixels become smaller and then larger again when passing through it. The same problem exists vertically, but it's not clearly visible as there is no horizontal movement.

The cause? Your game window is set to be 1920x1080 pixels in size. It spawned on a 1080p monitor. Since the window borders also need to fit in the game window, it gets squished to fit on the screen. The reason why I initially didn't encounter this is because my main display is a 4K one, so the game window never had the need to squish itself. The result of the squishing is that everything that's drawn needs to be downscaled to fit into the squished window. Downscaling always introduces some form of distortion as the process involves discarding information in one way, shape or form. In this case, since the game window's intended resolution is not evenly divisible by the squished resolution, some of the rows and columns will necessarily have a few pixels more or less than the others so that everything can fit in.


My initial analysis was therefore incorrect, and the cause is not your monitor.


You can easily resolve this by either making your game start in fullscreen, run in a borderless window or use a smaller resolution - just make sure it runs at its intended resolution, and that said resolution is an integer multiple of the native resolution.
 
Top