Hi guys,
I am a java noob, so please bear with me. For the past two weeks, I have found it difficult to cycle through images. I am Working on a simple 2D game, where I need the character to “walk”. I have four Classes, Board, Character,Enemy, and Main(runs program).
In the Character Class, this is a part of the method I have:
public void keyPressed(KeyEvent e)
int key = e.getKeyCode():
if(key == KeyEvent.VK_RIGHT){
dx=1
//need to cycle through 6 images here!
}
When I press the Right key, I need to have the character “walk” through 6 images, then, if I press the key again, the same needs to happen.
In the Board Class, I am using a Swing Timer with an update of 5ms.
This is a bit of an aside, but my Board Class is balooning into hundreds of lines of code to support all the “if” statments for enemies, and that’s just the first screen! Is this normal? If I continue at this rate, at the end of the program, I will probably have a Board Class with thousands of lines of code.
Please help out a noob,
Mike