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

Design Multiple floors / heights in one room

M

McWolke

Guest
Hey there, i am thinking of a way to do different heights in a top down game like zelda. I talk about something like this: https://i.ytimg.com/vi/Bd_x0mrSmhM/maxresdefault.jpg You have the base floor and the upper floor. While you are on the base floor you can walk under the bridge. While in the upper floor you can walk on the bridge. I already have an idea how it might work but it seems so inefficent. I would give every object a variable "floor" and check if they are equal, if yes, then collide. Also change the depth depending on the current floor. But if i do it this way i either had to change every instances variable in the creation code. Which could take forever.. Or i had to make different objects for every floor. Like obj_solid_base_floor and obj_solid_upper_floor and so on. Is there any better way?

I also posted this question on reddit: https://www.reddit.com/r/gamemaker/comments/4q2pm0/different_heights_floors_layers_in_one_room/
 

Zerb Games

Member
Zelda accomplishes this in a multiple of ways. What I would do is just have a one way wall, and a layer (or floor whatever) variable that dictates weather or not you can collide with this wall or if it just moves your y down by 6. In the creation code of the wall you would have layer=2 or something, and in the player collision you would have:
if other.layer=self.layer
{
y+=6 //or use something likeease(y-=6,linear) Not a built in function it just looks nice, you can find an ease script out there ease.com is a great source
}
else
{
//Wall collision where you can't move or play the push animation etc
}
With the layer variable you can also have the ability to draw the character underneath something or above and not allow enemies to hit you.
//Player collision with enemy
if self.layer=other.layer
{
//don't hit the player
}
hp-=other.damage
//knockback and any other thing you may want to happen.
}
And for stairs upon collision they can change your layer after reaching the top or something, and upon going down do the same.
//code in stairs create
layer=1
//creation code in stairs
layer=DESIREDLAYER
//code in stair collision/step, inefficient but understandable for a nooby.
//YOU WOULD NEED A TOGGLE FOR THIS CODE.
if collision_rectangle(x,x,x+16,y,obj_player,true,true) //x,y, length of stairs, height of change area //no need for a +number
{
if other.layer=self.layer
{
other.layer-=1
}
else
{
other.layer=self.layer
}
}

Hope this was intuitive enough. I'm not sure how far you are into programming.[/spoiler]
 
I

iMilchshake

Guest
Should the Layers have some kind of parallax movement? If not you can just do the collisions right and it will feel like multiple layers^^.
 
M

McWolke

Guest
Zelda accomplishes this in a multiple of ways. What I would do is just have a one way wall, and a layer (or floor whatever) variable that dictates weather or not you can collide with this wall or if it just moves your y down by 6. In the creation code of the wall you would have layer=2 or something, and in the player collision you would have:
if other.layer=self.layer
{
y+=6 //or use something likeease(y-=6,linear) Not a built in function it just looks nice, you can find an ease script out there ease.com is a great source
}
else
{
//Wall collision where you can't move or play the push animation etc
}
With the layer variable you can also have the ability to draw the character underneath something or above and not allow enemies to hit you.
//Player collision with enemy
if self.layer=other.layer
{
//don't hit the player
}
hp-=other.damage
//knockback and any other thing you may want to happen.
}
And for stairs upon collision they can change your layer after reaching the top or something, and upon going down do the same.
//code in stairs create
layer=1
//creation code in stairs
layer=DESIREDLAYER
//code in stair collision/step, inefficient but understandable for a nooby.
//YOU WOULD NEED A TOGGLE FOR THIS CODE.
if collision_rectangle(x,x,x+16,y,obj_player,true,true) //x,y, length of stairs, height of change area //no need for a +number
{
if other.layer=self.layer
{
other.layer-=1
}
else
{
other.layer=self.layer
}
}

Hope this was intuitive enough. I'm not sure how far you are into programming.[/spoiler]
alright, that was what i already had in mind :) i just thought there was a better way to do this since i am way too lazy to edit every instance creation code in the room editor ^^
thank you sir :)

Should the Layers have some kind of parallax movement? If not you can just do the collisions right and it will feel like multiple layers^^.
no parallax movement :)
 
I

iMilchshake

Guest
If you want actual layers Zerb's Idea is awesome.
For Basic stuff like this :

(From Titan Souls)
Collisions are enough, you don't need actual layers there!

Tobi! ^-^
 
M

McWolke

Guest
If you want actual layers Zerb's Idea is awesome.
For Basic stuff like this :

Collisions are enough, you don't need actual layers there!

Tobi! ^-^
i need layers for my puzzles so i'll give that a try :)

ps: titan souls is awesome :p
 
Top