How to program a background with multiple floors?

Started by MistyShires, Mon 11/05/2020 16:37:06

Previous topic - Next topic

MistyShires

Hello!

I grew up with 2D adventure games and recently got inspired to turn some vivid imagery from my nightmares into something more productive. In this case a 2D adventure game.

Now, I have no background in coding whatsoever and so far is just playing around with the tools to get the hang of them while I am working on the art assets. Which leads me to my question.

The first room of the game takes place in the entry hall of a mansion that is separated into two floors through a staircase and the plan is that the player would move between the different hallways of the two floors as they solved the puzzles. But I realized that the game only checks for which edge the player walks off of when it transitions into the next room, which makes sense given the way the tool is designed but it doesn't really help me with my conundrum.

Is there a way to make the game check for not only which edge the player walks off of when choosing which room to transition into, but also which floor? Like through the different walkable areas or something? I'd prefer to not have to redraw the entire background again to split the room into two so solving it through the code would be really nice.

Cassiebsg

Everything is possible (and with AGS you should add "almost).

You talking about making a 2D game, but then you looking at your BG as 3D with "floors".  ;)
The edges are there, but you don't need to use them at all!
You can use hotspots to click on to change room, or regions to detect if you have walked on one and move the player character to another place (be it a new room or a new "floor").

You can move the camera so it's focused on the ground floor when you enter, and move it up when the player changes "floor". So doing what you want isn't a problem, it just requires a bit more coding.  ;)
There are those who believe that life here began out there...

MistyShires

Thank you!
This is super helpful! I didn't even think about hotspots as a way to transition rooms!

This was really the only room with this specific problem but it is neat to know for the future. Now I can truly start to finish up the background now that I know that I don't need to slice it up.

I am looking forward to show off the first segment once it is starting to come together!

Khris

I'm a bit confused; your post sounds like the floors of your game are drawn as a single room background, which means you don't need room transitions at all?
Or do you have 2 AGS rooms you're trying to connect?

MistyShires

There are off course multiple rooms that I want to connect to this first room as it is meant to lead to four different hallways with two on each side, think of it as the central hub of the first area if you will. I wished that I had a screenshot to show you so that I can make it more clear what I mean (as I am not good with words) but I haven't even finished the linework yet, let alone the coloring and shading.

I just wanted to know if my idea was possible so I could redraw it in the case that it wouldn't work without having to scrap months of hard work. 

Khris

I reread your question and now I get it :-D

Just for reference, to keep using the room edges you can check the player's y coordinate, or use two walkable areas.

Code: ags
  // walks off left edge
  if (player.y > 100) player.ChangeRoom(2, ...); // bottom floor
  else player.ChangeRoom(3, ...);  // top floor

SMF spam blocked by CleanTalk