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

Draw_background vs draw_sprite?

Hi everyone!

Trying to implement a tiled parallax background that only loads the specific tiles when needed and I can't figure out how to do this in a smart way using draw_background.

1. Is backgrounds drawn at a specific depth or is it infite? Can I draw a background behind an already existing one?

2. Is it better to draw_sprite and set the depth right there and then to match my specific layer in the background?

Right now the code looks like this (very tedious and repetative):

//Layer 4 tile1
draw_background(
bg4_01,
view_xview[view_current] * 0.65,
(view_yview[view_current] * 0.4) + yoffset
);
//tile2
draw_background(
bg4_02,
view_xview[view_current] * 0.65 + 1280,
(view_yview[view_current] * 0.4) + yoffset
);
//tile3
draw_background(
bg4_03,
view_xview[view_current] * 0.65 + 1280 + 1280,
(view_yview[view_current] * 0.4) + yoffset
);
//Layer 3 tile1
draw_background(
bg3_01,
view_xview[view_current] * 0.6,
(view_yview[view_current] * 0.3) + yoffset
);
//tile2
draw_background(
bg3_02,
view_xview[view_current] * 0.6 + 1280,
(view_yview[view_current] * 0.3) + yoffset
);
//tile3
draw_background(
bg3_03,
view_xview[view_current] * 0.6 + 1280 + 1280,
(view_yview[view_current] * 0.3) + yoffset
);
 

obscene

Member
So when you enable a background in the room editor, those backgrounds are drawn automatically before everything else. Tiles, sprites, etc. However when you manually draw a background the depth where it's drawn is entirely dependent on the depth of the object where the code is. By definition, it's impossible to draw "behind" something.

If you need fine controls over background drawing, don't let GM draw them automatically. Just have an object in your room with a high depth draw them all manually.

On the subject of backgrounds vs sprites, when you are manually drawing them they are essentially the same thing, you just have different options available, such as tiling for backgrounds and subimages for sprites.
 
Top