Author Topic: Maps and how they work  (Read 6231 times)

Shaggy

  • Rogueliker
  • ***
  • Posts: 65
  • Karma: +0/-0
  • (╯°□°)╯︵ ┻━┻ <( !@#$ THIS, I'M OUT. )
    • View Profile
    • Not Quite ADoM
    • Email
Maps and how they work
« on: October 24, 2010, 01:27:08 AM »
So for some reason I'm having a major brain fart today  ::)

I can't for the life of me wrap my head around an ideal setup for maps in-game. I've got a Tile class [Character, Color, Walkable, Creature, and Item], as well as an array of tiles called CurrentMap which holds a screen-sized square of tiles, but that's not really working.

I either need to have a larger array of tiles that holds the whole map, or somehow load what's outside of the screen area in a buffer of some sort? I dunno. I just feel lost, and was wondering how you guys set up your map/tile classes and such? Not necessarily as in generation algorithms, but just as far as storing them and using the data in-game
Check out my blog at http://NotQuiteADoM.blogspot.com/ !

Krice

  • (Banned)
  • Rogueliker
  • ***
  • Posts: 2316
  • Karma: +0/-2
    • View Profile
    • Email
Re: Maps and how they work
« Reply #1 on: October 24, 2010, 05:54:45 AM »
The map is usually the size of level and part of it (view size) shown from offset.

Ari Rahikkala

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 64
  • Karma: +0/-0
    • View Profile
    • Email
Re: Maps and how they work
« Reply #2 on: October 24, 2010, 09:20:34 AM »
You generally want your map objects to simply contain a level. You could for instance make a Map class that has a .get(x, y) method, which when called on coords that are in bounds returns the tile at those coords, and when called on coourds outside the bounds returns nothing but an undiggable wall. If you want to keep the @ at the middle of the screen when rendering the UI (assuming the upper left corner of your rendering window is (0, 0) on the screen), just take the screen position, subtract half the playing window size, add the player's position on the map, and call your .get() on that.