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

2013/12/17

how to let my ship get a crate

3
4
5
6
7
8
9
virginia001 virginia001

2013/12/19

#
no there are 2 platforms... one for the crates and one for the trucks and the were already in greenfoot itself so there are normal images with the objects placed on it(i.e the trucks and the crates) so the one at the bottom is for the crates ,the one at the top is for the trucks
danpost danpost

2013/12/19

#
Do me a favor, right click on each platform and click on 'Inspect' on the menu. Report back what is in the titlebar of each window produced. You only need do this once for the upper platform and once for the lower one.
virginia001 virginia001

2013/12/19

#
the upper one: vrachtwagenplek: vrachtwagenplek (subclass of Platform) the one below: platform: platform
danpost danpost

2013/12/19

#
Add the following method (constructor) to the vrachtwagenplek class code:
public vrachtwagenplek()
{
}
This should prevent the constructor of the Platform class from running for objects of this class.
danpost danpost

2013/12/19

#
I fear we will have to deal with that platform as well -- creating one (or more) larger platforms instead of a bunch of single sized platforms so we do not have the same problem on the truck platform that we had on the crate platform. I will not be able to deal with this immediately; and there are some questions I have about the truck platform that need answered beforehand. Such as: are there steps, are there gaps, etc. (basically, describe the exact shape of this platform).
virginia001 virginia001

2013/12/19

#
no its just a rectangle/oblong where the trucks are parked on....but the objects are from a different type of stones objects than the crate platform
danpost danpost

2013/12/19

#
I will need the size (width and height) of the image for the truck platform. You can get it using similar code (that temporary line) to getting the size of the image of the crate platform. Replace all occurrences of 'pImg' with 'getImage()'.
virginia001 virginia001

2013/12/19

#
ive putted this in my public class of Vrachtwagen: and i get width: 251 and height: 107
public vrachtwagenplek()  
    {
        System.out.println("width: "+getImage().getWidth()+"\nheight: "+getImage().getHeight());
    }
virginia001 virginia001

2013/12/19

#
I hope this will get you an better image of my scenario this is the code for the Vrachtwagenplek platforms objects:(where trucks are standing on)
vrachtwagenplek vrachtwagenplek = new vrachtwagenplek();
        addObject(vrachtwagenplek, 275, 60);
        vrachtwagenplek vrachtwagenplek2 = new vrachtwagenplek();
        addObject(vrachtwagenplek2, 402, 67);
        vrachtwagenplek vrachtwagenplek3 = new vrachtwagenplek();
        addObject(vrachtwagenplek3, 540, 75);
        vrachtwagenplek vrachtwagenplek4 = new vrachtwagenplek();
        addObject(vrachtwagenplek4, 282, 116);
        vrachtwagenplek vrachtwagenplek5 = new vrachtwagenplek();
        addObject(vrachtwagenplek5, 427, 129);
        vrachtwagenplek vrachtwagenplek6 = new vrachtwagenplek();
        addObject(vrachtwagenplek6, 571, 136);

        //And this is for my Platform class (wheres crates are standing on)

Platform platform = new Platform();  
        addObject(platform, 408, 729);  
        Platform platform2 = new Platform();  
        addObject(platform2, 408, 657);  
        Platform platform3 = new Platform();  
        addObject(platform3, 408, 585);

virginia001 virginia001

2013/12/19

#
okay i fixed the platforms problem they are now as how i want so can we focus now on the clickable crates
coldxms coldxms

2013/12/19

#
Lol, why are you actually doing this? Try some coding yourself, so for you've gotten everything from DanPost....
virginia001 virginia001

2013/12/19

#
dit is zeker zon kanker sletje die elke dag op dicks bounced en shit?
danpost danpost

2013/12/19

#
Please post the Kratten class as you have it now.
virginia001 virginia001

2013/12/20

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

public class Kratten extends Actor
{
    private Platform platform;

    public void act()
    {

        if (Greenfoot.mouseClicked(this))  
        {  
            //if (platform != null && platform.getSchip() != null) 
            if ( platform.getSchip() != null) 
            {  
                platform.getSchip().setKratten(this); // schip laadt krat in
                getWorld().removeObject(this); // 'krat verdwijnt 
            }
        }
    }

    public void setPlatform(Platform p)  
    {  
        platform = p;  
    }  

    public Platform getPlatform()  
    {  
        return platform;  
    }

}
danpost danpost

2013/12/20

#
Oh, how silly. My bad. We cannot call the opposite movement code within the method (not after resetting the fields in each one). We need to just move the object back from where it came from. Need to change all the movement methods similar to this:
public void moveRight()
{
    setLocation(getX() + speed, getY());
    setRotation(180);
    if (platform != null)  
    {  
        platform.setSchip(null);  
        platform = null;  
    }  
    Platform p = (Platform)getOneIntersectingObject(Platform.class);  
    if (p != null)  
    {  
        setLocation(getX() - speed, getY()); 
        platform = p;  
        p.setSchip(this);  
    }   
}
Line 13 replaced the 'moveLeft' call and the 'turn' statement was dropped. Line 13 is basically line 3 with the operation changed.
There are more replies on the next page.
3
4
5
6
7
8
9