bad effect when draw object moving fast
Hi, i have a shooter game where a gun can shoot a bullet.
This bullet run fast so i move it whit X+=dx (dx is distance in pixel)
When the bullet run too fast i ahve a bad effect, ot smootly.
How i can resolve?
Now my code is frame based i think, i use this:
delay =30;
Timer timer=new Timer(delay,new ActionListener(){
publicvoid actionPerformed(ActionEvent e){
processBulletPosition();
timer.setDelay(delay-delayed);
}
});
publicvoid processBulletPosition(){
bullet.process(new 2DVector(10,0));//2DVector is simple object contain dx and dy increment.
repaint();
}
//im use JPanel to paint, not canvas
protectedvoid paintComponent(Graphics g){
super.paintComponent(g);
Graphics2D g2=(Graphics2D)g;
nanoTime=System.nanoTime();
bullet.draw(g2);
delayed=(System.nanoTime()-nanoTime)*1E-6;//make delayed in millisec
}
bullet proces is like this:
publicvoid process(2DVector vect){
int dx=vect.dx;
int dy=vect.dy;
x+=dx;
y+=dy;
}
Animation is very smooty, but when a bullet or an other object run too fast and dx increment is too many pixel the effect is very bad, and not smooty.
I think i have same fps becouse i decrement delay time of a delayed time...
Can you help me?
Message was edited by:
blow

