Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Storing Pokemon in an array?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 jblevins1991   Members   -  Reputation: 99

Like
0Likes
Like

Posted 01 February 2012 - 07:47 PM

Im working on a pokemon game and so far the only thing that has stumped me is storing pokemon and storing attacks.

class pokemon
{
public:

} Bulbasaur;

above is my pokemon template class. i have more done than this but i wont post any more that what i have above for various reasons.

class player
{
public:
int playersparty[6];

};

above is the player class. i can't wrap my mind around how to store objects such as pokemon in an array. the array will represent the players pokemon party through out the game. any help would be appreciated.

Sponsor:

#2 Cornstalks   Crossbones+   -  Reputation: 6999

Like
1Likes
Like

Posted 01 February 2012 - 08:00 PM

You mean something like
class player
{
    public:
        Pokemon playersparty[6];
};
?

Or do you mean something much more generic, so you can store both Pokemon and players in this array?

FYI, creating a Pokemon-style game is fine, but using trademarked and copyrighted characters and IP is not.
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#3 jblevins1991   Members   -  Reputation: 99

Like
0Likes
Like

Posted 01 February 2012 - 08:02 PM

You mean something like

class player
{
	public:
		Pokemon playersparty[6];
};
?

Or do you mean something much more generic, so you can store both Pokemon and players in this array?

FYI, creating a Pokemon-style game is fine, but using trademarked and copyrighted characters and IP is not.


Thank you for the help. I know that using trademarked IP is illegal sir. I appreciate your concern and vigilance. I am creating my own character etc.

Any clue on how to create attacks?

#4 Cornstalks   Crossbones+   -  Reputation: 6999

Like
0Likes
Like

Posted 01 February 2012 - 08:37 PM

Any clue on how to create attacks?


That's a pretty vague question. You can make it so a Pokemon has a takeDamage() function that tells it how much damage and what kind (i.e. fire, water, etc.), and a Pokemon can invoke takeDamage() on another Pokemon. There's a million ways to implement this though and it really depends on how you design your program.
[ I was ninja'd 71 times before I stopped counting a long time ago ] [ f.k.a. MikeTacular ] [ My Blog ] [ SWFer: Gaplessly looped MP3s in your Flash games ]

#5 LorenzoGatti   Crossbones+   -  Reputation: 3081

Like
0Likes
Like

Posted 02 February 2012 - 09:59 AM

There are three obvious layers:
  • A fixed set of hardwired basic mechanisms: for example hit points, special states (e.g. stunning), creature experience and change (e.g. adding moves or evolving to another species). They are the foundation of everything that can happen in the game.
  • Arbitrary but fixed numbers of definitions including the not-at-all-Pokémon species, their attacks and their types. Loaded from data files, immutable (and therefore omitted from saved games), and referencing sprites and other equally read-only game assets. Every creature should have some means (a pointer?) to access the objects that represent its species and its attacks.
  • An unlimited amount of not-at-all-Pokémon individuals (wild, in the player's team, in someone else's team, etc.) These objects are created at the beginning of the game and according to other events (scheduled battles, random encounters etc.), are destroyed when the player loses track of them, are normally persisted in saved games, and have a lot of mutable fields (e.g. current and maximum hit points and skills).
A variable named Bulbasaur is just about the most inappropriate way to make a creature species object. Do it a few hundred times, and you'll bloat your source code and increase compilation times, mix up your engine and game content without hope, and forfeit proper editing tools and game data customization.

Omae Wa Mou Shindeiru


#6 Tocs   Members   -  Reputation: 685

Like
0Likes
Like

Posted 03 February 2012 - 01:11 PM

I cloned the Gen 4 pokemon mechanics a while ago, and they're fairly difficult to abstract and construct. There rules to the mechanics often have special cases. For instance ordering attacks and quick claw's effect. There is a wide variety of attack mechanics so designing around it proved fairly challenging.

Pokemon have individual stats, and base stats. So I had an object "PokemonSpecies" which represented for instance Bulbasaur, it contained things like Bulbasaurs base stats (45 hp, 49 atk, 49 def, 65 sp.atk, 65 sp.def, 45 speed), pokedex information, EV yeild, and sprites and such. PokemonSpecies were loaded from files much like LorenzoGatti said. So I had like "Bulbasaur.pkmn" and "Pikachu.pkmn" etc etc.

The actual "Pokemon" object held things like Level, CurrentHP, stats, EVs, etc etc. So there is a clear distinction between species and an actual Pokemon.

Handling attacks is pretty convoluted, some moves last more than one turn, moves have only one type but it is not always the same (metronome), and have a category of damage (which effects which type of def and atk effect its damage) Some moves require special effects on hit, on activation, on miss, and other various conditions. Moves make "contact". You're going to have a bunch of virtual functions which you override to accomplish special effects.

So, not to be condescending, if you're having trouble gasping how to do things I'd recommend sticking to Gen I mechanics. Which has far fewer things to worry about. Or invent your own simpler mechanics. I developed the whole thing with info mostly from bulbapedia. It has detailed explanations of the mechanics.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS