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 44 45 46 47 48 49 50
|
//Methode 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)
{
if (ligne>=Pwidth)
{
//normalent elle s'occupe de deplacer l'aafichage vers de haut avec une ligne
dbg.copyArea(0,0,Pwidth,Pheight,0,-1);
ligne=Pheight-1;
}
for(int i=0;i<Pwidth;i++)
{
if(cellule[i]==1)
{
dbg.setColor(Color.black);
dbg.fillRect(i,ligne, 1,1);
}
}
ligne++;
}
}
//La methode d'affichage sur l'ecran
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){}
} |
Partager