Overlay Maps: bringing layers back to Ace

This script allows you to create "overlay maps" on top of each other. In other words, map layering.

Overlay maps allow you to create much more visually attractive maps since you now have control over different "layers", though you are unable to walk from one layer to another. For now anyways.

overlayMaps3.jpg


Download

Get it at Hime Works

Here is a demo: https://www.dropbox.com/sh/sz6mpw5n2d6zxi2/MhL6lunze4/Demo/Overlay Maps demo.zip

For overlay map zooming, get this add-on script.

Tutorials

Here are some tutorials that may be interesting

Description
An overlay map is just another map, except it is drawn over your current map.

The overlay map comes with the following properties

  • It does not need to use the same tileset as your current map. This means you can merge multiple tilesets together in a single map
  • Events on the overlay map are processed in the current map, although you are still not able to reference events from different maps.
  • The player is unable to directly interact with the overlay map, or anything on the overlay map.
  • The player, however, can indirectly interact with events on the overlay map by setting switches or variables that will trigger the events.
  • To transfer between layers, you must use player transfer events
  • Map layers can re-use each other, so if one map uses another map as the top layer, then that map can use the previous map as the bottom layer
  • Each layer has its own screen effects
    overlayMaps11.jpg

You can have an unlimited number of overlay maps, but note that having many map overlays will cause a significant drop in performance.
Usage

Create your maps as usual, taking into consideration how you want to layer them.

You might separate your maps into "floor" and "ceiling" or "floor, walls, ceiling", depending on how you like to organize things.

Note that because maps and overlay maps cannot interact with each other, all events on each overlay map are effectively bound to their own overlay map.

There are two types of note-tags: compact, and extended. The compact note-tag is short and easy to type, but the extended note-tag is probably better for organization.

Note that because maps and overlay maps cannot interact with each other, all events on each overlay map are effectively bound to their own overlay map.

To assign overlay maps to a map, tag the map with either

Compact:

<overlay map: map order ox oy scroll_rate sync zoom>Extended
Code:
<overlay map>map: xorder: xoffset: ox oyscrollrate: xsync: 0/1zoom: x opacity: x</overlay map>
The map is the ID of the map that will be drawn as an overlay.The order determines whether it will be drawn above or below the current map.

If it is negative, then it will be drawn under.

If it is positive, then it will be drawn over.

If it is not specified, then it assumes to be over, in the order that the

tags are specified.

ox and oy determine the offset of the origin. By default, the map's origin

is drawn at (ox = 0, oy = 0), but you can change this if necessary.

The x-value specifies the horizontal offset. Positive values shift it to the

right, while negative values shift it to the left.

The y-value specifies the vertical offset. Positive values shift it down,

while negative values shift it up.

The scroll rate specifies how fast the overlay map scrolls per step taken.

The default scroll rate is 32, which means it will scroll

32 pixels per move, or basically one tile. Higher scroll rates mean the

overlay map will scroll faster for each step you take, while slower scroll

rates results in less scrolling for each step you take.

Sync specifies whether the overlay map is synchronized with the current

map. This means that any screen effects such as shaking or weather will affect

the overlay map as well.

0 = not synchronized

1 = synchronized

The zoom value is a special option if you have installed the Overlay Map Zoom

script. Refer to that script for more details.

The opacity value specifies the opacity of the overlay map.

overlaymaps161.jpg


You can have multiple overlay maps by simply adding more tags. Note that the order they are drawn depends on the order you tag them.
Wowa Wow wow wow! That is freakin cool!


Awesome work on this and really awesome way to make layers. I wouldn't even had thought of using different maps.
Seriously fantastic. I can't believe you make this many scripts at such a fast rate, and all are consistently efficient and useful.
LOVE, LOVE, LOVE this!!!


I have long thought it would be great to be able to overlay maps on top of each other to get around Ace's layering limitation, but it hurt too much to think about actually doing it 🙂
I have implemented layer ordering.

In the note-tag, you can specify a second number to indicate the order that they should be layered.

The current map is given an order of 0.

<overlay map: 2 -1> # draw map 2 one layer below the current map<overlay map: 4 1> # draw map 4 one layer above the current map<overlay map: 6 -3> # draw map 6 three layers below the current mapYou can use the layer order to determine which goes above and which goes below.

This is useful because a single map could be composed of many layers, and you could transfer to different layers at different times while simply re-using different layers for the overlays.

Also note that because event locations may have changed during the game, it is especially important to be able to synchronize different maps together, otherwise you will end up with consistency issues. By re-using maps, you avoid running into this issue altogether.
Well, this proves it. Tsukihime is...

Spoiler
one_smart_cookie_by_cotaku-d2yfmtl.png
This is a really, really great feature you whipped up. Really wonderful work!
I have identified a bug where the character sprites drawn on the overlay maps are moving with the screen if your screen is sufficiently large (eg: bigger than 13x17)


Actually the past 3 scripts involving sprites and maps I've been running into the same issue.


Anyone know why this happens? Sometimes it's solved by just updating ox and oy to the player's current screen location but I can't get anything this time.
I recently fiddled around with sprites and was drawing them only to screen_x and screen_y, which worked fine until I tested it on a larger map.


I needed to use $game_map.display_y and $game_map.height to determine where to draw the sprite. Don't know if it's the same thing you're doing (or if it's the best way to do it haha), but maybe looking into those will help.
Found the issue.

I don't understand why commenting out those adjustments worked. No clue at all...

def screen_x @map.adjust_x(@real_x) * 32 # + 16end def screen_y @map.adjust_y(@real_y) * 32 - shift_y - jump_height # + 32 endI have updated the script to address the issue.

I have updated the demo as well to demonstrate how layer ordering works, how to re-use layers, and also how to transfer between layers.

