my dog learned polymorphism
The moose likes Game Development and the fly likes Beginning Games Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "Beginning Games" Watch "Beginning Games" New topic
Author

Beginning Games

Len Padson
Ranch Hand

Joined: Nov 21, 2011
Posts: 40
So, how would i make a basic game like this: a 100x100 pixel square with a black dot in the center, that can be moved left/right/up/down with the arrow keys? I think I know one way to do it but I would like to get your guys's feedback! Thanks!
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3892
    
  18

Welcome to CodeRanch!

Please take a look at your private messages for an important administrative issue.

Why don't you tell us about the one way that you already know?


The mind is a strange and wonderful thing. I'm not sure that it will ever be able to figure itself out, everything else, maybe. From the atom to the universe, everything, except itself.
Len Padson
Ranch Hand

Joined: Nov 21, 2011
Posts: 40
Well I know a very limited amount about making a class that extends JComponent, and then inserting a paint method and painting individual shapes to the JComponent, and then adding the JComponent to a JFrame, and just adding keylisteners to get user input, but I would really like to see a simple example, because I just feel like my way is more tedious than it should be. And I think the other issue is all cleared up now, thanks
Stephan van Hulst
Bartender

Joined: Sep 20, 2010
Posts: 3892
    
  18

Tedious as it may seem, that's the way it's done. There may be some libraries out there that make this process more smooth, but I can't think of any from the top of my head.

Here's an outline that may give you some ideas. Please keep in mind that I haven't tested this code, and I haven't added performance tricks (like selective repainting and making the panel opaque).

Len Padson
Ranch Hand

Joined: Nov 21, 2011
Posts: 40
Wow. Thank you so much for taking the time to write all this code. I will go try it and let you know how it works.
Jj Hill
Ranch Hand

Joined: Jul 25, 2011
Posts: 41

Stephan's answer is right.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Beginning Games
 
jQuery in Action, 3rd edition