Monday, December 29, 2008

MMORPG Day 8

On Day 8 I totally restructured the Map class (object). I found my current Map class was going nowhere and I saw no way out. I had one of those "Java Revelations" where you suddenly think of a way a lot easier and elegant than the one you're currently using. I shrank the code for the Map by half and now it's a lot easier to alter and more open to different options.

What I basically did was to substitute arrays and loops for things I was doing in a totally different way. I'm pretty surprised that I hadn't thought about this stuff before but I probably didn't think it was necessary. I now have an array of tiles in my Map class. Each tile holds all the variables about itself and almost nothing gets stored in the Map class itself except very general things. A Tiles variables include: Walkability (collision of all four sides), Colour(s), Object (ex. thing on top), Heights (all four corners), Actions (some script of a scripting language I haven't created yet triggered by character moving near/on tile).

I thought of a way to determine an objects/characters height when on a Tile. I would simply take the four sides of a Tile and find the average (height1+height2+height3+height4/4). The Characters height would have to be altered accordingly when moving. I hope to interpolate between nearby tiles when the character is not standing on any to find the next best height.

Nothing else really happened on day 8 which is kind of disappointing but I hope twice as much is going to happen on day 9 as I kind of pre-worked.

1 comment:

Anonymous said...

Sounds like your refactoring. It's a good idea to refactor often. See if you can decouple your Map class in two separate classes if it starts to become unwieldly.