I would also like some members to do some tutorials using this script to demonstrate the kinds of mapping power you have.

For example, the following was done with just two maps:

Currently on map 1, using map 2 as the overlay map above current map. You can see the events from map 2.

overlayMaps6.jpg


Now on map 2, using map 1 as the overlay map below current map. You can see the events from map 1.

overlayMaps7.jpg


If you use scripts like Shaz's remember position, the position of the events on the overlay maps are also memorized.

Because the editor does not allow you to load up two maps in the same window, it might be difficult to do the layers. My advice would be to take a picture of your map and then set that as the parallax in the editor (with it showing in editor) so that you can use it as a reference.

Note that my map screenshot script does not support the overlay maps yet, so if you take a mapshot of your final rendered map, it will only capture one layer. I will update this in the future. If you really need to take a picture of your layered map, you can use omega7's map saver script.

Something else that I thought was cool: overlay maps that scrolled faster or slower than the current map's scrolling. This allows you to create depth perception, since "farther" objects should move at a slower rate than "closer" objects. I will explore this idea and see how I can use the layer order to create depth. Maybe blurring the overlay might be useful as well...
This is so welcome, it opens up all sorts of possibilities.  Could you confirm that it is compatible with Yanfly's Ace Core Engine?

EDIT

Can't get the demo to work.  Get the message that System\RGSS300.dll could not be found.
I would prefer if you could check that since you probably already have yanfly's scripts set up for your project.


You can use the maps in the demo.


For the demo, just copy a system folder from any project. I didn't include the dll cause everyone that's developing in Ace should have one and these demos aren't really made for anyone that doesn't have RM. Plus it saves a MB for those with slow connections or limited bandwidth.
OK, thanks

EDIT

Still can't run it.  My system folder has 301.dll, and the demo is looking for 300.dll
That's interesting I thought RTP ships with both 300 and 301.


Anyways I've updated the demo to include the dll, but now it's 1 MB.
Actually since posting, I went through other demos I've downloaded, and found one with 300 and copied it from there.  Now working. Perhaps putting the dll on a separate d/l for those who don't have the 300 version? That way, those who've got it needn't bother.
I have implemented a feature called "scroll rate" for overlay maps.

The scroll rate allows you to control how many pixels will be scrolled, for each move that you make.

To specify a scroll rate, you enter a third number for the note-tag

<overlay map: 1 1> # draw map 1 one layer above with default scroll rate (32)<overlay map: 2 -1 16> # draw map 2 one layer under with a scroll rate of 16<overlay map: 5 1 48> # draw map 5 one layer above with a scroll rate of 48By default, the tiles are 32x32 pixels, and each step you walk will scroll the map by one tile.If you have a higher scroll rate, your overlay map will shift faster than your current map.

Similarly, if you have a slower scroll rate, your overlap map will shift slower than your current map.

This allows you to create perceptions of speed or depth: objects that are closer to you tend to be bigger and scroll faster, while objects that are further than you tend to be smaller and scroll slower. Or something like that.

Here's an example where I am on a sky island above a sky city. The overlay map is the city below, and it is scrolling much slower than the island

overlayMaps8.jpg


For every step that I take, the city scrolls only 8 pixels, or 1/4 the scroll rate of the current map.

overlayMaps9.jpg


It provides a unique map traveling experience, when one layer is moving at a different rate from another layer.

Here is an animated example:

Read this tutorial to see the above example in action

One issue that will likely appear is tile map looping.

When a smaller map is combined with a larger map, the smaller map will loop. And you don't really have much control over where it will be drawn.

I will be looking for a way to provide a way to "fix" the overlay map, much like how you fix a parallax map to the screen, and also to stop this automatic looping. My assumptions will be that if you are fixing the map to the screen, then you don't want it to loop, so if you want it to loop, don't fix it to the screen.
Overlay offsets have been implemented.

In addition to the scroll rate and layer order, you can specify an ox and oy to determine where the origin of the overlay map should be.

I have determined that offset is more important than scroll rate, and so have changed the order of the arguments in the note-tag

It is in tile coordinates, where (x=0,y=0) is the upper-left corner of the map.

The x-value will shift it horizontally. Negative x values shift it left, while positive x values shift it right.

The y-value will shift it vertically. Negative y-values shift it up, while positive y-values shift it down.

<overlay map: 2 -1 -10 -15 16>This will draw map 2 one layer below the current map, shifted to the left by 10 tiles, shifted up by 15 tiles, with a scroll rate of 16.
This just keeps getting better and better!
I think I see a minor graphical bug. I'm not sure, but the guy at the bottom of your castle:

overlayMaps7.jpg


I think the top of his head is behind the wall...

Anyway, that's just a minor detail few people will probably ever notice. Awesome script! 😀
Oh, I didn't notice that.


Yes you're right, the sprites on lower layers will be covered by anything on higher layers.


This will actually become a bigger issue because if you have larger sprites, the effect becomes more obvious. Some devs here may already be familiar with it since they are using larger sprites that have their heads cut off by trees.


The problem is due to layering: any characters on the bottom layer will be drawn under the top layer. Even if it is a wall.


I am not sure how to deal with the problem. The easiest way to resolve it in this case is to make sure that the wall behind him (or, in the 2D map, above him) is on the same layer.


overlayMaps10.jpg



But you can see another issue: the walls.


The wall is drawn on two separate layers, and the auto-tiles do not know this, so you will get some strange looking walls.


Not only that, you won't be able to walk "behind" the wall if you put them on the same layer. So if you wanted to have windows looking out? Can't be done.

Original thread: https://forums.rpgmakerweb.com/threads/overlay-maps-bringing-layers-back-to-ace.10417/