Hey, I know of a place called google, and I've looked over a few, but I want to know what is a good start walk-through tutorial for a first java game you think? I've seen ones for pong, ect.
But I also like to see more compelx games that are 2D of course, but you know. I do not want it to teach me applet, I want it to teach me how to program a simple game as a stand-alone application.
thank you, mightly java gods
Adam Nace
Ranch Hand
Joined: Jul 17, 2006
Posts: 117
posted
0
There is very little difference between the way you would write an applet and a stand-alone application. The main differences are: Applets are typically embedded in a web browser, and the Applet class has been outfitted with some methods that allow the Applet to interact with that web browser in a minimal way. Furthermore, you do not ahve to perform the process of creating and showing the Applet, because the borwser does this for you. It's pretty trivial anyway.
Secondly, Applets have a methods that are called by specific browser events, which are typically part of the life cycle of an Applet. Since you are not using an applet, you can basically ignore these, all except one. Should you choose to use the init() method for any reason, you will need to manually invoke the init() method just after construction. Typically, rather than using the init() method (which isn't predefined for stand-alone applications anyway), you make a method called createAndShowGUI() which basically does the same sorts of things.
The sun microsystems tutorials for Applets and Swing are good places to start to understand the differences between applets and stand-alone applications (note: the Swing tutorial essentially teaches stand-alone desktop applications).
If you're planning on doing animation, you will also want to look into the following:
I've been searching for the same, but there's not that many good, all-in-one sites. The book I have is Java 2 Game Programming by Thomas Petchel. It is pretty good, but very basic. You'll only read about 5 or 6 chapters and the rest just teaches the basics of Java. The good thing, is it has a lot of simple, but really good examples.
I never used the Applet class, I always extend the JApplet class. I'm used to working with JFrames' where I call the getContentPane() method, then add in my JPanels, or whatever.
I consider extending JApplet similar to extending JFrame, but I don't think you can set a JApplets size(done in html code), and you dont need to bother with setVisible(true), or setLocation() or setDefaultCloseOperation, cause it wouldnt make sense in an applet.
I guess you would extend Applet, if you just wanted to paint directly to screen, not sure if you can JPanels when extending Applet
Layne Lund
Ranch Hand
Joined: Dec 06, 2001
Posts: 3061
posted
0
Originally posted by colin shuker: I guess you would extend Applet, if you just wanted to paint directly to screen, not sure if you can JPanels when extending Applet
Applet is part of the old AWT API. You would use Panel instead of JPanel if you wanted to go this route. However, I think using Swing (all the GUI classes that start with J) is the prefered method in more recent versions of Java.