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
Workaround for double mouse input
By CubeGamer6, with 2 replies.
Last reply by CubeGamer6, over 7 years ago:
danpost wrote...
You not only need to check which button was detected, but you also need to ask which mouse action was performed (pressing, dragging or releasing) -- you cannot just assume that the first is pressing and the next will be releasing.
I see. So that means i have to use the Greenfoot.mousePressed(), Greenfoot.mouseClicked(), etc to determine what happened. Thanks for the reply!
How To Expand Commands
By CavemanWrath, with 2 replies.
Last reply by CavemanWrath, over 7 years ago:
That worked like a charm. Thanks
Stop actors from spawning on top of one actor?
By Recorsi, with 48 replies.
Last reply by Recorsi, over 7 years ago:
danpost wrote...
Recorsi wrote...
Shouldn't it message me once then?
Not unless you move the print line down to outside the 'if' block.
i tried putting it in the act method, it still didn't work.
Show how used in act. Did you run the scenario or hit the 'Act' button a few times?
Ok nevermind it works now. I moved the act method up, maybe that was the problem. Thanks danpost & Hippo :)
What is this code means?
By agiastaee, with 1 reply.
Replied to by danpost, over 7 years ago:
agiastaee wrote...
whats "this." part mean ? <Code Omitted>
It means the same thing as: <Code Omitted>provided that 'frame' is not declared as a local variable within the block of code. That is, 'frame' is a predefined instance field. The 'this.' part is implicitly understood from within a non-static method when not explicitly given, It refers to the object created from the class that the method is being executed for (or on). All non-static methods (and constructor blocks) are executed on or for an instance (whether new or not) of the class. Field reference
Stopping every sound at once?
By Recorsi, with 2 replies.
Last reply by Recorsi, over 7 years ago:
Works great thanks :)
ArrayList error
By CavemanWrath, with 2 replies.
Last reply by CavemanWrath, over 7 years ago:
I don't exactly remember but whatever I did fixed it. It is very possible that I will run across some more bugs with it in the future though.
Changing an int to a double using two methods
By dbutts1@stumail.com, with 5 replies.
Last reply by dbutts1@stumail.com, over 7 years ago:
Thank You
Integer not returning
By WardedBowl403, with 4 replies.
Last reply by WardedBowl403, over 7 years ago:
Super_Hippo wrote...
As far as I know, that only happens when you right click the object and choose the method. I am happy that not every method call creates a pop up window to be honest.
Hmm okay. The computers at my school always create a popup when a function with a return type that isnt void is called. I guess those computers are also running and older version of greenfoot. Thanks for the help, I was very confused.
Greenfoot 6.34 Bubbles size and direction
By dbutts1@stumail.com, with 10 replies.
Last reply by dbutts1@stumail.com, over 7 years ago:
Okay, Thank you very much.
Get Objects that aren't actors
By NoaSakurajin, with 7 replies.
Last reply by Super_Hippo, over 7 years ago:
Well, you could add another 'in the world' at the end of the first sentence if it isn't clear to you. It really wouldn't make much sense if the world keeps a reference to all objects which are created (but not added to world) and doesn't ever remove the reference.
HELP WITH GREEPS URGENT
By JohnMa, with no replies.
Hi, I need help with my greeps code for my class Rule 1: Only change the class 'Greep'. No other classes may be modified or created. *** You will be making all of your changes within the act method of the Greep class. Rule 2: No additional fields. You cannot extend the Greeps' memory. That is: You are not allowed to add fields to the class (except final fields). You can use the one byte memory that is provided. Rule 3: You cannot move more than once per 'act' round. Rule 4: You cannot communicate directly with other Greeps. That is: no field accesses or method calls to other Greep objects are allowed. (Greeps can communicate indirectly via the paint spots on the ground.) Rule 5: No long vision. You are allowed to look at the world only at the immediate location of the Greep. Greeps are almost blind, and cannot look any further. Rule 6: No creation of objects. You are not allowed to create any scenario objects (instances of user-defined classes, such as Greep or Paint). Greeps have no magic powers - they cannot create things out of nothing. Rule 7: No teleporting. Methods from Actor that cheat normal movement (such as setLocation) may not be used. I CAN ONLY CHANGE THE super.act method this is my code right now. I need to get better scores import greenfoot.*; // (World, Actor, GreenfootImage, and Greenfoot) /** * A Greep is an alien creature that likes to collect tomatoes. * * @author (Your Name Here) * @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! final static int HOW_MUCH_STEPS = 10; final static int FULL_360= 360; /** * 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 * * Name: * Date: * Description: basic starting version * * * */ public void act() { super.act(); // do not delete! leave as first statement in act(). if (carryingTomato()) { int remainingSteps = getMemory(); if(remainingSteps == 0) { spit("purple"); turnHome(); } else { remainingSteps--; setMemory(remainingSteps); } if(atShip()) { dropTomato(); turn(180); } if(atWater() || atWorldEdge()) { setMemory(HOW_MUCH_STEPS + Greenfoot.getRandomNumber(HOW_MUCH_STEPS/2)); turn(Greenfoot.getRandomNumber(FULL_360)); } move(); } else { boolean hasPurple = seePaint("purple"); if(hasPurple) { turnHome(); turn(180); } if(atWater() || atWorldEdge()) { turn(Greenfoot.getRandomNumber(FULL_360)); } move(); checkFood(); } } /** * 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 "Ruhaan"; // 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"; } }
how can i limit the ammount of actors are created when act =30 cycles
By roonie01, with 11 replies.
Last reply by roonie01, over 7 years ago:
thank you so much it works great
The scenario stops when switching worlds?
By Arakniode, with 3 replies.
Last reply by roonie01, over 7 years ago:
do you possibly have a Greenfoot.stop(); some where in your code for the start button
how to fix this code for class moves very choppy need help quick
By roonie01, with 2 replies.
Last reply by roonie01, over 7 years ago:
oh thanks so much man your a life saver that's exactly what I was trying to do
Bubbles with a for loop
By dbutts1@stumail.com, with 2 replies.
Last reply by dbutts1@stumail.com, over 7 years ago:
Thank You
301
302
303
304
305
306
307
X