GameMaker: Studio

GameMaker: Studio

View Stats:
How do you make a parallax game?
I am trying to make a side scrolling game with a 3D illusion using layers, I am using a code like this:

if (self.y < PlayerObj.y) {
depth = 1
}
if (self.y > PlayerObj.y) {
depth = -1
}

But the problem is, that I have a lot of enemies plus the playable character and I have no clue on how to make them all work together
< >
Showing 1-6 of 6 comments
The author of this thread has indicated that this post answers the original topic.
maras Oct 17, 2020 @ 6:56am 
99% of the time you can use
depth = -y;
Blind Oct 17, 2020 @ 7:04am 
I have no idea what you guys are talking about since usually I see parallax as an entirely horizontal phenomenon... why you y'ing?
Originally posted by Blind:
I have no idea what you guys are talking about since usually I see parallax as an entirely horizontal phenomenon... why you y'ing?
https://www.youtube.com/watch?v=KCzdYo4imdE
This is what I am making. I don't want the characters overlapping that's it.
Blind Oct 17, 2020 @ 7:11am 
oh, that's not parallax (or if it is it's not a typical usage of the word).

Parallax is when in side-scrolling sections the different background layers scroll at different speeds (such as really slow scrolling mountains)


Ya, for depth-layering you should be ok with something as simple as depth=-y, but make sure to calculate it based on where your feet are, not where your model's center is (IE: A floating ghost would have a value quite a bit below him)
Last edited by Blind; Oct 17, 2020 @ 7:12am
The Winter Bud Oct 17, 2020 @ 9:52am 
//start of game event globalvar MINIMUM_DEPTH=-100; // NOTE-you can use a macro instead if you like // since MINIMUM_DEPTH is a constant
//player create event depth=MINIMUM_DEPTH;
//enemy end step var plyr=instance_nearest(x,y,obj_player); if(plyr!=noone){ depth=MINIMUM_DEPTH+point_distance(x,y,plyr.x,plyr.y); }

this form of depth handling radiates around a center instead of a vertical plane like
depth=-y;

the closer the enemy is to the player, no matter it's direction is to the player, the more it draws the enemy on top of things.

EDIT: since the player's depth is at MINIMUM_DEPTH, he will always draw on top of the enemies.
Last edited by The Winter Bud; Oct 17, 2020 @ 10:57am
Originally posted by Blind:
oh, that's not parallax (or if it is it's not a typical usage of the word).

Parallax is when in side-scrolling sections the different background layers scroll at different speeds (such as really slow scrolling mountains)


Ya, for depth-layering you should be ok with something as simple as depth=-y, but make sure to calculate it based on where your feet are, not where your model's center is (IE: A floating ghost would have a value quite a bit below him)
Yeah I am an idiot, I just put depth=-y in the step event for every object and everything works. Thanks guys!
< >
Showing 1-6 of 6 comments
Per page: 1530 50