Hi
ok, first of all , excuse me for my english , it’s my third langage so …
what i wanna do is, a scrolling background for my little game ( Raptor 2D), exactly like in this link http://www.planetalia.com/cursos/Java-Invaders/JAVA-INVADERS-25.tutorial
the problem is , that i don’t understaind what they did ! so i’m gonna show u a few parts of my code , and please tell me what i gotta do to obtaint this stupid scrolling background
ok i have a classe scene.java , where i draw the background , in the method paint
super.paintComponent(g);
Graphics2D g2d = (Graphics2D) g;
// Dessiner l'arrière plan
double scalex = (double)this.getWidth() / (double)image.getIconWidth();
double scaley = (double)this.getHeight() / (double)image.getIconHeight();
g2d.scale(scalex,scaley);
g2d.drawImage(image.getImage(),0,0,image.getImageObserver());
g2d.scale(1/scalex,1/scaley);
g2d.setColor(Color.LIGHT_GRAY);
g.setFont( new Font( "", Font.ITALIC, 24 ) );
g2d.drawString( "Vies : "+vie+"%", 10, 30 );
g2d.drawString( "Scores : "+score, 10, 60 );
g2d.drawString( "Missiles : 000 ", 10, 90 );
// Afficher le vecteur
for(int i=0;i<elements.size();i++)
{
elements.get(i).paintComponent(g);
}
}
image is the background of my game ! so help me please to scroll it
thankxxxxxxxx
…