aspose file tools*
The moose likes Game Development and the fly likes What should a 2d tile-based map basically have??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "What should a 2d tile-based map basically have???" Watch "What should a 2d tile-based map basically have???" New topic
Author

What should a 2d tile-based map basically have???

HaoZhe Xu
Ranch Hand

Joined: Nov 03, 2003
Posts: 222
I used to write games in C++ with allegro, but all failed, because when i know something new about game, i like to add it in my game. after several add-in, m y game doesn't look like a game :-<
so i decided to design my own game, not influenced by others, and i am wondering what basic element should a 2d tile-based map have?
here's my previous work:

I know it's not a good structure/design, so can anyone suggest what should be added/modified.
there're two approach of displaying the map to screen:
1. use currentCharacter to represent characters, a loop through all the tiles on current screen, if find currentCharacter not -1, then get the character displayed, when character moves, currentCharacter is -1 and the destination tile's currentCharacter is his/her number
2. use the x,y properties in character class, initially, a loop through all characters and use their x,y to calculate their position in the map, accordingly, set the tile's currentCharacter, when character moves, modify the x or y value, and calculate the new position

it's a little bit messy, i hope you understand, the difference is: no 1 is easy to implement, but character can only move by a tile's width/height, if the tile's width/height is big, then it is teleport! (i used to use 32x32, it's ok), no 2 needs more calculations, but different characters can moves by different step length, use their x,y divided by tile's width/height to get their tile-position.
forgive my poor English
[ Jess added a carriage return to shorten the width of the page and added some spacing to make the code more readable. ]
[ August 14, 2004: Message edited by: Jessica Sant ]

[url]Olnex.net[/url]
[SCJP 1.2, SCJD, SCWCD]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
A good game should first have a set of requirements and design decisions, before coding starts.

Games are complex pieces of software, you wouldn't want to start coding a million line business application without some up-front design would you?

There's many decisions to make even for the type of tile map.
2D or 3D is basically a decision for display code, not game code per se.
But will you use square tiles, hexagonal, or some other shape (those two are the most common for a reason)?
What will be the things your tiles will have?
Movement factors (terrain type?), altitude, weather options maybe (which together with terrain might mean a further movement penalty), etc.
Can there be one or more than one character on a tile at any time?

That's just what I could think of in a few minutes.

Then for your characters (both user controlled and NPCs), come up with similar decisions.


42
Charles Rector
Greenhorn

Joined: Feb 18, 2003
Posts: 14
Heya!

As far as character movement, I've been using the second method for a long time now. I personally think it's a lot simpler and more flexible than the first method you mentioned. Speed only becomes an issue if you've got a lot of characters onscreen at once. Even in that situation, there are ways to speed up processing with caching and other little tricks. But cross that bridge when/if you get to it!


Driven. You know. By people who drive.
Warren Dew
blacksmith
Ranch Hand

Joined: Mar 04, 2004
Posts: 1332
    
    2
Jeroen Wenting:

A good game should first have a set of requirements and design decisions, before coding starts.

Games are complex pieces of software, you wouldn't want to start coding a million line business application without some up-front design would you?


Well, some up front design ... but I think if you took an agile approach to developing the game, you would start coding pretty early in the process, before many of the requirements and design decisions were finalized.

Wheter it would be a good idea to develop a game that way is an interesting question.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: What should a 2d tile-based map basically have???