I'd like to ask a question on tile rendering in classic 2D RPGs.
Though the theory should apply universally to all resolutions and cell size, I would say talking of 640x480 resolution and 32x32 cell size are most appropriate for this discussion. This means each screen would contain 15 rows by 20 columns of cells (unless it's scrolling, then more could be present, though clipped partially). Just to clarify, this is a "Straight" overhead tile map, like classic Ultima and Final Fantasy games.
To cut a long question short, What's the best way to render this for smooth scrolling? If you know exactly what I'm on about at this point, please don't bother reading the rest of this post
![](smile.gif)
Say, you have Base array storing base cells (for base layer), and overlapping layer (so called "fringe"). You might have another layer for stationary animation cells or whatever. You might even have more layers for extra overlapping graphics. You also have "sprites" layer which contains sprites like players, birds, NPCs or whatever (anything that moves around). And all those overlapping layer cells are stored in link-list style (with *next pointer) in the Base layer. I think all of you know this popular format.
Backbuffer is used to "cook" all those layers and sprites (they have correct perspective and so on) then flipped to Primary buffer.
I've tried snippets here and there in the past. The most notable one was to create an off-screen buffer which was 2 cells wider and longer, centered around the focus Player Character (PC) who is standing in the middle of screen. So it was 17 rows by 22 columns of cells rendered in the offscreen buffer. Mind you, this was done for ALL layers
separately (don't laugh). I think I had 4 layers then, so I had 4 17row x 22column offscreen buffers! Then I blitted as much as 640x480 from each of these offscreen buffers onto Backbuffer, in the correct order to provide perspective (so if NPC is standing behind a tree, it won't look like NPC is standing ON it). To smooth scroll, I would simply cut out another 640x480 chunks from the offscreen buffers (starting from wherever appropriate, depending on which direction I'm scrolling). When the focus PC moved by 1 cell width (after smoothe scrolling), the offscreen buffers were updated from scratch... so 17rows x 22columns were centered around the new location of the PC
![](smile.gif)
As you can imagine, this created a massive overhead. I spend days optimizing it just to make a point to myself that the Method is bad, and not the code... (I hope it was that way around lol).
So I don't think I'll ever do that again for real. So... once again, Whats the best way to do this? I've looked around the internet and I found a few varying methods, but I want to know what is a good way for this particular sort of cell map. Should I just render All cells (clip cells as required) directly into backbuffer, from top row to bottom row, then following layers?
In case you still don't know what I'm trying to achieve here, I'll name a few console RPG examples of the effect I'm trying to get. Here it is, I hope you know some of them:
Final Fantasy 1, 2 and 3 (US version), Lunar series, Phantasy Star series, Tales of Phantasia, Dragon Quest (Dragon Warrior), possibly Seiken Densetsu series (if you know them...), Villgust, ... (list all the 2D RPG games from this era
![](smile.gif)
)
(There's another closely related question regarding the relationship between the structure storing the conventional layers and structure storing sprites. But to avoid confusion, I'm going to post this in another thread later today.)
Thanks you.
Edited by - PugPenguin on May 10, 2001 11:15:37 AM