import java.awt.Color; import java.awt.Graphics; public class CombinationBlock extends Block{ //Overview: A CombinationBlock is a changable color block. // When the hp changes its value, the block changes its look. public CombinationBlock(){ super(true,2,Color.yellow); } public void drawImage(Graphics g, int x, int y, int w, int h){ g.setColor(Color.black); g.fillRect(x,y,w-1,h-1); g.setColor(getColor()); g.fillRect(x+1,y+1,w/2-2,h/2-2); g.fillRect(x+w/2,y+h/2,w/2-2,h/2-2); switch(hp){ case 0: g.setColor(Color.blue); break; case 1: g.setColor(Color.black); g.fillRect(x,y,w-1,h-1); g.setColor(getColor()); g.fillRect(x+1,y+1,w/3-3,h/3-3); g.fillRect(x+w/3,y+h/3,w/3-3,h/3-3); g.fillRect(x+w/3+w/3,y+h/3+h/3,w/3-3,h/3-3); break; case 2: g.setColor(getColor()); g.fillRect(x+1,y+1,w/2-2,h/2-2); g.fillRect(x+w/2,y+h/2,w/2-2,h/2-2); break; } } }