Jump to content

  • Log In with Google      Sign In   
  • Create Account

2d map for an rpg


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
44 replies to this topic

#1 stein102   Members   -  Reputation: 293

Like
0Likes
Like

Posted 08 January 2012 - 06:27 PM

I want to make a 2d rpg game, I'm stuck on how to make the map. I want to make a map with a grid, where you use the arrow keys to go from square to square. What is the best way to do this?

Thanks

Sponsor:

#2 bpx95   Members   -  Reputation: 102

Like
0Likes
Like

Posted 08 January 2012 - 06:33 PM

One way is to make just a map file with contents that may look something like:

0 1 2 5 0 1
2 3 4 1 0 2
1 0 3 4 1 0
1 2 5 3 0 1

Where each of the numbers is the id of a type of square. So '0' might be dirt, '2' might be rock, etc. The file could look like a grid so that you can easily look at it and see what everything represents.

You can also use a tool such as Mappy: http://tilemap.co.uk/mappy.php
Or just make your own tile editor.

You just need a file that has a list of all the tiles in your world, and probably some info such as width and height of the world in tiles. Then your program can just open up the file, read the info it needs (width and height), then read in the tiles one-by-one. You can organize the tiles in an array.

#3 Alpha_ProgDes   Crossbones+   -  Reputation: 3420

Like
0Likes
Like

Posted 08 January 2012 - 07:00 PM

I'll ask this. How far have you gotten in creating your game?

Beginner in Game Development? Read here.  

 

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

 

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts smile.png
 

Spoiler

#4 stein102   Members   -  Reputation: 293

Like
0Likes
Like

Posted 08 January 2012 - 07:10 PM

I'm just starting my game now. I'm really not 100% on where to start, I thought doing the graphics would be a good start so I could see my progress as I moved on. If this is a bad idea, can you please point me in the right direction? :)

Thanks

#5 Alpha_ProgDes   Crossbones+   -  Reputation: 3420

Like
2Likes
Like

Posted 08 January 2012 - 07:40 PM

Before you get hung up on maps, if I were you, I'd get a character (or any object) on the screen and move him around with the arrow keys first. That's normally the first thing to accomplish.

Beginner in Game Development? Read here.  

 

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

 

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts smile.png
 

Spoiler

#6 stein102   Members   -  Reputation: 293

Like
0Likes
Like

Posted 08 January 2012 - 07:43 PM

After that, what is the next step? Because that doesn't take much time at all? I can get that done in a few minutes.

#7 Alpha_ProgDes   Crossbones+   -  Reputation: 3420

Like
2Likes
Like

Posted 08 January 2012 - 08:14 PM

  • After that get a static background on the screen and have the character/object move around in it.
  • Add another character (NPC) that randomly moves around the screen.
  • Get your character/object to shoot a projectile in the direction you are facing.
When you get those three things up and running, then you should be able to move on to maps. Feel free to post the code after you're done :)

Beginner in Game Development? Read here.  

 

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

 

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts smile.png
 

Spoiler

#8 stein102   Members   -  Reputation: 293

Like
0Likes
Like

Posted 08 January 2012 - 08:16 PM

Thanks :D I'll get to work!

#9 stein102   Members   -  Reputation: 293

Like
0Likes
Like

Posted 08 January 2012 - 10:37 PM

Okay, got that done, now I guess I'll add collision to everything? That would be my next step?

#10 Alpha_ProgDes   Crossbones+   -  Reputation: 3420

Like
0Likes
Like

Posted 08 January 2012 - 11:33 PM

After you add collision, do the following:
  • Have a file that has 20 letters across and 20 down. In all the grid should have 400 letters all together.
  • Load that file, read the file one letter at a time and display each letter.
  • Now associate a grass graphic with the letter g, rock graphic with the letter r, bush graphic with the letter b.
  • Now create another 20 x 20 file filled with all r, g, and b's.
  • Having the association of letter to graphic and reading that file should create a 20 x 20 map of rocks, grass, and bushes.
  • You may or may not want to use a 2-dimensional array for this, depending on your approach.

Again, feel free to post code when you're done. But there people far more knowledgeable and experience than me that can help you with your approach, architecture, and code.


Note: see you tomorrow.

Beginner in Game Development? Read here.  

 

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

 

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts smile.png
 

Spoiler

#11 BeerNutts   Members   -  Reputation: 1614

Like
0Likes
Like

