Good beginners example program?

Hello –

I am looking for some well commented source of a simple java game – something like pong.

I’ve been poking around the java docs, trying to figure out how graphical java programs work… but I’m not having a whole lot of luck.

Any links to good articles / programs would help, thanks!

Here’s a pong applet, follow the link to the source:

http://www.geocities.com/nonnus29/pong/pong.htm

This applet is from a tutorial series here:

http://www.gamedev.net/reference/list.asp?categoryid=20#119

Read the ones by Adam King, as far as I know the source to the other tutes is gone. These tutes should get you started.

Awesome.

Some simple animation is incredibly simple! It didn’t take me long to get a ball bouncing off of the four walls.

One question with this, though:

public boolean keyDown(Event e, int key)
{
message = "value = " + key;

return true;

}

Should sticking this code into my applet be receiving input from my keyboard? It doesn’t seem to be working. (In my paint method I’ve got .drawString(message,40,40);

If that should be working, what is the point of trying to use EventListeners?

edit:: I took a look at the pong source you pointed me to. It seems as if that applet used the method described above for receiving input from the keyboard, and that applet works … I’ll have poke at my applet until it works. (It’s compiling but not displaying anything in response to keyboard input. Strange… maybe it has to do with the gotFocus events?)

Thanks for the help!

Your class needs to implement keylistener. Add the keylistener to your applet “this.addKeyListener(this);”?