Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 ... 3 4 [5] 6 7 ... 72

Author Topic: The Roguelike Development Megathread  (Read 245860 times)

Fenrir

  • Bay Watcher
  • The Monstrous Wolf
    • View Profile
Re: The Roguelike Development Megathread
« Reply #60 on: January 27, 2009, 04:20:18 pm »

Deciding on a data structure for the map is proving to be a pain.
Logged

Mephisto

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #61 on: January 27, 2009, 04:33:43 pm »

Thanks for the replies to my post. There were some things I haven't thought of. It's still going to be a while before I can actually code this beast, though. I'd rather finish a few of the C++ books I'm reading before starting.

I do have a suggestion for others. Get one of the "guides for dense people," better known as Complete Idiot's Guide to... or ... for Dummies. I've got a background in Ada. Possibly because of that, I read most of C++ for Dummies in roughly five or six hours one weekend.

I guess I shouldn't recommend Idiot's Guide, though. Even though it was written in 1998 and C++ was standardized in '96, the book still uses iostream.h, strings.h, etc. The file manipulation section didn't work at all. Also, both of these books are supposedly cross-platform, but it turns out that they're not without some fiddling.
Logged

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: The Roguelike Development Megathread
« Reply #62 on: January 27, 2009, 04:40:31 pm »

In case this helps anyone...

My project has:
- A map class, with
-- A three-dimensional array of Tile structs.
-- A vector of all Creatures on the map.
-- A vector of all 'inventory' Things on the map.

Each Tile has:
- A number representing what kind of tile it is.
- A vector of all Creatures in the tile.
- A vector of all Things in the tile.

