Looks solid! Just throwing this idea out there, but what about making Link flash red whenever he gets hit instead of just decreasing the health? That way the user will know when he has taken damage without actually having to take his eyes off the character. Just a thought.
How did you implement the animations in regards to like...drawing as a whole. I'm about to implement the animation of sprites into a small 2D openGL engine that I'm working on, but I haven't decided on how to do it yet. Are you changing the frames once a sprite has displayed for a specific amount time (maybe delta t), or are you maybe changing it based on how many frames it has been showing? Sorry if that didn't make sense. Just curious!
Are you just using Java's...swing class (?) to draw your graphics? Haven't used Java in a while so I can't remember the libraries used for drawing haha
Ah yes! I could make a indicator that Link taking damage. Well add in the future.
In regards to implement the animation well it is going to take a lot of explaining but I will do my best to make sure you understand a good amount of it so you too can create a similar system. I wrote a Animation class that does a bunch of things:
1) Loads all the images(this would be the string directories of where these images are located in the project folder) that are being feed into the Animation object into a list that can contain images). Obtain the frameInterval from the subclass of this Animation class. Examples: frameInterval = 8.
2) Have some idea of how much far apart or interval of time for the images and also set up frame entries or frame data for each image. I use an array implementation for both of these.
3) Have a method or function that increments the current frame by one. Essentially this is the animation counter.
4) Have a method or function that knows have the animation reached the last frame. Very good idea to have if you want to loop the same animation.
5) The draw method of the Animation class will draw a specific image relative to the sprite position based on the current frame and make sure it is less than or equal to the last frame. If there is no sprite object to draw from, the draw method needs to be overridden in the subclass of the Animation class.
6) Have an implementation that resets the frame when animation has been done,
And that is really much it for the Animation class.
Once I have got the Animation class the way I wanted. Now I can derive or make a subclass or if I have many animations in my games: make many subclasses of the Animation class. An example of such as subclass would be LinkMoveLeftAnimation extends Animation or LinkMoveRightAnimation extends Animation. By doing so, I can use the inherited methods of the Animation class. Every subclass of the Animation can for example increment the current frame, reset the frame (this would reset the current animation frame back to zero, and has a boolean method that checks has the animation reached the last frame. Every subclass also has an idea of a frameInterval and an array containing string directories of the images it should have. LinkMoveLeftAnimation class should move left animations.
I'm actually drawing only one image in that "moment in time" which is what the current frame is all about. Since I am incrementing frame by one which is what my increment frame method is doing, the frame will change therefore my current image will change based on my logic. Eventually the frame will reach a time "threshold" or some time limit in which I need to draw a different image. Also, eventually the current frame will reach the last frame data or frame entry that is set up after my required images are loaded in which I can reset the animation frame back to zero so the animation system will draw back the initial image. Resetting the frame back to zero is pretty much required for 2D character movement animation otherwise you won't draw be able to draw those images after the last frame.
The Animation system itself was tricky to implement and it took a lot more effort and a lot more time and a lot of experimentation with the frameInterval to put these concepts together to create the animation system. The 2D animation system itself went through a lot of improvements before it worked the way I wanted it to work. But the basic level is that animation is just evaluating time pairs and a list of images. Sometimes you need to increase the frameInterval so the animation is not running too fast. Sometimes you need to decrease the frameInterval so the animation is not running too slow. It really depends on how many images are in the list and quite possibly on the look of the animation itself. Be sure to experiment to get the look you want.
I also need to mention your animation execution should be based or dependent on what the state of the character is. The character action state can be attacking, idle, running or walking. The character also has a direction state: left, right, up or down. The animation drawn must be according to the action state and direction state.
And that is pretty much how the logic works to get the correct images to show up.
I am using java awt for drawing graphics. I only used swing to create the JFrame and JPanel. The rest is awt, io, util, imageio and my own codebase for the GUI interface and game logic. Java Standard GUI library did not give me the look I wanted. So I decided to built own logic for buttons and menus and user interface display which gave me more control of how everything looked and operated when the game ran.
Hope these ideas helped! I would say just make a lot of mistakes early when building the system. It will make implementing the system that much easier and you will gain a better understanding of the animation system that much better. The earlier animation system I had problems and I kept improving it and improving it until I iron out all the bugs and better understanding where and why things went wrong initially.
Edited by warnexus, 05 February 2014 - 09:01 PM.