This site requires JavaScript, please enable it in your browser!
Greenfoot back
LakeOtis
LakeOtis wrote ...

2016/11/30

Isn't starting up (again)

1
2
3
LakeOtis LakeOtis

2016/11/30

#
This time it says that it's taking to long and has to restart. I restarted it and it still wasn't going. I looked at the world class and it needed compiling, but it said that it was already compiled. I deleted one of the semicolons on the end of a statement and then put it back and then compiled it, but it still wouldn't compile. What's going wrong?
danpost danpost

2016/11/30

#
Again, show your initial world class code.
LakeOtis LakeOtis

2016/12/1

#
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/*
 * Write a description of class UpperWorld_Peaceful here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class UpperWorld_Peaceful extends World
{

    /**
     * Constructor for objects of class UpperWorld_Peaceful.
     * 
     */
    public UpperWorld_Peaceful()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(1000, 1000, 2); 
        int coins;
        coins = 0;
        prepare();
    }

    /**
     * Prepare the world for the start of the program.
     * That is: create the initial objects and add them to the world.
     */
    private void prepare()
    {
        You you = new You();
        addObject(you,0,0);
        you.setLocation(0,0);
        you.setLocation(396,382);
        house house = new house();
        addObject(house,360,96);
        you.setLocation(410,277);
        you.setLocation(257,159);
        you.setLocation(342,190);
        You you2 = new You();
        addObject(you2,369,392);
        name name = new name();
        addObject(name,370,334);
    }
}
danpost danpost

2016/12/1

#
Try adding a second asterisk on line 3. If that does not do it. Try going to just before the last character of each line, arrowing right once, pressing delete until the next line is brought up and then pressing enter to move it back down (in case there is some hidden character that is causing issues).
LakeOtis LakeOtis

2016/12/2

#
didn't work
LakeOtis LakeOtis

2016/12/2

#
though the comment part did help
danpost danpost

2016/12/2

#
LakeOtis wrote...
though the comment part did help
Select the entire class code and replace it with the following:
import greenfoot.*;

public class UpperWorld_Peaceful extends World
{
    public UpperWorld_Peaceful()
    {
        super(1000, 1000, 2);
        prepare();
    }
   
    private void prepare()
    {
        addObject(new You(), 342, 190);
        addObject(new You(), 369, 392);
        addObject(new house(), 360, 96);
        addObject(new name(), 370, 334);
    }
}
I am now getting the feeling that this may be a world size issue. Essentially, you are creating a 2000x2000 pixel world, which is awfully large. Maybe you can reduce it to some nominal size -- possibly something between (500, 500, 1) and (600, 600, 1). If it does not have to be square, possibly (900, 600, 1), which is the usual limit I use on world size.
LakeOtis LakeOtis

2016/12/4

#
I did that and replaced the size with the 900 600 1 thing, but it isn't compiling and there's still an infinite loop.
danpost danpost

2016/12/4

#
LakeOtis wrote...
I did that and replaced the size with the 900 600 1 thing, but it isn't compiling and there's still an infinite loop.
Well, it is not in the given class. Post the codes of the 'name', 'house' and 'You' classes.
Nosson1459 Nosson1459

2016/12/4

#
Who said the problem has to be in UpperWorld_Peaceful, could be there is an infinite loop somewhere else (When I tried your original posted world code on my computer it compiled and ran fine, but I had to comment out the prepare() method because I didn't have those actors for the addObjects). I didn't see danpost's post because I was typing mine, so I didn't reload the web page until I finished typing and posted it (where I saw the familiar user image of danpost with a similar or same solution to your problem).
LakeOtis LakeOtis

2016/12/6

#
Name:
import java.awt.Color;
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class name here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class name extends You
{
    /**
     * Act - do whatever the name wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        setImage(new GreenfootImage("YOU", 25, Color.GREEN, Color.BLACK));
    }    
}
House:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class house here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class house extends Actor
{
    /**
     * Act - do whatever the house wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        int x;
        x = 360;
        int y;
        y = 96;
        if (Greenfoot.isKeyDown("d"))
        {
            move(-6);
        }
        if (Greenfoot.isKeyDown("a"))
        {
            move(6);
        }
        if (Greenfoot.isKeyDown("w"))
        {
            setLocation(getX(), getY()+6);
        }
        if (Greenfoot.isKeyDown("s"))
        {
            setLocation(getX(), getY()-6);
        }
    }    
}
You:
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class You here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class You extends characters
{
    /**
     * Act - do whatever the You wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        Actor house;
        house = getOneObjectAtOffset(0, 0, house.class);
        World shop;
        shop = new shop();
        if (house != null)
        {
            Greenfoot.setWorld(forSale);
        }
        
    }    
}
forSale (really nothing but create the world)
import java.awt.Color;
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)

/**
 * Write a description of class forSale here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class forSale extends World
{

    /**
     * Constructor for objects of class forSale.
     * 
     */
    public forSale()
    {    
        // Create a new world with 600x400 cells with a cell size of 1x1 pixels.
        super(1000, 1000, 2);
        prepare();
    }

    /**
     * Prepare the world for the start of the program.
     * That is: create the initial objects and add them to the world.
     */
    private void prepare()
    {

       
    }
}
danpost danpost

2016/12/6

#
I do not think the name class should extend the You class (it should extend Actor). Also, you did not include your characters class code here.
Nosson1459 Nosson1459

2016/12/7

#
I don't think I see any problems in the classes shown.
LakeOtis LakeOtis

2016/12/7

#
danpost wrote...
I do not think the name class should extend the You class (it should extend Actor). Also, you did not include your characters class code here.
I thought I did, but here
import greenfoot.*;  // (World, Actor, GreenfootImage, Greenfoot and MouseInfo)
 
/**
 * Write a description of class You here.
 * 
 * @author (your name) 
 * @version (a version number or a date)
 */
public class You extends characters
{
    /**
     * Act - do whatever the You wants to do. This method is called whenever
     * the 'Act' or 'Run' button gets pressed in the environment.
     */
    public void act() 
    {
        Actor house;
        house = getOneObjectAtOffset(0, 0, house.class);
        World shop;
        shop = new shop();
        if (house != null)
        {
            Greenfoot.setWorld(forSale);
        }
         
    }    
}
LakeOtis LakeOtis

2016/12/7

#
Nosson1459 wrote...
I don't think I see any problems in the classes shown.
I have others, but they aren't mentioned or shown anywhere in the program
There are more replies on the next page.
1
2
3