How can I use a class such as this one to improve game structure and code reuse ?
Joined: Dec 07, 2012
How do I use a class such as this one, for each entity of a game?
I have the standard game loop and Player class and so forth but the overal game infrastructure is of poor quality. Can you please help me understand how to do so. THankyou
You don't write a program by saying "How do I use this technology to make my program better/work". That's like saying "how do I use a socket wrench to improve my car?"
A socket wrench MAY help you improve your car...but if your biggest problem with your car is that the tires are flat, the socket wrench is NOT going to help you.
Never ascribe to malice that which can be adequately explained by stupidity.
Joined: Sep 01, 2010
Here's what I would do:
I would make an "Animatable" interface, and have two methods, update() and draw(Graphics2D g2). Make each of your basic objects implement this interface. Then your game loop can have a single array of ALL your animatable objects, and call their update methods and then their draw methods as part of the game loop cycle.