Java Reference
In-Depth Information
oldX = e . getX() ;
repaint () ;
}
} );
}
private Color getRandomColor ()
{
Color color = new Color (( int )
(Math . random ( )
256) , ( int )
(Math .
random()
256) , ( int )
(Math . random ( )
256)) ;
if (getBackground() . equals ( color ))
{
return Color .RED;
return color ;
}
private void createBricks ()
{
for ( int row = 0; row
{
for ( int col = 0; col < NUM BRICK COLUMNS ; c o l ++) {
bricks .add( new Brick (row , col , getRandomColor () ) ) ;
<
NUM BRICK ROWS ;
row++)
}
}
}
public void start() {
gameStarted = true ;
if (timer != null )
{
timer . stop() ;
if (!player . isAlive()) {
player = new Player () ;
ball = new Ball(BallColor .Red, this );
createBricks () ;
timer = new javax . swing .Timer(BallSpeed .NORMAL. speed() , new
TimeListener () ) ;
timer. start() ;
repaint () ;
}
public void pause ()
{
if (timer == null )
{
return ;
timer . stop() ;
}
public void changeBallColor(BallColor color )
{
ball . changeColor( color ) ;
repaint () ;
}
public void showMessage( String s , Graphics2D g2) {
Font myFont = new Font( "SansSerif" , Font .BOLD + Font . ITALIC, 40) ;
g2. setFont(myFont) ;
g2 . setColor (Color .RED) ;
 
Search WWH ::




Custom Search