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.
posted 3 years ago
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.