Jump to content
  • Advertisement
Sign in to follow this  
tont

map question for SDL side scroller

This topic is 4625 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 was under the impression that the 'map' would be more of a really big BMP that you would only show portions of when the character was in that section, but the more tutorials im looking at, it seems the better way to do it is to create 'tiles' of the map, and place them on the screen accordingly in a large array of tiles. could anyone help clarify this for me. thank you.

Share this post


Link to post
Share on other sites
Advertisement
i suppose either would work, if you wanted to do a huge side scrolling BMP then goto http://lazyfooproductions.com/SDL_tutorials/lesson19/index.php

good tutorials...

if you wanna do a tiling one good luck because im trying to and no one can really answer my questions lol

Share this post


Link to post
Share on other sites
I would do the tiles way, but that is just me. To me, the tiles way seems like it would be faster, and better on performance, instead of loading a HUGE image as the background.



Chad.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
lol a huge bitmap wont be a problem unless your running on a intel pentium1 processor with 64 MB of ram. then you might pose a problem.

Share this post


Link to post
Share on other sites
Yep it seems the most popular way is using a bunch of small tiles, this way it makes it easier to customize the maps and re-make them...like you have a tile for trees...a tile for grass.etc.. It also helps with making background objects and foreground object (like if the player wants to walk behind something).

The standard way of doing it is greating a huge multi-dimensional array..like

const int X = 25;
conts int Y = 25;

int map[X][Y];

then everytime the player takes a step, redraw the map according to where they are

so a 5x5 map would look something similar to this


map[0][0] map[1][0] map[2][0] map[3][0] map[4][0]

map[0][1] map[1][1] map[2][1] map[3][1] map[4][1]

map[0][2] map[1][2] map[2][2] map[3][2] map[4][2]

map[0][3] map[1][3] map[2][3] map[3][3] map[4][3]

map[0][4] map[1][4] map[2][4] map[3][4] map[4][4]


where every element of the array *(map[x][y]) represents a tile.

If you already knew all the sorry for the explination, hope that helps ya out
ArchG

Share this post


Link to post
Share on other sites
theres some different philosophies about maps.

In a SDL scroller that I've been porting to plain OGL, Super Maryo Chronicles, the map is a collection of objects, no tiles, though they do behave somewhat like tiles. The difference is theres more freedom of where to put them, whereas tiles have to be placed consistently. They treat every "tile" as a sprite, and half maybe a repeating background picture behind it to make it look nicer.

I find it's a pretty good method, actually.

Next is of course the traditional tile system, with 1 or more layers of tiles drawn at certain intervals. This way is probably a bit faster in some cases, because if you have a really big object that needs to be drawn, and only a part of it is on visible on the screen, in the former method, you must draw the entire object, whereas in this you need only draw the tiles that are on or partially on the screen.

I think though, that the best method for a 2D scroller is a mix of both. That way, you can get the functionality of the right one for the right job at different parts of your program. Large images can be chopped into tiles to improve performance, but key objects in the game world can be map sprites to allow freedom of where to place them.

Share this post


Link to post
Share on other sites
Quote:

In a SDL scroller that I've been porting to plain OGL, Super Maryo Chronicles, the map is a collection of objects, no tiles, though they do behave somewhat like tiles. The difference is theres more freedom of where to put them, whereas tiles have to be placed consistently. They treat every "tile" as a sprite, and half maybe a repeating background picture behind it to make it look nicer.


I've actually been considering trying a method like this.

Is it difficult to perform collision detection between the player and the tiles? Since they're objects wouldn't you have to iterate through all of the tiles to check for collisions? Or is there some other way that collisions are checked?

Just curious because I might try to apply something like this in my current side scroller.

Share this post


Link to post
Share on other sites
i think the most effiecient way to do a tile and user collision detection would be to get the reletive x and y of the user and call like

if(iswalkable(userx,usery) == false)
{
do stuff like it hit somthing
}

Share this post


Link to post
Share on other sites
You'd definitely want a tilemap over a big bitmap. It's way more flexible. All you can really do with a big bitmap is blit parts of it.

I wrote a side scroller on the showcase - I used a tile map, but its tiles actually correspond to models which are rendered using OpenGL. Some tiles are flat, but others contain a model, like a wall section or turret.

Mark

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!