posted 20 years ago
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]