Skip to main content
gamedev.net
🔒 Locked

Making Asteroids in Java

Started by Doomhauer 3 replies 5.3k views
Original Post
Doomhauer
Doomhauer
Hi folks, My end of year unit for college includes making an Asteroids clone in Java. I think I know how all my classes are going to work out but am having a few problems with the basics. Mainly I cant seem to get any sort of fluid movement to my key events, the ship object will move in response but very awkwardly. Any tips regarding the building of asteroids would be greatly appreciated! Thanks -D
PCosmin89
PCosmin89
Instead of using your keys to add movement to your ship, try to use a system closer to how real life works. Instead of incrementing your position by x at each keystroke, use a system based on Velocity and Acceleration.

This should give you all the information you need on connecting those elements and making a fluid movement.
BigRob
BigRob
I don't know how you build the main-loop of your game. But Kev over at cokeandcode.com has a nice tutorial for Java2D games: http://www.cokeandcode.com/info/tut2d.html

Hope it helps
BCullis
BCullis
Instead of tying the movement directly to the inputs (I'm assuming your keyboard), you may want to use the keys to instead enable/disable some sort of "moving" boolean, then have your game loop move the player depending on the state of that boolean. This helped get rid of key-press lag in some java games I worked on recently, where the OS will confirm the first keypress but won't confirm a constant press right away, resulting in a stutter every time you hold down a new direction.
Hazard Pay :: FPS/RTS in SharpDX (gathering dust, retained for... historical purposes)
DeviantArt :: Because right-brain needs love too (also pretty neglected these days)
Doomhauer
Doomhauer
Brilliant, all very helpful thanks peeps! :)

-D

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.