[java] how to restart a game?

Started by
1 comment, last by Starter 14 years, 4 months ago
Hi everyone. I'm making a little game for an assignment. After the game is done I want to give the player the option to restart my game. How do I go on about this? so far what i came up with is instead of having a button for a restart i choose to do keyboard pressing. So if the player presses r they it would restart the game new. But that is the part I'm stuck at. Actually making the key work. Can anyone give me some suggestion. Please and thank you ^^
Advertisement
java.awt.event.KeyListener
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][LWJGL Tutorials for NeHe][LWJGL Wiki][jMonkey Engine]
Quote:Original post by CaptainJester
java.awt.event.KeyListener


To add to that: it's a interface so you will have to implement it in your game class. Then add it to the Frame or Canvas with the addKeyListener() method. Use the KeyEvent in the implemented method to get the key you want.

This topic is closed to new replies.

Advertisement