It's not a secret anymore!*
The moose likes Game Development and the fly likes Good Java Game Tutorial Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Good Java Game Tutorial" Watch "Good Java Game Tutorial" New topic
Author

Good Java Game Tutorial

Keenan Staffieri
Greenhorn

Joined: Jul 22, 2006
Posts: 23
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
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:

  • Muli-Threading
  • Using Threads with Swing
  • 2D Graphics
  • Sound
  • Timers
  • Animation
  • More on Animation
  • And Even More on Animation
  • Full Screen Mode



  • Hope this helps.

    - Adam
    Larry Eisenstein
    Greenhorn

    Joined: Feb 21, 2006
    Posts: 14
    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.

    Also, check out this link:
    http://www-static.cc.gatech.edu/classes/AY2005/cs1322_fall/HW/hw10.htm

    This is an assignment from a programming class, but its really cool. I'm sure you can google the solution.

    Other than that, I've just been downloading little Java apps from the Net and then stepping thru them on my machine.


    Hope this helps.
    Kino Lobo
    Greenhorn

    Joined: Feb 08, 2006
    Posts: 20
    I want to know what is a good start walk-through tutorial for a first java game you think?


    It's not a walk-through at all, but might help:

    Killer Game Programing


    I'd rather trust a man who works with his hands!
    Gregg Bolinger
    GenRocket Founder
    Ranch Hand

    Joined: Jul 11, 2001
    Posts: 15299
        
        6

    This series of tutorials on creating Java Space Invaders game is the best I've seen.


    GenRocket - Experts at Building Test Data
    Ernest Friedman-Hill
    author and iconoclast
    Marshal

    Joined: Jul 08, 2003
    Posts: 24187
        
      34

    That's a really nice tutorial, Gregg!


    [Jess in Action][AskingGoodQuestions]
    Gregg Bolinger
    GenRocket Founder
    Ranch Hand

    Joined: Jul 11, 2001
    Posts: 15299
        
        6

    Originally posted by Ernest Friedman-Hill:
    That's a really nice tutorial, Gregg!


    Yep, and Kevin is one super nice dude. Be sure to ping him and let him know you liked his stuff.
    Kevin Glass
    Greenhorn

    Joined: Aug 01, 2006
    Posts: 4
    Well thanks for pointing my stuff out. For reference the best place to get hold of that tutorial is:

    http://www.cokeandcode.com/tutorials

    It's up to date and has considerably nicer formatting.

    Kev
    [ August 01, 2006: Message edited by: Kevin Glass ]

    <a href="http://www.cokeandcode.com" target="_blank" rel="nofollow">Blog / Games / Tutorials</a><br /><a href="http://www.tiltilation.com" target="_blank" rel="nofollow">Current Game</a>
    Gregg Bolinger
    GenRocket Founder
    Ranch Hand

    Joined: Jul 11, 2001
    Posts: 15299
        
        6

    Sweet, thanks Kevin.
    colin shuker
    Ranch Hand

    Joined: Apr 11, 2005
    Posts: 744
    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
    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.

    Layne


    Java API Documentation
    The Java Tutorial
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: Good Java Game Tutorial