You are being forwarded to the lastest updates ot his page!
Or you can Click Here if it doesn't work or you don't wish to wait.

Need help with a RPG battle engine...

Tru_Messiah
Basically I am working on a simple battle engine... this is just my first attempt at making any type of game and arn't really aiming to make a RPG just trying to see how much knowledge I have and make as good a battle system as I can.

All the enemies I have made using objects... such as bat, troll etc... and they have attributes such as hit points.. experience points left after dead... attack and defense power...

anyway to start my battle engine I pass two objects into it like this...

<B>battleEngine.startBattle (badBat, Ben);</B>

however my method that starts the battle stats like this...

<B>static void startBattle(Bat badBat, Player Ben)</B>

I can only accept a Bat object into it so if I wanted to fight a troll by using

<B>battleEngine.startBattle (Troll, Ben);</B>

if wouldnt work because the engine would be expecting a bat.. how do I go arround making it accept any enemy object... and using that as the person I am fighitng???


Gregg Bolinger
What you should do is create a super class or a class that all your fighters extend. Then, accept that super class as the method argument. Example...

code:

public class Fighter
{
//common methods
}



code:

public class Bat extends Fighter
{
//Bat methods
}



code:

startBattle(Fighter fighter1, Fighter fighter2);



code:

battleEngine.startBattle(bat1, troll1);



Something like that anyway. Should get you going.


jkennedy70
Well, you need to define an Enemy class or interface and have Bat and Troll either extend it or implement it. A further design consideration might be whether Bat and Troll should actually be separate classes at all. Do they have any different attributes or methods (or method implementations) or is it just the values of the attributes that differ? On the other hand you might want to consider having a FlyingEnemy class that extends the generic Enemy class and then have Bat extend FlyingEnemy for example.

Does that give you some ideas?

Jules


Gregg Bolinger
I think this is a good candidate for the Games Forum.


Joseph George
Just a note... this forum uses UBB code,

use array brackets, [], not angle brackets to embolden things.