This site requires JavaScript, please enable it in your browser!
Greenfoot back
student101
student101 wrote ...

2013/1/14

Pokemon style turn based battle system

student101 student101

2013/1/14

#
Hi, I was wondering how I would create a turn-based battle system that's similar to Pokemon in Greenfoot? Right now I have the changing to a battle world when an enemy is encountered but I don't know how to code the actual fighting. I'm talking about attacks, health bars etc.
davmac davmac

2013/1/14

#
You can have the world keep track of which actor's "turn" it is, and have the world's act method call a method on that actor. You'd also have a method in the world so that actors could signal that they have finished their turn. The act method of actors would not be used (or used only for simple repeating animation).
student101 student101

2013/1/14

#
thanks for replying. I think I understand what you're trying to say but I'm a beginner in Greenfoot and I'm lost half the time. Could you give me examples in code please, if possible?
davmac davmac

2013/1/14

#
For starters, create an actor class called eg "TurnBasedActor" and have your other actors extend it. Have a method called 'doTurn()' in it (which does nothing). Your other actors can re-implement this method to do whatever they want. Then, have a variable called 'currentActor' of type 'TurnBasedActor' in your world. In the act method of your world, call currentActor.doTurn(). If you need more help, please ask specific questions rather than just a general 'write all the code for me'.
You need to login to post a reply.