Hi JACK,
JACK EVERETT was observed on 11-Oct-97, writing to ALL
Something about: C
JE> I understand that this is the C++ discusion area..but until I can
JE> get my sysop to get the C area I need to ask a question for C..I
JE> I am trying to write a RPG text Game...
JE> and it has come time for the user to take oon some harry monster
JE> but no matter what I do i am unable to get any code ideas to start
JE> this..
I don't do RPG's and I don't have any sample code, but I
may be able to give you some coding tips.
Before you can have any monsters you need to define the
data that the monsters consist of. In the top area of
your C file, before any functions, put all your structure
templates. (you could also use an .h file, but for now
just work with one file) You can also define global
variables here, if you need any. Read your C book to
learn about variable scope. Also note that structure
templates are not variables. They specify the data layout
but you have to declare a variable of that type before
you can use one. I give you an example below... Don't
get overwhelmed by all of this. Work your way through
a tutorial or book and it will all come together for you
in time....
/* this structure template can store the number of
hits required from each weapon to kill the monster
*/
struct hits2kill {
int hammer;
int pistol;
int shotgun;
int grenade;
}
/* this structure template can be the main
monster data structure. Other structures
like the one above can be nested inside this one
*/
struct monster {
char name[26]; /* monsters name */
char description[120]; /* string displayed to player */
int health; /* current health rating */
struct hits2kill hits; /* nested structure hits2kill */
BOOL mortum; /* boolean value is it dead? */
}
Now you have a way to organize data for the monsters.
Before you can use these structures you have to define
and initialize them... Say you want to use two monsters
in the game.. you might define an array of two monsters
and initialize them at the same time like...
struct monster_data monster[2] = {
{ "BloB", "A huge green jelly like mass that
devours his victims by melting them with
his external stomach acids",
100, 50, 25, 10, 2, FALSE },
{ "Stink Thing", "Fat greasy, pimple covered
beast that kills it's victims with poison
gas farts", 100, 70, 37, 17, 5, FALSE }
};
To access an element like say, each time player shoots a
monster you need to see how much health has left...
Somewhere in your program you will have a big loop where
you evaluate what the player does and act on those things.
In this part you might evaluate the shots/hits and how they
impact on the monsters health...
monster[current_monster].health -= (100/monster.hits.shotgun);
These are just some thoughts off the top of my head. This
is not intended as a tutorial by any stretch.
I hope this gives you some ideas on how to code your game.
Roger Scudder
rscudder@usa.net
--- Terminate 5.00/Pro
* TerMail/QWK * Terminate point system, the easiest in the world!
---------------
* Origin: Fidonet * Storm Front BBS (215)788-4662 v.34+ (1:273/216)
|