Hi Dark,

Yeah, I understood what you were getting at. My basic point of using
my wrestling game as an example is that the programming techniques are
identical to those I'd use for Megaman, Golden Ax, Ninja Turtles,
Mario, or any other  game where there are multiple playable
characters.

You start out by creating a generic player class object and set all
the initial values to 0. If the end user selects the Zero character
from the menu the player object is then initialized with the default
weapons and stats for the Zero character. If the end user decided to
use X instead you'd Initialize the player object with the X
character's  default stats and weapons. From that point on when your
program accesses the player object it will respond accordingly to
whatever stats are stored in the player object. There is no need to
program the game to react differently from character to character
because the player object acts as a global interface to all the
characters in the game.

Since BGT is becoming quite popular I'll demonstrate this concept in
Angelscript.

#include "player.bgt" // Include player class

Player g_player; // Initialized player object

void Select Character (int character)
{

        // player selected X
        if (character == 1)
        {
                g_player.SetJumpDistance (6);
        }

        // player selected Zero
        if (character == 2)
        {
                g_player.SetJumpDistance (4);
        }
}

void PlayerJump ()
{

        // Declare local variables
        bool blocked = false;
        int distance = 0;
        double direction = g_player.IsDirection ();
        double x = g_player.IsX ();
        double y = g_player.IsY ();
        double z = g_player.IsZ ();

        // Jump as far as the
        // player character can go
        while (distance <= g_player.IsJumpDistance ())
        {

                // update the player's location
                x = GetX (direction, x, 1);
                y = GetY (0, y, 1);
                z = GetZ (direction, z, 1);

                // Find out if the player's way is blocked
                blocked = EncounteredObject (x, y, z);

                // If the player's way is blocked
                // exit the jump loop
                if (blocked)
                {
                        distance = g_player.IsJumpDistance ();
                }

                // If the player's way is clear
                // update the player's location
                else
                {
                        g_player.SetLocation (x, y, z);
                }

                // Update the loop
                distance++;
        }

// Drop back to the ground
        PlayerLand ();
}

Although, this tiny example is far from complete the basic point I
outlined here is that after I set the jump distance for the player
character when we go into the while loop it will stop jumping when the
maximum distance is reached or the character plows face first into a
wall, force field, or some other object that will block his/her path.
If the max distance is 4 when the distance counter reaches 4 it will
end the loop and the player will fall to the ground. If it is set to 6
same thing only you get a chance to jump a little further along the
x/y/z axis. This is standard programming 101.

By not hard coding the values and using an interface like a player
object to set maximum jump distance I don't have to write a separate
jump function for X and Zero. This way I can use the same jump
function for either, and the program will react according to the
default stats. Hope that makes sense.

This is why it is so easy to write games with multiple playable
characters. As long as you structure your program properly it doesn't
matter what the game is or what style. The programming conceptually is
identical. You can have one or one hundred characters because once you
initialize your player object with the initial stats the game simply
doesnt care who you are. All it cares about is what values are stored
in your object.

Cheers!

---
Gamers mailing list __ Gamers@audyssey.org
If you want to leave the list, send E-mail to gamers-unsubscr...@audyssey.org.
You can make changes or update your subscription via the web, at
http://mail.audyssey.org/mailman/listinfo/gamers_audyssey.org.
All messages are archived and can be searched and read at
http://www.mail-archive.com/gamers@audyssey.org.
If you have any questions or concerns regarding the management of the list,
please send E-mail to gamers-ow...@audyssey.org.

Reply via email to