text: *
  A friendly place for programming greenhorns!
  Big Moose Saloon
  Search
  |
  Java FAQ
  |
  Recent Topics
  |
  Flagged Topics
  |
  Hot Topics
  |
  Zero Replies
  Register / Login
  JavaRanch
  »
  Java Forums
  »
  Java
  »
  Beginning Java
  Author
  I want to focus on
  Alwell Mulsid
  Greenhorn
  Joined: Sep 28, 2001
  Posts: 1
  posted
  Sep 30, 2001 20:21:00
  0
  I'm very very new on Java and of course I consider myself as a newbie. I really want to focus on Java game development. Any suggestions where to concentrate on
  java
  topics?
  Cindy Glass
  "The Hood"
  Sheriff
  Joined: Sep 29, 2000
  Posts: 8521
  posted
  Oct 02, 2001 12:17:00
  0
  Most games are heavy into GUIs so knowing the AWT and SWING very well would be to your advantage.
  "JavaRanch, where the deer and the Certified play" - David O'Meara
  Tim Blommerde
  Greenhorn
  Joined: Sep 24, 2001
  Posts: 21
  posted
  Oct 02, 2001 15:18:00
  0
  Of course getting yourself familiar with the Java language is the first thing you should do. After that you might look into the java.awt.image.renderable package and the java.io package. Of course it all depends on what kind of game you want to create.
  A slightly outdated site called '
  The Java Game Programming Tutorial
  ' might set you on the right track. Another tutorial, found at the
  Sun site
  , learns you how to create a Bingo game. I know it does not sound spectacular, but you said you're rather new to Java, so you have to start at the bottem.
  Good luck,
  Tim
  Gerry Giese
  Ranch Hand
  Joined: Aug 02, 2001
  Posts: 247
  posted
  Oct 02, 2001 15:42:00
  0
  I found the following to be exceptional:
  - downloads on this page, online stuff is under 'Lectures'
  The following either have promise or are not directly related to java but still useful for a game developer:
  This is a topic I'm looking into myself. Anyone else have some good reference sites, tutorials, or game/code samples to share?
  CJP (Certifiable Java Programmer), AMSE (Anti-Microsoft Software Engineer)
  Author of
  Posts in the Saloon
  Nathan Pruett
  Bartender
  Joined: Oct 18, 2000
  Posts: 4121
  I like...
  posted
  Oct 03, 2001 06:04:00
  0
  Thanks for all the great links, Gerry!
  Here are a few more...
  - Dungeon Master Java
  - New, big discussion site!
  I, too, am interested in Java game programming... I've programmed the obligitory Tetris game
  , and it's on
  my website
  ... I've worked on a few other games, but haven't had the time to finish them due to time spent doing actual work...
  As far as what you should look into... learn basic Java pretty well first... then it depends on what you're going to do with your game... some basic GUI will be needed, AWT for
  applets
  , Swing for applications. Maybe some IO if you're going to be doing file access... Image processing and threads are always important to know... there are a few books out there on Java game programming, but almost all of them are quite a bit out of date, and most aren't that good...
  -Nate
  Write once, run anywhere, because there's nowhere to hide! - /. A.C.
  Gerry Giese
  Ranch Hand
  Joined: Aug 02, 2001
  Posts: 247
  posted
  Oct 03, 2001 10:47:00
  0
  Nathan - good info! I think there are lots of people with real lives who secretly want to be 'Game Developers'. Any chance we could add a 'Fun and Games' forum to the Saloon? Can't hurt to ask... The javagaming.org link was *supposed* to be in that blank line in the latter part of my first message - don't know why it didn't make it.
  There are three books coming out this month and early next of note to aspiring Java Game Developers:
  The Tao of Java 2 Game Programming
  ,
  Java Graphics Programming Library (Advances in Computer Graphics and Game Development)
  , and
  AI Game Programming Wisdom
  . The last one is not Java-specific, and is like a 'Game Programming Gems' just for AI. That one and the middle one won't be out until March/April respectively, but the first one is due out any day now and looks to be a must-buy. I'm really going to tear into that one when it arrives!
  One of the hardest things to research so far has been good examples of sprites and double-buffering in a game-related context - ie, how to do basic animation. I've cobbled together someting that works, but I know that it's not ideal. FYI, I'm just goofing with trying to make a nethack clone. It's barely started, and I'm embarassed to even look at it myself, but you gotta start somewhere!
  Thanks again!
  Nathan Pruett
  Bartender
  Joined: Oct 18, 2000
  Posts: 4121
  I like...
  posted
  Oct 04, 2001 07:36:00
  0
  Gerry,
  New forums are created on JavaRanch if someone can display a large amount of postings on a certain topic, and bring up the idea in the JavaRanch forum ( the one where postings about this site go... ) I'd really enjoy one focused on games, too... though most of the questions on games could probably be handled in the Swing/AWT/JFC , IO, or the Java In General forums depending on what the questions were about...
  Thanks for the links to the books... now I have more things to put on my Christmas list...
  Nethack has been one of my all time favourite games... and I think it's about time for a Java clone of it!
  For a short post describing double-buffering on here
  look at this
  ... there's more to it though, if you want to make animations, you have to have threads and more stuff...
  Here's some code I had laying around that has all the parts you'll need to do animation... Since this is just some code I've thrown together over a few minutes a few weeks ago, the standard disclaimers apply...
  ( Though I did check to make sure it ran in appletviewer before I posted it... )
  import java.awt.*; import java.awt.event.*; import java.applet.*; public class ShowGraphics extends Applet implements Runnable, MouseMotionListener, MouseListener { Image i[], buffer, background; Graphics bg; Thread animationThread; boolean threadOn, paused; int paddle1X, paddle1Y; int imageX[], imageY[], imageZ[], deltaX[], deltaY[], deltaZ[]; public void init() { System.out.println( "init() entered." ); i = new Image[ 3 ]; imageX = new int[ i.length ]; imageY = new int[ i.length ]; imageZ = new int[ i.length ]; deltaX = new int[ i.length ]; deltaY = new int[ i.length ]; deltaZ = new int[ i.length ]; System.out.println( "Arrays initialized." ); // Replace image1.gif, image2.gif, image3.gif, and background.jpg // with any images you have lying around on your harddrive... i[ 0 ] = getImage( getCodeBase(), "image1.gif" ); i[ 1 ] = getImage( getCodeBase(), "image2.gif" ); i[ 2 ] = getImage( getCodeBase(), "image3.gif" ); background = getImage( getCodeBase(), "background.jpg" ); MediaTracker mt = new MediaTracker( this ); for( int n = 0; n < i.length; n++ ) { mt.addImage( i[ n ], n ); } mt.addImage( background, i.length ); try { for( int n = 0; n < i.length; n++ ) { mt.waitForID( n, 100 ); System.out.println( "Loaded image " + n ); } } catch( InterruptedException x ) { System.err.println( "Achtung! Der mediertracken ist verboten!" ); } System.out.println( "Graphics loaded." ); for( int n = 0; n < i.length; n++ ) { imageX[ n ] = ( ( int )( Math.random() * ( ( n + 1 ) * 2 ) ) ) + n; imageY[ n ] = ( ( int )( Math.random() * ( ( n + 1 ) * 2 ) ) ) + n; imageZ[ n ] = n; deltaX[ n ] = ( int )( ( n + 1 ) * 1.5 ); deltaY[ n ] = ( int )( ( n + 1 ) * 1.5 ); deltaZ[ n ] = ( int )( ( n + 1 ) * 1.5 ); //deltaX[ n ] = ( ( int )( Math.random() * ( ( n + 1 ) * 2 ) ) ) + n; //deltaY[ n ] = ( ( int )( Math.random() * ( ( n + 1 ) * 2 ) ) ) + n; } System.out.println( "Graphics attributes set." ); paused = true; addMouseListener( this ); addMouseMotionListener( this ); System.out.println( "init() exited" ); } public void start() { animationThread = new Thread( this ); threadOn = true; animationThread.start(); } public void run() { long time = System.currentTimeMillis(); long delay = 500; while( threadOn ) { time += delay; try { Thread.sleep( Math.max( 0, time - System.currentTimeMillis() ) ); } catch( InterruptedException x ) { System.err.println( "Buggah! Sumthin's messin' wit' me thread!" ); } repaint(); } } public void stop() { threadOn = false; } public void paint( Graphics g ) { if( buffer == null ) { buffer = createImage( getSize().width, getSize().height ); bg = buffer.getGraphics(); } for( int x = 0; x < getSize().width; x += background.getWidth( this ) ) { for( int y = 0; y < getSize().height; y += background.getHeight( this ) ) { bg.drawImage( background, x, y, this ); } } for( int z = -30; z< 30; z++ ) { for( int n = 0; n < i.length; n++ ) { if( imageZ[ n ] == z ) { bg.drawImage( i[ n ], imageX[ n ], imageY[ n ], i[ n ].getWidth( this ) + imageZ[ n ], i[ n ].getHeight( this ) + imageZ[ n ], this ); System.out.println( "Image " + n + " is at " + imageZ[ n ] + " at time " + z ); } } } bg.setColor( Color.red ); bg.drawRect( paddle1X - 40, paddle1Y - 40, 80, 80 ); if( paused ) { bg.setColor( Color.red ); bg.drawString( "PAUSED", ( getWidth() / 2 ) - 10, getHeight() / 2 ); } g.drawImage( buffer, 0, 0, this ); } public void update( Graphics g ) { if( !paused ) { for( int n = 0; n < i.length; n++ ) { imageX[ n ] += deltaX[ n ]; imageY[ n ] += deltaY[ n ]; imageZ[ n ] += deltaZ[ n ]; if( imageZ[ n ] > 29 | | imageZ[ n ] < -29 ) { deltaZ[ n ] = -deltaZ[ n ]; imageZ[ n ] += deltaZ[ n ] * 2; } if( imageX[ n ] > ( getSize().width - ( i[ n ].getWidth( this ) + imageZ[ n ] ) ) | | imageX[ n ] < 0 ) { deltaX[ n ] = -deltaX[ n ]; imageX[ n ] += deltaX[ n ] * 2; } if( imageY[ n ] > ( getSize().height - ( i[ n ].getHeight( this ) + imageZ[ n ] ) ) | | imageY[ n ] < 0 ) { deltaY[ n ] = -deltaY[ n ]; imageY[ n ] += deltaY[ n ] * 2; } } } paint( g ); } public void mouseClicked( MouseEvent e ) { if( paused ) { paused = false; } } public void mouseEntered( MouseEvent e ) { } public void mouseExited( MouseEvent e ) { paused = true; } public void mousePressed( MouseEvent e ) { } public void mouseReleased( MouseEvent e ) { } public void mouseDragged( MouseEvent e ) { } public void mouseMoved( MouseEvent e ) { if( !paused ) { paddle1X = e.getX(); paddle1Y = e.getY(); } } }
  Since it's an
  applet
  , here's the HTML I have to launch it... ( with spaces inserted, so it won't execute in the browser...
  )
  < html > < head >< / head >< body > < applet code=ShowGraphics.class width=400 height=400 > < / applet > < / body > < / html >
  -Nate
  Gerry Giese
  Ranch Hand
  Joined: Aug 02, 2001
  Posts: 247
  posted
  Oct 11, 2001 10:49:00
  0
  Nathan,
  Thanks for the applet! Looks pretty good. I was surprised to see it recognized the transparency in a .GIF! Hopefully I can dissect it and figure it all out pretty soon. The closer it gets to the holidays the less time I seem to have fun stuff like this. :-( Thanks again, and let us know if you find anything new/interesting on the game programming front!
  Gerry
  I agree. Here's the link:
  subject: I want to focus on
  Similar Threads
  get a jframe to "stay on top" in Applet
  java command line
  Passed SCJP what next
  JTable Cell Focus
  focusing on an input element with jquery
  All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
  JForum
  |
  Paul Wheaton