コード例 #1
0
 private void paintItems(Graphics2D g2d) {
   for (Item item : c.getAllStuff()) {
     if (item != null) {
       if (item.flicker()) {
         g2d.drawImage(
             item.getImage(), item.getPosition().getX(), item.getPosition().getY(), this);
       }
     }
   }
 }
コード例 #2
0
 private void paintLifes(Graphics2D g2d) {
   int lifes = c.getLifes();
   for (int i = 0; i < lifes; i++) {
     ImageIcon imageIcon =
         new ImageIcon(
             ItemFactory.class.getResource(Config.getImagePath() + Level.getLevel().getLife()));
     Life life =
         ItemFactory.createLife(
             Config.getBoardDimension().getLength() - (2 + i) * imageIcon.getIconWidth(),
             0,
             imageIcon);
     g2d.drawImage(life.getImage(), life.getPosition().getX(), life.getPosition().getY(), this);
   }
 }
コード例 #3
0
 private void paintBackground(Graphics2D g2d) {
   int x = c.getBackground().getPosition().getX();
   int y = c.getBackground().getPosition().getY();
   g2d.drawImage(
       c.getBackground().getImage(),
       x - c.getBackground().getDimension().getLength(),
       y,
       Config.getBoardDimension().getLength(),
       Config.getBoardDimension().getHeight(),
       this);
   g2d.drawImage(
       c.getBackground().getImage(),
       x,
       y,
       Config.getBoardDimension().getLength(),
       Config.getBoardDimension().getHeight(),
       this);
   g2d.drawImage(
       c.getBackground().getImage(),
       x + c.getBackground().getDimension().getLength(),
       y,
       Config.getBoardDimension().getLength(),
       Config.getBoardDimension().getHeight(),
       this);
   if (Config.getForeground().compareTo("") == 0) {
     ImageIcon foreground =
         new ImageIcon(
             this.getClass().getResource(Config.getImagePath() + Config.getForeground()));
     g2d.drawImage(
         foreground.getImage(),
         0,
         Config.getBoardDimension().getHeight() - foreground.getIconHeight(),
         Config.getBoardDimension().getLength(),
         foreground.getIconHeight(),
         this);
   }
 }
コード例 #4
0
 private void paintScore(Graphics2D g2d) {
   Font font = new Font("sans", Font.PLAIN, 36);
   g2d.setColor(Color.green);
   g2d.setFont(font);
   g2d.drawString((int) c.getPoints() + "", 10, 50);
 }