There was such nice game as Snake.
We made applet and you can play online now.
Game roles and the applet enter are placed at
Get Java project, C++ project or Window exe version (all free) at
Article about how it woks are published on the site too.
It includes exercises for students.