Now that I have the game fundamentals working the way I want to; the next step was to add in some other entities into the game for the player to interact with. Today I added in one new entity; the Dragon. At the moment it’s just a simple enemy that flies in the opposite direction to the player. While implementing the Dragon class I found a cool little method in Slick that I previously didn’t know was there; since the Dragons are flying in the opposite direction, they need to face the other way, instead of having two copies of every image, if you invoke the “getFlippedCopy” method on your image, lo and behold the image is flipped!
Once I had the Dragon Entity implemented and moving, I decided that I needed to implement Ai at this stage, by giving each entity its own Ai class, I can uniquely customise each enemy to have a specific behaviour, the code is then kept nice and tidy within each entity Ai class, however if there is a method or a specific behaviour that I want all or some of my entities to have then I have to duplicate the code. So to avoid this I have implemented a generic Ai class and made it abstract, then each of the individual Ai classes inherit from this. I can then put methods that I want more than one entity to use in this generic Ai class.
After this I was easily able to implement collision detection into the Ai’s, for now if a player collides with another Dragon that dragon is removed from the world and the play loses some health. This will get worked on more at a later stage of development, for now I just need to know that the game is working as intended, once I have all the game like that I can go back and make it awesome.