public void act() 
    {               
        if (Greenfoot.isKeyDown("space"))    //Tests if space key is down
        {
            start = true;    //When start is true the next if will start play
        }

        if (start == true)
        {
            play();    //This runs the code for making the cat move up and down as well as spawning pipes
        } else 
        {
            getWorld().addObject(new Tail(), getX()-43, getY()-movement);    //Spawns tail behind the cat
            counterTail += 1;

            if (counterTail <= 8)
                movement = 0;

            if (counterTail >= 9)    //This makes tail spawn above 5 and then below making it seem likes it moving up and down
                movement = 5;

            if (counterTail == 16)
                counterTail = 1;
        }

        if (getY() < 0)    //Resets the world (so the cat moves to the start) if the cat reaches the top or bottom
        {
            setLocation(getX(), 0);         
        }
        if (getY() >= getWorld().getHeight() - 2)
        {
            die();
        }
    }