Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


[java] Help with my first game


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 jojor512   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 May 2000 - 12:50 PM

Hello. For my first Java game, I''m making a WORM-like game. I''m using rectangles as the Worm and its food. My problem is that I can''t get the program to respond to keyboard input. this input would be used to control the directionn of the worm. Any suggestions would be great on how I could improve this design and implement keyboard input. Heres what I have so far: import java.awt.*; import java.applet.*; import java.awt.event.*; import java.util.*; public class TrivialApplet extends Applet { int posX = 10; int posY = 20; boolean run = true; public void init() { setBackground( Color.white ); resize(420,420); } public void paint( Graphics g ) { while( run == true ) { g.setColor( Color.white ); g.fillRect(posX,posY, 10,3); posX = posX + 1; g.setColor( Color.black ); g.fillRect(posX,posY, 10,3); try { Thread.sleep(10); } catch ( Exception e ) { break; } }

Sponsor:

#2 Jerry Lynn   Members   -  Reputation: 122

Like
Likes
Like

Posted 20 May 2000 - 08:07 PM

Since this is your first game I would really recommend getting one of the books available on Java game programming. I keep a list of the ones I know about on the FAQ:

http://games.cpbinc.com/faq/

In particular I would recommend ''Java Game Programming for Dummies''. It covers a lot of the basics in a step-by-step format and has pretty good source code included.

#3 Jim_Ross   Members   -  Reputation: 122

Like
Likes
Like

Posted 21 May 2000 - 05:16 AM

http://java.sun.com/docs/books/tutorial/uiswing/events/intro.html
I was gonna tell you myself, but sun just does such good a job of it. I couldn''t find event listeners in the faq.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS