public void checkDragging(int c, int d) {

        if(Greenfoot.mousePressed(this) && !isGrabbed){
            // grab the object
            isGrabbed = true;
            wasGrabbed = true;
            
            contGoneX = this.getX();
            contGoneY = this.getY();
    
            // the rest of this block will avoid this object being dragged UNDER other objects
            World world = getWorld();
            MouseInfo mi = Greenfoot.getMouseInfo();
            world.removeObject(this);
            world.addObject(this, mi.getX(), mi.getY());
            
            setImage(new GreenfootImage("cont"+c+d+"drag.png"));
            return;
        }
        // check for actual dragging of the object
        if((Greenfoot.mouseDragged(this)) && isGrabbed){
            // follow the mouse
            MouseInfo mi = Greenfoot.getMouseInfo();
            setLocation(mi.getX(), mi.getY());

            return;
        }
        // check for mouse button release
        if(Greenfoot.mouseDragEnded(this) && isGrabbed && wasGrabbed){
            // release the object
            setImage(new GreenfootImage("cont"+c+d+".png"));
            isGrabbed = false;
            wasGrabbed = true;
            setLocation(contGoneX,contGoneY);
            return;
        }

    }