This site requires JavaScript, please enable it in your browser!
Greenfoot
Username
Password
Remember Me?
Sign Up, Lost Password
Activity
About
Documentation
Download
Discuss
Scenarios
Discussions
You need to login to take part
Current Discussions
Bubbles Lab
By MrsJones, with 9 replies.
Last reply by danpost, about 10 years ago:
rc5pn wrote...
need some help implementing the code in the bubble constructor- couldn't use a for loop, instead used a while loop
You should start a new discussion thread and reference this one for your issue. Could not use a for loop -- or not allowed to use a for loop? Show attempted code we can help you with. Explain why it does not meet your satisfaction.
how do i make a scrolling game
By djyoay, with 1 reply.
Replied to by danpost, about 10 years ago:
djyoay wrote...
I'm trying to make a driving game but I don't how to make it scroll.
What perspective are you using? What have you tried? Show some attempt.
How to make lives and invincibility frames
By Flootershai, with 1 reply.
Replied to by davmac, about 10 years ago:
I think most of your problem is in this line: <Code Omitted> This is setting HitboxState to false, and always evaluating to false. You need to use double-equals (==) to compare, rather than single equals: <Code Omitted> Or, since you are dealing with a boolean value: <Code Omitted> (Read above as "if not HitboxState").
I don't know why I can't get my little man to jump.
By smcgee, with 1 reply.
Replied to by Super_Hippo, about 10 years ago:
Line 48: move(2); This doesn't call your move-method (line 79). You have to remove the number there, so it will be just move();. After that, you need to add some code into the fall-method or the Jumper will keep falling after one jump.
Scrolling Background in y-Achsis Direction
By Julian109998, with 5 replies.
Last reply by Julian109998, about 10 years ago:
Thank you, it works perfectly :)
Get user's location
By trimil, with 4 replies.
Last reply by trimil, about 10 years ago:
Okay.
Spawning objects after time
By Amature, with 12 replies.
Last reply by danpost, about 10 years ago:
MacG wrote...
I wanna addObject with some interval, But I want it loop, every 2 seconds, the zombie will show and it not stoping, can I do that ?
Just count act cycles; and when it reach the number of act cycles executed within a 2 second interval (usually something between 100 and 120) spawn a zombie and reset the 'int counter' field.
how do i set a timer
By Trevlodown, with 1 reply.
Replied to by Super_Hippo, about 10 years ago:
Place lines 2 through 6 into the act-method. By the way, you should probably use a higher number than 60 because 60 act-cycles is about one second at normal speed.
Greeps
By Aaron222, with no replies.
Hello I am doing the Greeps. My professor told me that the greeps should catch at least 15 tomatoes in 15 seconds in each map. I do not know where my source code should be changed. Those are my greep class' source code.<Code Omitted> import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot) /** * A Greep is an alien creature that likes to collect tomatoes. * * @Alisa Johnston * @version 0.1 */ public class Greep extends Creature { // Remember: you cannot extend the Greep's memory. So: // no additional fields (other than final fields) allowed in this class! /** * Default constructor for testing purposes. */ public Greep() { this(null); } /** * Create a Greep with its home space ship. */ public Greep(Ship ship) { super(ship); } /** * Do what a greep's gotta do. */ public void act() { super.act(); // do not delete! leave as first statement in act(). TomatoPile tomatoes = (TomatoPile) getOneIntersectingObject(TomatoPile.class); Greep overlapping = (Greep) getOneIntersectingObject(Greep.class); if (atWorldEdge()) { turn(Greenfoot.getRandomNumber(90)); } if (carryingTomato()) { spit("purple"); if(atShip()) { dropTomato(); turn(180); move(); setMemory(0); } else { if (atWater()) { turn(Greenfoot.getRandomNumber(150)); move(); } else { turnHome(); move(); } } } else { if (atWater()) { turn(Greenfoot.getRandomNumber(150)); } if (tomatoes != null) { if (getMemory() < 9) { setMemory(getMemory() + 1); } if (getMemory() < 8) { move(); } } else { if (seePaint("purple") && !carryingTomato() && tomatoes == null && !atWorldEdge() && !atWater()) { turnHome(); turn(180); spit("orange"); } else if (!seePaint("purple") && !seePaint("orange")) { if (randomChance(30) == true) { if (randomChance(50) == true) { turn(0); } else { turn(-10); } } if (!atWater()) { spit("red"); } } else if (seePaint("red") && !seePaint("purple") && !seePaint("orange")) { if (randomChance(50) == true) { turn(90); } else { turn(-90); } } move(100); } checkFood(); } if (tomatoes == null) { setMemory(0); } } /** * Is there any food here where we are? If so, try to load some! */ public void checkFood() { // check whether there's a tomato pile here TomatoPile tomatoes = (TomatoPile) getOneIntersectingObject(TomatoPile.class); if(tomatoes != null) { loadTomato(); // Note: this attempts to load a tomato onto *another* Greep. It won't // do anything if we are alone here. } } /** * This method specifies the name of the author (for display on the result board). */ public static String getAuthorName() { return "Alisa Johnston"; // write your name here! } /** * This method specifies the image we want displayed at any time. (No need * to change this for the competition.) */ public String getCurrentImage() { if(carryingTomato()) return "greep-with-food.png"; else return "greep.png"; } }
Cannot find a simple collision method.
By elektrikpulse61, with 4 replies.
Last reply by elektrikpulse61, over 10 years ago:
Now that you've put it that way, your idea is much more logical. Of course when I try to assign a list-returning method to an Actor object, I'm going to get an incompatible types error! Thank you both davmac and danpost for your help on this. I'll be sure to remember your advice for next time!
Transparent part of an PNG sound not be able to be clicked
By 31oli31, with 4 replies.
Last reply by danpost, over 10 years ago:
Both the circle and the triangle/rectangle issues can be resolved using math. The circle issue is a 'length of an hypotenuse' problem (distance between two points) while the triangle/rectangle issue is a basic ratio problem (the percent distance of the mouse click from the center of the actor image to the left or right edge of the actor image compared to the percentage distance of the mouse click from the top edge of the actor image to the bottom edge). Both can also be resolved by checking for the color of the image at the location of the mouse click. If the color is not transparent the
changing text
By FutureCoder, with 9 replies.
Last reply by FutureCoder, over 10 years ago:
Thank you so much, it works perfectly.
looping
By olliequirk, with 2 replies.
Last reply by Super_Hippo, over 10 years ago:
I don't see an error there. What I notice is that lines 17 through 24 are the same as 25 through 32. If I remember correctly, the actors are only repainted in the world between the act-cycles (or if the method was called "manually"). So you can't see the character moving down when you hold down the down-key. When you release the key, the actor will be somewhere below the last position, but changing the image while falling in the do-while-loop doesn't really make sense because you can't see it. Why do you want to use a do-while-loop? Maybe it would work like you wish if you just use line 1 as
Making Solid Walls
By cleeming, with 1 reply.
Replied to by Super_Hippo, over 10 years ago:
Save the current position, move and if it is touching something it shouldn't be able to walk through, walk back. <Code Omitted>
how to
By Trevlodown, with 1 reply.
Replied to by danpost, over 10 years ago:
Trevlodown wrote...
How can I add one of my own games on to this website
Either click the 'Share' button near the top-right corner of the scenario window or press Ctrl-E; then use the 'Publish' tab on the pop-up 'Share' frame.
450
451
452
453
454
455
456
X