Quote (Reverence @ Mar 26 2013 06:27pm)
if i store names in structs, like you said i'll be forced to keep them all at the same length, so there will inevitably be several names with white space at the end of them. what i'm saying is that each time i display those names, to keep things evenly spaced, i would have to detect and trim off whatever white space it has. i'd be using that function 4 times each round (skill and monster name for both monsters currently fighting) so i'm wondering if it's a good idea to store names like that or not
i haven't even thought about how i will be displaying the game - i never learned how and i don't have an idea of where to start. but i want to make the guts of the game before i move on to that
WHAT?
just set an array of characters and initialize to \0 (nullbyte)
then use functions like snprint() to take your information and put it into a buffer in which you will print.
all string functions stop at the first nullbyte so there is no "trimming" nessistary.
ext:
char something[10] = {'1', '2', '3', '4', '5', 0, 0, 0, 0, 0};
will always print 12345
id just do something like this tbh
Code
struct{
char name[15] = {0};
int damage = 0;
int multiplier = 0;
char something_else[100] = {0};
} data_set;
struct data_set monsters[100];
sprintf(monsters[1].name, "%s", "lolwat");
monsters[1].damage = 20000;
monsters[1].multiplier = 2;
that way you can have a common data_set for players and monsters but you can create two different arrays for holding the info.
edit from here you could even randomly select a monster from your array for the player to face and based on the player level you can change the multiplier to change the monsters fixed hp/damage
This post was edited by AbDuCt on Mar 26 2013 06:58pm