File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Game Development and the fly likes Movement problems Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Game Development
Bookmark "Movement problems" Watch "Movement problems" New topic
Author

Movement problems

Kris Chad
Greenhorn

Joined: Apr 01, 2012
Posts: 1
Hello.Currently I'm making projectiles for a mini-game of mine,but I'm having movement problems with my code.I was originally going to use the same strategy I used to create and move the player,but that would require making the projectile upon login,not on command.Right now,the code will make a bullet in the starting area,wait a couple seconds,then make one in the ending area.How would I fix this so that it actually looks like its moving across the screen?Here is my code.



By the way,I know why it's not working,I just don't know how to fix it.
Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
    
    1
Have you looked into the "game loop" pattern. Basically, a loop repeatedly calls two commands, one to calculate current positions, the second to do the repaint.



As you get further into it, there are issues as to how to make the timing even for each loop. Some people take a timing reading before and after the two commands, and subtract the elapsed time from a desired total loop time to calculate a sleep amount. Another approach is to use a Timer (util.Timer is my preference) and give it a TimerTask with the two commands, and set it to repeat at the desired interval.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Movement problems