@Override
    public void paint(Graphics g) {
     
if(enter){
    enter=false;
    levelNo++;
    if(levelNo<levels.length&&levels[levelNo]!=null){
    this.setLevel(levels[levelNo].getLevel());
    }
}
        //  this.frame.getContentPane().setBackground(Color.yellow);
        super.paint(g);
if(type==0){
        if ((level[p.getY()][p.getX()] == 'B' || level[p.getY()][p.getX()] == 'V')&&(p.score>=p.challange )) {
dialog.setSize(600,600);
            dialog.setVisible(true);
            frame.setVisible(false);
         
        }
        }
        int ratio =40;
        if(level.length>15){
            ratio = 30;
        }
        if(level.length>30){
            ratio=15;
        }
        if(level.length>40){
            ratio =10;
        }if(level.length>60){
            ratio=6;
        }
        this.getFrame().setSize(this.getLevel().length * ratio + 40, this.getLevel().length * ratio + 40);
        Graphics2D g2D = (Graphics2D) g;

        try {

            g2D.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                    RenderingHints.VALUE_ANTIALIAS_ON);
            AffineTransform aTran = new AffineTransform();
            aTran.translate(1.0f, 1.0f);
            g2D.transform(aTran);

            for (int i = 0; i < level.length; i++) {
                for (int j = 0; j < level.length; j++) {
                    char element=level[i][j];
                      if(element == 'n') {
                            g2D.drawImage(n, (int) ratio * j, (int) ratio * i,
                                    (int) ratio, (int) ratio, this);
                        } else if (element== 's') {
                            g2D.drawImage(s, (int) ratio * j, (int) ratio * i,
                                    (int) ratio, (int) ratio, this);

                        }else if (element== 'e') {
                            g2D.drawImage(e, (int) ratio * j, (int) ratio * i,
                                    (int) ratio, (int) ratio, this);
                        }else if (element == 'w') {
                            g2D.drawImage(w, (int) ratio * j, (int) ratio* i,
                                    (int) ratio, (int) ratio, this);
                        } else if (element == 'h') {
                            g2D.drawImage(nw, (int) ratio*j, (int) ratio*i,
                                    (int) ratio, (int) ratio, this);
                        } else if (element == 'j') {
                            g2D.drawImage(sw, (int)  ratio * j, (int) ratio* i,
                                    (int) ratio, (int) ratio, this);
                        } else if (element == 'k') {
                            g2D.drawImage(k, (int) ratio * j, (int) ratio * i,
                                    (int) ratio, (int) ratio, this);
                        } else if (element == 'l') {
                            g2D.drawImage(l, (int) ratio * j, (int) ratio * i,
                                    (int) ratio, (int) ratio, this);
                        }






    else  if (element == 'x') {
                        g2D.drawImage(stone, (int) ratio * j, (int) ratio * i,
                                ratio, ratio, this);
                    } else if (element == 'r') {
                        g2D.drawImage(green, (int) ratio * j, (int) ratio * i,
                                (int) ratio, (int) ratio, this);
                    } else if (element == ' ') {
                        g2D.drawImage(sand, (int) ratio* j, (int) ratio * i,
                                (int) ratio, (int) ratio, this);
                    } else if (element == 'V') {
                        g2D.drawImage(victim, (int) ratio * j, (int) ratio * i,
                                (int) ratio, (int) ratio, this);
                    } else if (element == 'B') {
                        g2D.drawImage(bomb, (int) ratio * j, (int) ratio* i,
                                (int) ratio, (int) ratio, this);
                    } else if (element == 'S') {
                        g2D.drawImage(door, (int) ratio * j, (int) ratio * i,
                                (int) ratio, (int) ratio, this);
                    }else if(element=='q'){
                        g2D.drawImage(light, (int) ratio * j, (int) ratio * i,
                                (int) ratio, (int) ratio, this);
                    }

                   
                     else if(element=='*'){
     g2D.drawImage(coins, (int) ratio* j, (int) ratio * i,
                                (int) ratio, (int) ratio, this);
 }
                    else {

                        g2D.drawImage(stairs, (int) ratio * j, (int) ratio * i,
                                (int) ratio, (int) ratio, this);
                    }
                    

                }
            }
            if (type == 0) {
                g2D.drawImage(p.getPlayer(), p.getX() * ratio, p.getY()* ratio, ratio, ratio, this);
            }
        } catch (Exception e) {
        }

        paintComponents(g);

    }