• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

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

 
Ranch Hand
Posts: 222
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
blacksmith
Posts: 1332
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic