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

Metroid style map with different sized rooms

R

Rohan79

Guest
Hey!

I would like to make a Metroid style adventure game. My question is about the rooms, I would like to make my whole level separated as rooms. Just like in Metroid style games.

Now, what I don't know is, how should I go from room to room. Or what would be the right way.
The easy way I know is:
  • define the rooms in creation code of the current room for all 4 directions
  • name the rooms like lvl_10_17 where the numbers are coordinates
What I didn't test is using ds_grid which sounds like a good idea for me. Also would allow me to generate a minimap easier. But wait, what's with the bigger rooms?

One screen is 160x144 (Game Boy resolution) and the rooms would be that size or the multiple of that (320x144, 160x288, 640x288, 160x576, etc...)

So basically I need some advice, how to start. Because I'm not sure how to begin with it even if I have idea for it.
The ds_grid solution sounds the best for me since I don't need creation code, I can place the rooms into it easily, can be used for minimap creation (not sure about doors). But I don't know, how to handle the bigger than 1 screen rooms for the ds_grid.

I have an untested theory actually: make an room_x and room_y variable within the rooms. top left corner is [0,0] when I pass through, let's see... 160x0, it'll become [1,0], or if I pass through pixel 320x144 it'll be [2,1]. Basically I would virtually cut the rooms into 160x144 slices. They would be still one room, but the there was an info about which slice I am in.
So I could tell the "room to room" script how much to skip in a direction in the ds_grid to load the other room.

Any better ideas? Did anyone tried to make a Metroid style map in Game Maker?
 
Instead of thinking of each cell in the ds_grid as a whole room, start considering each cell as being a "screen" in a room, so if you had a few rooms, say called "rm_entrance", "rm_hallway", and "rm_cavern", your grid would look like this:

Note: rm_entrance will be represented by "E", rm_hallway by "H", and rm_cavern by "C"
Code:
 00000000001111
 01234567890123
0
1 EHHHHCCCCC
2      CCCCC
3      CCCCC
4
Of course, instead of the letters you would store the room id's or something, and if the "cell" has been visited.

The numbers along the top and side are the grid coordinates. If you have things set up this way, you could even use the map grid to determine which room to go to when you leave the screen.
 
R

Rohan79

Guest
OK, so I think I get the basic idea, but I still don't know how should I define a part of a room as a cell... or screen.

Now, I just set the grid size in room editor to the screen resolution just for showing a room which has the size of 3x2 screens. So this is how a room looks like, there are multiple of ways to go, even within a screen.
So... now I have two rooms, same size. They're conveniently called as lvl_9_10 and lvl_10_10 and they're stored in the ds_grid and the player can go from one to other. But of course it's not good for different size of rooms. So basically what I don't understand, how do I "split" the rooms into multiple like this on the screenshot should be stored in 3x2 places in the ds_grid.

Now, going from room to room is simple in my same size case, simply because I just place my player to the other end of the room when he goes from one room to other, so it keeps everything else, movement speed, height, jump speed, etc.
But different sizes can come with different x or y values, but I guess I could solve it by using some kind of offsets to correct the player's new placement.

Sorry, I went a little bit off-topic.


Instead of thinking of each cell in the ds_grid as a whole room, start considering each cell as being a "screen" in a room, so if you had a few rooms, say called "rm_entrance", "rm_hallway", and "rm_cavern", your grid would look like this:

Note: rm_entrance will be represented by "E", rm_hallway by "H", and rm_cavern by "C"
Code:
 00000000001111
 01234567890123
0
1 EHHHHCCCCC
2      CCCCC
3      CCCCC
4
Of course, instead of the letters you would store the room id's or something, and if the "cell" has been visited.

The numbers along the top and side are the grid coordinates. If you have things set up this way, you could even use the map grid to determine which room to go to when you leave the screen.
 
Well, ideally, you'll want to start with determining where on the map the top left corner of the room is going to be, so in the example I provided, "rm_hallway" starts at map coordinate (2:1). You're probably going to store these coordinates somewhere, so that it makes one of the next steps simpler. After that, you determine how many "cells" the room takes up, which would be simply "room_width / screen_width" and "room_height / screen_height". You then loop through the grid, starting at the top left coordinate you came up with earlier, and iterating using the width and height numbers, setting each cell in the grid to the appropriate room value, quick example:

Code:
var map_x = 2,
    map_y = 1,
    rm_width = 640, // You might want to get this value dynamically in some way
    rm_height = 144, // Same with this one
    map_width = rm_width / screen_width, // "screen_width" of course being the 160 value you quoted
    map_height = rm_height / screen_height, // Same as above, but for value 144
    x1 = 0,
    y1 = 0;

repeat (map_height - 1)
{
    repeat (map_width)
    {
        map_grid[# map_x + x1, map_y + y1] = current_room; // "current_room" will be the reseource ID of the room you are adding
       
        x1++;
    }
   
    x1 = 0;
    y1++;
}
... Then, when you want to determine where on the map the player currently is, you'll use something like the following:

Code:
var map_x = room_x + floor(obj_player.x / screen_width),
    map_y = room_y + floor(obj_player.y / screen_height);
The values "room_x" and "room_y" would be the top left coordinates I mentioned earlier.

You can also get the coordinates of the player relative to the current "cell" they are in as follows:

Code:
var player_x = obj_player.x - floor(obj_player.x / screen_width),
    player_y = obj_player.y - floor(obj_player.y / screen_height);
... Which would be useful for determining where in the next room to put the player.
 

TheouAegis

Member
Look through the first couple pages of this forum. There is another post about Castlevania/Metroid Style Maps. I posted rough mock-up of the logic behind how such a map is made. It is worth noting here where as for my rough mock-up I used a screen size of 256 by 256 pixels, you would want to use a smaller value perhaps. Although I am pretty sure that Gameboy Metroids do still use a room size of 256 by 256, but I never actually paid attention to that.
 
R

Rohan79

Guest
rm_width = 640, // You might want to get this value dynamically in some way
rm_height = 144, // Same with this one
Uh, I didn't get why you said "some way"... Well I thought it can be done easily, but I was wrong. Now, this is a new challenge. After some minutes of thinking, after I started to write the script and I realised it won't work that easily, I could only think about some really ugly way that I should avoid. Literally loading all the level rooms, get the info, put them into the ds_grid go to the next room, repeat. But I don't want that, it's truly not nice. But I really would like to have the room width and height dynamically, outside of a room.

I was thinking about filling the grid with a script according to the left-top position and dimensions. Not the most convenient way, but it should work... if I could get the room sizes to get the number of screens / rooms. I have the cell numbers within a room that I can use to determine where the player should be in the next room after leaving.

Look through the first couple pages of this forum. There is another post about Castlevania/Metroid Style Maps. I posted rough mock-up of the logic behind how such a map is made. It is worth noting here where as for my rough mock-up I used a screen size of 256 by 256 pixels, you would want to use a smaller value perhaps. Although I am pretty sure that Gameboy Metroids do still use a room size of 256 by 256, but I never actually paid attention to that.
That post looks really useful for the mini-map generation!

EDIT:
I figured out based on Your helps! It works perfectly. I had to manually enter room size though, but it's not a problem, I made a helper script so I just have to add a room once, it loops through cell number x and y so it's semi automatic. I can still ruin it by entering wrong values and placement, but it's pretty good. Also I made the player positioning right when the player goes from room to room.

 
Last edited by a moderator:
M

maratae

Guest
Also I made the player positioning right when the player goes from room to room.
I've been having the hardest time with this..
How did you determine where in the room the player shall go, let's say if you're moving horizontally and the next room is taller?
 
Top