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

How do I keep a background immovable?

pixeltroid

Member
for reference, I am trying to achieve the effect in this video at around 55:00


Notice how the sky background does not move, thus creating the illusion of extreme depth.

I thought that was a cool effect and I tried to implement it by changing the background code to:


background_x[0] = view_xview[0] * 0

This causes the background (which is exactly the size of the view size) to not scroll. BUT when I move, I see it jittering sideways by a few pixels.

How do I make it so that the background does not move at all, like in the video I posted?

Any help would be greatly appreciated!
 
D

Deleted member 16767

Guest
Are you trying to make it follow the camera view?

If so, for just a background, there are many solutions. The most simple one is fa_center.
 

pixeltroid

Member
Are you trying to make it follow the camera view?

If so, for just a background, there are many solutions. The most simple one is fa_center.
I'm not trying to make it follow the camera view. The background graphic is exactly as big as the view size.

How do I implement it with fa_center? Can you give an example in code?
 
D

Deleted member 16767

Guest
I'm not trying to make it follow the camera view. The background graphic is exactly as big as the view size.

How do I implement it with fa_center? Can you give an example in code?
//In Draw GUI
draw_set_halign(fa_center)
 

rIKmAN

Member
//In Draw GUI
draw_set_halign(fa_center)
That relates to drawing text, not sprites - it says exactly that in the manual.

OP, without knowing exactly what you mean by "wiggling" (lagging behind? pixel distortion?) it's likely because your view is moving at subpixel coordinates and you are getting pixel crawling on the background image (at least that's what I assume from your description).

Can you floor() the values to integers or is that not possible with the way your game is setup?
 
Last edited:
D

Deleted member 16767

Guest
Code:
var xScale = display_get_gui_width() / view_wport[0]
var yScale = display_get_gui_height() / view_hport[0]

var viewX = camera_get_view_x(view_camera[0])
var viewY = camera_get_view_y(view_camera[0])

Then draw the sprite and either -/+ the variables. Whichever works best for you.

I don't really want to put the code here since a lot of youtubers go through a lot to teach people code like that.
 
Top