public void paintComponent(Graphics g) {
	    super.paintComponent(g);
            Toolkit.getDefaultToolkit().sync();
	    Graphics2D g2d = (Graphics2D) g;
            
	    if ( game.isGameOver() ) {
		g2d.drawString("GAME OVER! points: "+game.getPoints(),(game.getWidth()/2-50),(game.getHeight()/2-30));
                parent.setVisible(false);
	    }
	    else {
		for (Asteroid a : game.getAsteroids()) {
		    int x = a.getX(); int y = a.getY();
		    int size = a.getSize();
		    Rectangle2D.Double first = new Rectangle2D.Double(x,y,size,size);
		    boolean drawSecond = false;
		    if (x < 0) {
			x = size - x;
			drawSecond = true;
		    }
		    else if (x+size >= game.getWidth()) {
			x = x - game.getWidth();
			drawSecond = true;
		    }
		    if (y < 0) {
			y = size - y;
			drawSecond = true;
		    }
		    else if (y+size >= game.getHeight()) {
			y = y - game.getHeight();
			drawSecond = true;
		    }
		    g2d.draw(first);
		    if (drawSecond) {
			Rectangle2D.Double second = new Rectangle2D.Double(x,y,size,size);
			g2d.draw(second);
		    }
		}
		Ship s = game.getShip();
		Polygon shipshape = getShipShape(s);
		g2d.fill(shipshape);
		if ( game.shipIsImmune() ) {
		    g2d.draw(new Ellipse2D.Double(s.getX()-18,s.getY()-18,37,37));
		}
		for (Bullet b : game.getBullets()) {
		    g2d.draw(new Rectangle2D.Double(b.getX(),b.getY(),1,1));
		}
		g2d.drawString("level: " + game.getLevel() + ", points: " + game.getPoints() + ", lives left: " + game.getLivesLeft(),10,20);
                //drawAllSensors(g2d,s);
                drawActivatedSensors(g2d,s);
            }
        }