About Store Forum Documentation Contact



Post Reply 
Need help understanding FPS code
Author Message
unforgivenhero Offline
Member

Post: #1
Need help understanding FPS code
Alright so I've been spending a while looking at all the Bloody Massacre code and have simultaneously been working on a FPS project. However, I am having trouble understanding how the player works in Bloody Massacre (BM).

From looking at the BM code, I think that the player's status (such as remaining health, whether he's alive or dead etc; is defined in the character.h file. This then includes the chr() constructor which is called in the player.h file. The player structure is then created in the main.h file. Does this seem correct or am I looking at it wrong?

What I've done so far is create a player by extending the Game::Chr class in a structure named player. But I want to add health, lives, alive/dead functionality. Should I create another source file to do this and link it to the player structure or what? I really need help creating a working player and this is just so confusing.

Any help will be immensely appreciated! smile
07-18-2011 12:45 AM
Find all posts by this user Quote this message in a reply
Dampire Offline
Member

Post: #2
RE: Need help understanding FPS code
In BM all "health" functionality realized in character.h in order to enemies (AI.h) and player (Player.h) have same methods of managment alife/dead. You may do it in Player.h or Character.h, it does not matter.
07-18-2011 05:53 AM
Find all posts by this user Quote this message in a reply
unforgivenhero Offline
Member

Post: #3
RE: Need help understanding FPS code
Alright, I'll try implementing the methods inside the player structure then.
07-18-2011 12:38 PM
Find all posts by this user Quote this message in a reply
unforgivenhero Offline
Member

Post: #4
RE: Need help understanding FPS code
Alright so I decided to keep everything in my player source file where I declared the STRUCT(Player ,Game::Chr) to extend the game character class and create the player. However, I'm having a bit of trouble setting up some functions.

Right now, I have these virtual functions:

virtual void addDamage(Flt damage, Player *src); // Adds damage to the player
virtual void die(); // Called when player is dead
virtual void attack(Player &target) {} // used when attacking a target

My problem is that when looking at the blood massacre code, I noticed these were declared in the character.h file. Then in BM's player.h file the functions:

void die ();
void addDamage (Flt damage, Chr *src);

were declared. Can I simply merge the adddamage functions and die functions together in my player.h file? Because when I declare the virtual functions and the above 2 in the same source file I get an error.

Any help is appreciated. I'm struggling a ton just to make a character lol.
07-21-2011 08:43 PM
Find all posts by this user Quote this message in a reply
Dampire Offline
Member

Post: #5
RE: Need help understanding FPS code
Delete "virtual" and all be fine.
07-22-2011 07:54 AM
Find all posts by this user Quote this message in a reply
unforgivenhero Offline
Member

Post: #6
RE: Need help understanding FPS code
Alright, ill try that
07-22-2011 11:54 AM
Find all posts by this user Quote this message in a reply
Post Reply