• Advertisement
Sign in to follow this  

tile engine Vs Rendering

This topic is 4868 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to put together some code to draw tiled maps. Later on I want to be able to add characters to move around and other game specific code. But for now I just would like to draw the levels on screen, and maybe move something around them Now heres the question :- Could a tile engine and a rendering engine be considered two seperate parts of a game. Should the tile engine handle creating a data structure to store the information about the level, while the rendering engine draws the map tiles graphically on screen? Any thoughts on this, I'm trying to find out about the design and componets involved in a game like Zelda on the NES.

Share this post


Link to post
Share on other sites
Advertisement
The ideal is to encapsulate as much as possible - the rendering engine should know nothing about the game, and the game should only know enough about the rendering engine to send it the appropriate commands.

One of the payoffs of this approach is code reuse - when you make your next 2d game (say, a side scroller), you can use the same rendering engine.

In this case, you would write your renderer so that it only understands primitives - polygons, or maybe even just axis-aligned quads.

Then, your tiles would be handled by game code - the renderer would know nothing about them. When it came time to render, the tile engine would send the tiles to the renderer as textured quads, i.e. the 'abstract' form that the renderer understands.

Hope that helps.

Share this post


Link to post
Share on other sites
I created a very simple tile engine for my Asteroids clone. It just tiles the screen with stars. It can easily be expanded to support large maps like Zelda.

I encapsulate everything into a little class called CMap(Works just fine aslong as you're not using MFC).

Rendering goes like this:

for (int y = 0; y < scanlinesy; ++y)
{
for (int x = 0; x < scanlinesx; ++x)
{
D3DXVECTOR2 vPos(x * tilesize, y * tilesize);
m_pSprite->Draw(...);
}
}


I can easily adapt this code to support large tile maps, and still have it all encapsulated. Write a viewport/camera class and pass it in during rendering or before.

Toolmaker

Share this post


Link to post
Share on other sites
The best way to do it i think would be to have a TileMap class or structure that contains all the map info and has functions for loading maps from file, allocating the memory, unloading, and so on.. and have another class or method as part of your renderloop that accesses this world data to draw the world.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement