M
Michael Strorm
Hi!
I posted a message a while back asking for project suggestions, and decided
to go with the idea of creating an adventure game (although it was never
intended to be a 'proper' game, rather an excuse to write- and learn- some
C++).
To cut a long story short, I wrote a fair chunk of it, but realised that
it's... not very good. Okay, it's my first "proper" C++ program, so that's
no big deal, but I don't want to waste more time working on a program that
should be rewritten from scratch (I want to start reading 'Accelerated C++'
instead). What *would* be interesting would be to hear what other people
think about the (compilable, but not properly working) code.
It's a long program, spread over many files, so I haven't posted them here.
The URL is
http://www.mstrorm.free-online.co.uk/
Yes, I know the code isn't particularly well laid out or commented- but I
hope it's clear enough.
The design of the program is that a Controller class controls the flow of
events and oversees everything. A base-class 'Noun' includes common behavior
and is extended to give us game locations, items (i.e. physical objects),
Beings (i.e. game characters, further subclassed for the Player object which
represents the human player) and exits.
Given a command such as
eat chocolate
or
go north
the controller finds the Noun-subclass-object representing chocolate (an
Item) or north (an Exit)- that object then does the action "eat" or "north"
respectively. Assuming the Noun-subclass supports that action, it can
respond appropriately (e.g. the Exit object with id=="north" would update
the player's location in its "go" method to wherever the exit pointed to).
Note that action methods (or, more specifically, functions) are static
functions held in a vector of pointers. I don't like the way that the vector
of function-pointers is initialized, but it seemed the best way at the time.
Criticisms of the large-scale design, or basic programming would be equally
useful. I think there's plenty to criticize about both, as you can see from
the comments I left in (though I like the subclassing of Nouns into
different object types).
Anyway, feedback would be appreciated....
I posted a message a while back asking for project suggestions, and decided
to go with the idea of creating an adventure game (although it was never
intended to be a 'proper' game, rather an excuse to write- and learn- some
C++).
To cut a long story short, I wrote a fair chunk of it, but realised that
it's... not very good. Okay, it's my first "proper" C++ program, so that's
no big deal, but I don't want to waste more time working on a program that
should be rewritten from scratch (I want to start reading 'Accelerated C++'
instead). What *would* be interesting would be to hear what other people
think about the (compilable, but not properly working) code.
It's a long program, spread over many files, so I haven't posted them here.
The URL is
http://www.mstrorm.free-online.co.uk/
Yes, I know the code isn't particularly well laid out or commented- but I
hope it's clear enough.
The design of the program is that a Controller class controls the flow of
events and oversees everything. A base-class 'Noun' includes common behavior
and is extended to give us game locations, items (i.e. physical objects),
Beings (i.e. game characters, further subclassed for the Player object which
represents the human player) and exits.
Given a command such as
eat chocolate
or
go north
the controller finds the Noun-subclass-object representing chocolate (an
Item) or north (an Exit)- that object then does the action "eat" or "north"
respectively. Assuming the Noun-subclass supports that action, it can
respond appropriately (e.g. the Exit object with id=="north" would update
the player's location in its "go" method to wherever the exit pointed to).
Note that action methods (or, more specifically, functions) are static
functions held in a vector of pointers. I don't like the way that the vector
of function-pointers is initialized, but it seemed the best way at the time.
Criticisms of the large-scale design, or basic programming would be equally
useful. I think there's plenty to criticize about both, as you can see from
the comments I left in (though I like the subclassing of Nouns into
different object types).
Anyway, feedback would be appreciated....