1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
//La méthode de 'Rendering'
public synchronized void gameRender()
{
if (dbImage==null) dbImage=createImage(Pwidth,Pheight);
//recuperatrion du contexte graphique de l'image
dbg=dbImage.getGraphics();
//Changement du background
dbg.setColor(Color.white);
dbg.fillRect(0,0,400,400);
if(dbg!=null)
{
for(int i=0;i<Pwidth;i++)
{
if(cellule[i]==1)
{
dbg.setColor(Color.red);
dbg.fillRect(i,ligne, 1,1);
}
}
ligne++;
if(ligne==Pheight)
ligne--;
}
}
//la méthode pour le dessin sur l'écran
public void paintScreen()
{
Graphics g;
try{
g=this.getGraphics();
if((g!=null) && (dbImage!=null))
g.drawImage(dbImage,0,0,null);
Toolkit.getDefaultToolkit().sync();
g.dispose();
}
catch(Exception e){}
} |