Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

jimmy_bbq

how to do map?

This topic is 6369 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 wanna develop 2D RPG game. I wonder how map is made. for example, in a map, there are rock or house where we cannot walk through them, How to program it??? is it called as collision detection? Pls Help jimmy

Share this post


Link to post
Share on other sites
Advertisement
Well, Jimmy_bbq, most major games have a number of predefined maps that it uses. These are often stored in 2-D + Arrays.

Collision detection is checking if a unit runs into something that would keep it from entering that "square" of the map (i.e. another unit, a body of water, a wall, etc.)

If you want to get into randomly generated maps, that adds a degree of complexity that I''m guessing you don''t want to mess with.

I''d recommend creating one map to develop with and create come other maps (for other levels, or to randomly select a map from) later.

Share this post


Link to post
Share on other sites
Thank for your reply.

can u teach me more detail about the map. Can you give me algorithm??

another thing, I plan to use mouse in my game, so when I click on my target, the character will go to that target, avoiding rock, wall in map intelligently. How can I do it?

Thanx a lot

Jimmy

Share this post


Link to post
Share on other sites
That''s called pathfinding, and there are MANY ways to do it. You can use simple straight line pathfinding, but that will cause the player to stop if it hits anything, and not find a way around it. It''s easiest, but It''s hard to even call it pathfinding. It''s more like basic trig. You could also use simple midpoint displacement, but that will not necessarily find you the SHORTEST path. You could also trace your way around any objects you encounter. Finally, the most intelligent, but not the fastes alorithm is the A* algorithm. It will always find the shortest path. But it IS slow, especially on large maps.

For moreinfo on everything you could ever need to know about AI of any sort, including pathfinding, go here: http://www.gameai.com/

Share this post


Link to post
Share on other sites
Very simply:

// Top left index of where to start drawing tiles.
int MapX;
int MapY;

// The map data structure (global).
Tile Map[MapWidth][MapHeight];

void DrawMap ()
{
// Where on screen we are drawing.
int ScreenX;
int ScreenY;

ScreenY = 0;
// ScreenTileHeight and Width are the number of tiles
// able to fit on one screen.
for (int y = MapY; y < MapY + ScreenTileHeight; y++)
{
ScreenX = 0;
for (int x = MapX; x < MapX + ScreenTileWidth; x++)
{
DrawTile (ScreenX, ScreenY, Map[MapX][MapY]);
ScreenX += TileWidth;
}
ScreenY += TileHeight;
}
}

// That should get you started. You should be able to figure
// out how to go from there...

farmersckn

Share this post


Link to post
Share on other sites
I''m not sure what is generally used for RPG''s, but I think that isn''t the right question you should be asking. Rather, think what kind of pathfinding you need for your situation.

With that said, RPG''s are generally slower paced games, so you can make pathfinding a complex, time consuming process if you wish. How ever, look up something like the depth first or breadth first searched. They are definately much easier to code than A* and you won''t take much of a time hit by using them in an RPG. This website and gameai should give you more than enough info on pathfinding and tile based games.

Good luck and cheers,

Ben

Share this post


Link to post
Share on other sites
The best source of information I know on the Net is Amit Patel''s webpage.

He has a lot of explanations, if not source code. If you are any good at programming, you will have no problem doing your own A* program

youpla :-P

Share this post


Link to post
Share on other sites
i am not good in programming. so i think it''s better to have source code to refer to....

WHERE can i get source code for A*??

Share this post


Link to post
Share on other sites

  • 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!