Playing Roles CALVERVTUTURP READ THIS!!!

Non-platform specific questions.

Playing Roles CALVERVTUTURP READ THIS!!!

Postby BlarghNRawr » Thu Sep 25, 2008 1:21 am

Calvervtuturp is making the adventure mode for my smash bros planet ( :mrgreen: ), and he/i need to know how to play roles in RPG games, so all of your party and the enemy takes turns
also the enemy needs to attack a random party member instead of always one
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: Playing Roles CALVERVTUTURP READ THIS!!!

Postby edh » Sat Sep 27, 2008 9:06 pm

You could make a variable to hold the current active character. You could actually make an array to store the information you would need in a struct, one struct for each character. Then when you move (keydown or mouse click) the active character would move, do it's action, whatever. When the turn ends, increment the variable for the current character.

WARNING: Rough example follows.
Here is a struct to store a character name, reference to an actor (sprite), some hit points and some magic points. You could do whatever you need. The important piece is probably the actor pointer.

This example also creates an array of two heros and sets some default values.

Code: Select all
struct character {
        char *name;
        Actor* actor;
        int hp;
        int mp;
} heroes[2] = { {"hero one\0", 0, 10, 10}, {"hero two\0", 0, 5, 15} };


Then you could have a global value for which character is active and the total number of actors (for bookkeeping).
Code: Select all
int activeCharacter  = 0;
int numberCharacters = 2;


Then when you want to move one, you could do something like this.
Code: Select all
heroes[activeCharacter].x += 5;


At the end of a character turn you would increment the activeCharacter, taking care to make sure you don't go past the end of the array.
Code: Select all
activeCharacter = (++activeCharacter) % numberCharacters;


To attack one randomly (assuming all characters are in a place where they could be attacked), you would just generate a random number from 0 to numberCharacters.
User avatar
edh
 
Posts: 233
Joined: Thu Sep 13, 2007 12:17 am
Location: Maine, USA
Score: 14 Give a positive score

Re: Playing Roles CALVERVTUTURP READ THIS!!!

Postby BlarghNRawr » Sat Sep 27, 2008 9:41 pm

O_O
never thought of that :) thnx
Download Game Music
current projects:
Bold! ?% Started mechanics
Unnamed puzzle game 60% --i need a name!--
User avatar
BlarghNRawr
 
Posts: 767
Joined: Wed Jun 25, 2008 12:36 am
Location: Not using G-E anymore. Now using Source SDK.
Score: 27 Give a positive score

Re: Playing Roles CALVERVTUTURP READ THIS!!!

Postby equinox » Mon Mar 02, 2009 4:18 pm

int mp;
} heroes[2] = { {"hero one\0", 0, 10, 10}, {"hero two\0", 0, 5, 15} };

why instead not to write: heroes[2] = { {"hero.0", 0, 10, 10}, {"hero.1", 0, 5, 15} };
User avatar
equinox
 
Posts: 118
Joined: Tue Jan 29, 2008 3:38 pm
Score: 0 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest

cron