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

2012/4/11

What is the code that objects in the game can let fall different items

martijn13039 martijn13039

2012/4/11

#
I like to make a program that people make a mess and that an other object need to clean it, but I don't know how it is possible that some guys let fall some different troop PLZ I need help, maby you can gif me the code but otherwise all help is welcome Martijn :)
martijn13039 martijn13039

2012/4/11

#
plz help me
trash1000 trash1000

2012/4/11

#
Your description of what you actually want to do is very vague. Explain it further and maybe someone can actually help. P.S.: You cannot expect someone to reply to your post after just an hour...
SPower SPower

2012/4/11

#
You need 3 actor subclasses for this. One which is a person who makes the mess, another to clean it up and a third which is the mess. From the first class, you create objects from the third class(mess) and from the second class you remove it.
martijn13039 martijn13039

2012/4/11

#
je but how can the third clas drop some mess
martijn13039 martijn13039

2012/4/11

#
trash1000 I want that an actor drop some mess if i play the game
davmac davmac

2012/4/11

#
Definitely sounds like you need to go through the tutorial videos (in the Documentation section). Never ask for the code, the idea is that you should learn how to develop the code yourself. Have a go. Create a scenario, add the classes as SPower suggested. Watch the tutorials. Make it so that your two actors (the one which makes the mess and the one that cleans it up) are added automatically when the world is created. Then you've got a starting point. If you can get this far, ask for some more help (tell us what your classes are called, and give more information - when do you want the mess dropper to drop mess, what strategy should the cleaner use, etc). You really cannot expect much help with such a vague question. It's not that we don't want to help, but it's really difficult when we don't even understand what you want, and you haven't even started writing any code so it's hard to suggest how to improve it.
martijn13039 martijn13039

2012/4/11

#
Sir davmac I will appologise for my vague question I hope this wil I be better I know is not right to ask for a code but I try it for days to make the code but I wil say sorry for asking I hope this wil better, I like to make a game with somepeople that make a mess and one guy need to cleanup This is the code that I have (I have peoples that can walk different en a guy that I can drive) But I wil that de people who walk different drop sometime a item (mess) The code: concierge (I can drive public class concierge extends Animal { public void act() { move(4); if ( Greenfoot.isKeyDown("right")) { turn(5); } if ( Greenfoot.isKeyDown("left")) { turn(-5); } if (atWorldEdge()) { turn(15); } if(canSee(mess.class)) { eat(mess.class); } if(canSee(student.class)) { eat(student.class); Code: (this students need to drop sometime a item but I don't know how) public class student extends Animal { public void act() { move(6); if ( Greenfoot.getRandomNumber(101) < 15) { turn( Greenfoot.getRandomNumber(40)-20 ); } if (atWorldEdge()) { turn(15);
SPower SPower

2012/4/11

#
In student:
public void act()
{
    if (Greenfoot.getRandomNumber(10) == 5) {
           getWorld().addObject(new mess(), getX(), getY());
    }
.....the code you already had here........
}
Next time: think about it yourself :)
martijn13039 martijn13039

2012/4/11

#
oow Thank you so much now I understand, it´s so easy thx!!!
You need to login to post a reply.