Posted 09 January 2012 - 12:35 PM

What i would suggest is either writing your own map editor, or use a tile-map tool. Considering, typical RPG's have large worlds, just using a text file with numbers representing tiles is not going to be easy or fun.

What you want is your world laid out in a map-tile editor, and you can actually see what it's going to look like on screen.

So, check out Mappy, or Tiled (google them), and port the output into your game, or you're going to write your own map.

FWIW, I'd suggest using Mappy or Tiled, but creating your own can have benefits as well. If you create your own, be sure most of the functionality will be re-used in your game.
My Gamedev Journal: 2D Game Making, the Easy Way

---(Old Blog, still has good info): 2dGameMaking
-----
"No one ever posts on that message board; it's too crowded." - Yoga Berra (sorta)

#12 Alpha_ProgDes   Crossbones+   -  Reputation: 3420

Like
0Likes
Like

Posted 09 January 2012 - 12:38 PM

Well I agree with you BeerNutts that in the long run he should use a tool to do the job. But since it's his first go-around (I'm assuming) having hiim do this gets him familiar with the basic concepts.

Beginner in Game Development? Read here.  

 

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

 

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts smile.png
 

Spoiler

#13 vleugel   Members   -  Reputation: 205

Like
0Likes
Like

Posted 09 January 2012 - 12:58 PM

Wouldnt it be a good idea to use TileObjects instead of numbers?
These TileObjects can store the type of image being displayed (background and possible images on top like trees or 3d effects), the type of tile (passable or not), possibly the movements costs and a pointer to the object currently on it (a nullptr in case the tile is not occupied). Although I have to admit not having any experience in these kind of games, so I'm not sure about the performance using a system like this. This way you won't have to use collision detection, you can just use if(RelativeTile(1,0)->IsPassible() && RelativeTile(1,0)->Occupier() == nullptr) {moveRight()}

You do have to write your own map editor in that case.

#14 phil_t   Members   -  Reputation: 1426

Like
0Likes
Like

Posted 09 January 2012 - 01:36 PM

I don't think you'd want each tile to be a "TileObject" - there would be performance and memory usage implications. You could achieve the same effect with the flyweight pattern though.

#15 Alpha_ProgDes   Crossbones+   -  Reputation: 3420

Like
0Likes
Like

Posted 09 January 2012 - 01:48 PM

Before we start getting real fancy with the tile data structures, we may want him to finish this up. He is still new to this.

Beginner in Game Development? Read here.  

 

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

 

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts smile.png
 

Spoiler

#16 stein102   Members   -  Reputation: 293

Like
0Likes
Like

Posted 09 January 2012 - 09:33 PM

Have a file that has 20 letters across and 20 down. In all the grid should have 400 letters all together.

  • Load that file, read the file one letter at a time and display each letter.
  • Now associate a grass graphic with the letter g, rock graphic with the letter r, bush graphic with the letter b.
  • Now create another 20 x 20 file filled with all r, g, and b's.
  • Having the association of letter to graphic and reading that file should create a 20 x 20 map of rocks, grass, and bushes.
  • You may or may not want to use a 2-dimensional array for this, depending on your approach.


I'm kinda lost on how to do that.

So, create a text file with 400 characters, load it, read it. That's about as far as I got.

#17 Alpha_ProgDes   Crossbones+   -  Reputation: 3420

Like
0Likes
Like

Posted 09 January 2012 - 10:49 PM

What are language, IDE, and/or program are you using?

Beginner in Game Development? Read here.  

 

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

 

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts smile.png
 

Spoiler

#18 stein102   Members   -  Reputation: 293

Like
0Likes
Like

Posted 09 January 2012 - 10:50 PM

I'm using Eclipse with Java.

#19 Alpha_ProgDes   Crossbones+   -  Reputation: 3420

Like
0Likes
Like

Posted 09 January 2012 - 10:54 PM

Do you know how to load a graphic file in Java? (Honestly, I don't know the libraries that well, so don't take offense)

Beginner in Game Development? Read here.  

 

Super Mario Bros clone tutorial written in XNA 4.0 [MonoGame, ANX, and MonoXNA] by Scott Haley

 

If you have found any of the posts helpful, please show your appreciation by clicking the up arrow on those posts smile.png
 

Spoiler

#20 stein102   Members   -  Reputation: 293

Like
0Likes
Like

Posted 09 January 2012 - 10:55 PM

I know how to load an image.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS