rpg game question

Started by
5 comments, last by FLeBlanc 12 years, 1 month ago
Im making a pokemon rpg game and i need an idea on how to create target pokemon. i have the pokemon class made, but i dont have an idea on how to create the enemy pokemon class. should i use inheiritance?
Advertisement
Inheritance is overkill when you can have a team property as an integer. You can not give out your game if you use the pokemon trademark.
Why does an enemy pokemon have to be modelled any differently to a "regular" pokemon?

You probably don't want inheritance. It is mostly a means to achieve convenient runtime polymorphism. If you don't have a polymorphic interface in mind, it's not what's needed.
i don't plan on giving it out, its just something that makes learning game programming fun and interesting.

so i can just do something a long the lines of...

Pokemon *pika = new pikachu;

so i can just do something a long the lines of...

Pokemon *pika = new pikachu;


Better:

pikachu pika;
I never planned to give out my physical simulation application but after 4 years in development people liked it and it got nominated for best execution in the Swedish Game Awards.
You might consider using object composition rather than "traditional" deep hierarchy polymorphism. That is, avoid building those ugly inheritance trees where such-and-such is derived from whatsis, which is derived from whozit and wotsit. Nothing but god-awful messes to be had there.

Object composition allows you to express an object based on the properties it possesses, without tying those properties to any particular class in the inheritance tree. Objects in this sense, then, boil down to being basically a bucket full of properties. You can add exactly the properties you need to the object, without worrying about which base class or classes would be appropriate to derive from.

This topic is closed to new replies.

Advertisement