So, yeah if you can make something like that then you have several of the basics down. It looks like getting a better grasp on classes is the next thing on your plate.
You already understand some of the things needed for dealing with classes/objects. I can see because you've already written code that uses classes. To create a Ball object you call new Ball(20) on line 172 of the above code.
So just for the practice of getting that understanding a little more complete, create a ball object in your init method (ball = new Ball(20);)
Since we'll want to access that same object in the paint method, declare the variable as a field of the game class (like you have xpos, ypos and others right now) (Ball ball;).
And last but not least, we want to draw that ball in the paint method. Let me say right up front, this is not the ideal way to draw your ball class, but it is a very straightforward way. Add as the last line in the paint method g.drawOval((int)ball.x, (int)ball.y, (int)ball.width, (int)ball.height);
That draw line is calling the drawOval method of the Graphics object and passing it an x, y set of coordinates and a width and height for the oval. And each of those values is being pulled from Ball class (which extends the Ellipse2D class, where each of those values (x, y, width, height) are declared). Because you extend Ellipse2D.Float, those values are all floats and we need them to be ints for the drawOval method. That's why each one is cast to int.
Edited by j-locke, 09 August 2012 - 09:24 PM.
Yes! Rpg text battle simulations are so fun to make. That was my go to when I was learning C++.