Overlay Maps: bringing layers back to Ace

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,071
First Language
English
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.



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

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.



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.
 
Last edited by a moderator:

hyde9318

RMC Coordinator
Veteran
Joined
Apr 1, 2012
Messages
2,593
Reaction score
680
First Language
English
Primarily Uses
RMMV
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.
 

BILL_NYE_THO

The Science Guy
Veteran
Joined
Feb 17, 2013
Messages
361
Reaction score
21
First Language
English
Primarily Uses
Seriously fantastic. I can't believe you make this many scripts at such a fast rate, and all are consistently efficient and useful.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,285
Reaction score
11,872
First Language
English
Primarily Uses
RMMV
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 :)
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,071
First Language
English
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.
 
Last edited by a moderator:

hyde9318

RMC Coordinator
Veteran
Joined
Apr 1, 2012
Messages
2,593
Reaction score
680
First Language
English
Primarily Uses
RMMV
Well, this proves it. Tsukihime is...

 

Jesse - PVGames

Game and Graphics Developer
Veteran
Joined
Jun 23, 2012
Messages
1,738
Reaction score
2,734
First Language
English
Primarily Uses
This is a really, really great feature you whipped up. Really wonderful work!
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,071
First Language
English
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.
 
Last edited by a moderator:

Galv

Veteran
Veteran
Joined
Oct 1, 2012
Messages
1,181
Reaction score
1,124
First Language
English
Primarily Uses
N/A
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.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,071
First Language
English
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.



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



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...
 
Last edited by a moderator:

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,403
Reaction score
10,841
First Language
English
Primarily Uses
RMVXA
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.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,071
First Language
English
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.
 
Last edited by a moderator:

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,403
Reaction score
10,841
First Language
English
Primarily Uses
RMVXA
OK, thanks

EDIT

Still can't run it.  My system folder has 301.dll, and the demo is looking for 300.dll
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,071
First Language
English
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.
 

Kes

Global Moderators
Global Mod
Joined
Aug 3, 2012
Messages
21,403
Reaction score
10,841
First Language
English
Primarily Uses
RMVXA
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.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,071
First Language
English
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



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



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.
 
Last edited by a moderator:

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,071
First Language
English
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.
 

Shaz

Veteran
Veteran
Joined
Mar 2, 2012
Messages
38,285
Reaction score
11,872
First Language
English
Primarily Uses
RMMV
This just keeps getting better and better!
 

gpgekko

Nevermind me, I'll just cast shadows on your walls
Veteran
Joined
Jan 23, 2013
Messages
114
Reaction score
7
First Language
Dutch
Primarily Uses
I think I see a minor graphical bug. I'm not sure, but the guy at the bottom of your castle:



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! :D
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,230
Reaction score
3,071
First Language
English
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.





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.
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

I really need to stop thinking there are new freebies just because someone made a new post in the freebies subforum lol.
AND just like that..... I got STEAM DLC up and working! YES!
Game making is like a marathon, except the last 1/4 is more like sprint... a very long and intense sprint.
Finally got to finish the demo for my project!
Another week has gone by. Maybe you made changes to your project/s. Maybe you didn't. Nonetheless, THAT IS NO EXCUSE TO NOT BACK THEM UP O_O!

Forum statistics

Threads
93,445
Messages
912,460
Members
122,968
Latest member
Paitshens
Top