I also have a global array of TileDefinition structs, which Tile references, containing:
- The possible characters you can use to draw that tile (usually 1, sometimes 4ish like DF's ground)
- foreground, background color
- the cost to move through that tile for different ambulation types
- whether it blocks LOS

That's the basic basic stuff...
Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: The Roguelike Development Megathread
« Reply #63 on: January 27, 2009, 05:13:42 pm »

Using a 3d array to store everything seems a bit much. Couldn't you use a 2d aray and fill them with pointers to containers or other arrays? That way you only need the containers or arrays for tiles where objects can actualy be, probably saving you like 25% on space.
Logged

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: The Roguelike Development Megathread
« Reply #64 on: January 27, 2009, 06:25:11 pm »

Hmm, good idea.  I still like my 3d array because my map is 3d (because I'm crazy--not recommended), but replacing the vectors with vector*s with null for empty is a decent idea.

I would *not* go so far as to make creatures a linked list.  I mean, I could imagine someone saying "each tile has a pointer to a creature or null, and each creature has a pointer to the next creature on the tile", but that way lies madness.  If you were coding twenty years ago that would be worthwhile, but not today.
Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

Dasleah

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #65 on: January 28, 2009, 02:42:44 am »



Still plugging away on this. Once I've done better tree placement / spawning, I'll move on to Player movement.



SEXY COLOURED TREE MAXIMUM UPDATE GO GO GO
« Last Edit: January 28, 2009, 05:53:37 am by Dasleah »
Logged
Pokethulhu Orange: UPDATE 25
The Roguelike Development Megathread.

As well, all the posts i've seen you make are flame posts, barely if at all constructive.

chaoticag

  • Bay Watcher
  • All Natural Pengbean
    • View Profile
Re: The Roguelike Development Megathread
« Reply #66 on: January 28, 2009, 07:02:33 am »

Uhh, can you post a link to the library you use dasleah? My results turned up with a version for python 1.4.1
Logged

corvvs

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #67 on: January 28, 2009, 08:11:53 am »

Hmm, good idea.  I still like my 3d array because my map is 3d (because I'm crazy--not recommended), but replacing the vectors with vector*s with null for empty is a decent idea.

I would *not* go so far as to make creatures a linked list.  I mean, I could imagine someone saying "each tile has a pointer to a creature or null, and each creature has a pointer to the next creature on the tile", but that way lies madness.  If you were coding twenty years ago that would be worthwhile, but not today.

Er... it would make more sense for each *creature* to have a pointer to the tile it's sitting on. And what would be the alternative to a linked list of creatures? A fixed array, so you can only have a maximum of X ever? Or are you going to realloc() your creature array whenever you need to add a new one and just hope that you have enough contiguous memory free?
Logged

qwertyuiopas

  • Bay Watcher
  • Photoshop is for elves who cannot use MSPaint.
    • View Profile
    • uristqwerty.ca, my current (barren) site.
Re: The Roguelike Development Megathread
« Reply #68 on: January 28, 2009, 09:20:39 am »

I would say a linked list of all the creatures on the level, not on each tile, to make creature updates easier. A circular linked list?

Of course, it could also have linkages for the tile...
Logged
Eh?
Eh!

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: The Roguelike Development Megathread
« Reply #69 on: January 28, 2009, 12:40:35 pm »

Er... it would make more sense for each *creature* to have a pointer to the tile it's sitting on.
I have each critter store its coordinates on itself, but that's equally good.

And what would be the alternative to a linked list of creatures? A fixed array, so you can only have a maximum of X ever? Or are you going to realloc() your creature array whenever you need to add a new one and just hope that you have enough contiguous memory free?

You misunderstand...though I do store my creatures in a vector of Creatures on the map, and a vector of Creatures in each tile, which is close enough for me.  Storing them in a linked list is just as good.

What I was suggesting against is turning each creature into both a creature and a storage data type, where its properties are "name, hit points, next critter in the list".  Eh, I guess that's something you only see in old old game servers, and nothing modern.  Using standard containers is so much easier, and it'll get your game out the door so much faster, with still almost no overhead.
Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

Virex

  • Bay Watcher
  • Subjects interest attracted. Annalyses pending...
    • View Profile
Re: The Roguelike Development Megathread
« Reply #70 on: January 28, 2009, 01:05:33 pm »

Er... it would make more sense for each *creature* to have a pointer to the tile it's sitting on.
I have each critter store its coordinates on itself, but that's equally good.

I might be mistaken, but doesn't that complicate things like checking which tiles are walkable et cetera?
Logged

Granite26

  • Bay Watcher
    • View Profile
Re: The Roguelike Development Megathread
« Reply #71 on: January 28, 2009, 01:10:14 pm »

For stats, I'm using a hashtable(statname as string, statvalue as integer) structure and a generalize 'hasstats' class that impliments an overwritable getstat(statname) function.

Makes equipment a lot easier to manage, and adding in a new stat is extremely fast.  (Oops, forgot speed, well, give a default to the base character object, qed)

It works for classes, skills, objects, effects, terrain, and whatever.

mainiac

  • Bay Watcher
  • Na vazeal kwah-kai
    • View Profile
Re: The Roguelike Development Megathread
« Reply #72 on: January 28, 2009, 02:09:32 pm »

Ha!  I finally figured out what I was doing wrong with classes and headers!
Logged
Ancient Babylonian god of RAEG
--------------
[CAN_INTERNET]
[PREFSTRING:google]
"Don't tell me what you value. Show me your budget and I will tell you what you value"
« Last Edit: February 10, 1988, 03:27:23 pm by UR MOM »
mainiac is always a little sarcastic, at least.

Sowelu

  • Bay Watcher
  • I am offishially a penguin.
    • View Profile
Re: The Roguelike Development Megathread
« Reply #73 on: January 28, 2009, 02:46:13 pm »

Er... it would make more sense for each *creature* to have a pointer to the tile it's sitting on.
I have each critter store its coordinates on itself, but that's equally good.

I might be mistaken, but doesn't that complicate things like checking which tiles are walkable et cetera?

Yes, but it makes it slightly easier to draw them.  Six/half dozen.  Mine's a little more graphics heavy, so it works.  YMMV, and it's just a few dereferences once per time that you touch the critter.

And each tile still has pointers to all the critters in it.
Logged
Some things were made for one thing, for me / that one thing is the sea~
His servers are going to be powered by goat blood and moonlight.
Oh, a biomass/24 hour solar facility. How green!

Fenrir

  • Bay Watcher
  • The Monstrous Wolf
    • View Profile
Re: The Roguelike Development Megathread
« Reply #74 on: January 28, 2009, 02:48:10 pm »



It is the dawn of a new era. The Age of Legends has ended and the Age of Little Red @-Men on Brown .s has begun.
Logged
Pages: 1 ... 3 4 [5] 6 7 ... 72