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
greenfoot piano (from the book)
By wahaj, with 2 replies.
Last reply by wahaj, about 12 years ago:
well i cant take credit for this. i did get these ideas from the book. but i understand now what to do. i think the major mistake that i was that i put the increment of a inside the if statement. my mind kind of went towards that but for some reason i didnt try it. thanks for the reply.
H
By poila., with 4 replies.
Last reply by poila., about 12 years ago:
Michionlion wrote...
it is pretty self explanatory... public void lookForFly() { declares a method, and in the method... if (canSee(Fly.class)) { tests if the method canSee() returns true when you pass in Class Fly.class. if it does return true... eat(Fly.class) it calls the method eat(), passing in Fly.class, then... increments the FlysEaten variable by 1. In this example, you would need the methods canSee(Class) and eat(Class), neither of which are included in Greenfoot.
Thank you very much I know how it works now.
Detect scenario exit?
By DonaldDuck, with 6 replies.
Last reply by kiarocks, about 12 years ago:
Looks like you could try to catch the ThreadDeath Error that happens when you refresh/close, not sure how hard it would be.
high scores
By tylers, with no replies.
on my high scores ive got a a scroll bar and i don't want that how do it get rid of it
this is it
help
By tylers, with no replies.
on my scenario
here
it runs locally at 55fps but post it onto the gallery it runs at 21 ish fps. not sure why ?
Timer code?
By MakerOfGames, with 1 reply.
Replied to by danpost, about 12 years ago:
There is the system command: System.currentTimeMillis() which returns (as type 'long') the current time in milliseconds (if that is what you are looking for). (Download and check out my
Millisecond Timer
scenario).
New to Greenfoot
By sebaqu, with 1 reply.
Replied to by danpost, about 12 years ago:
The easiest thing to do is on each act cycle: 1) turn left (keep hand on left wall) 2) move(1) 3) if (blocked) move(-1) (wall was still there) 4) turn right 5) move(1) 6) if (blocked) move (-1) (wall in front now also) 7) turn right 8) move(1) 9) if (blocked) move(-1) (Oh no! dead end) 10) turn right 11) move(1) (back from whence I came) After step (1), you could make use of a 'for' loop to repeat 2 through 4 (4 times -- once for each direction). There are a few advanced mazes that this will not work for (they would have a path that goes forth and completes a cycle back to itself
What's the meaning of this piece of code please?
By poila., with 1 reply.
Replied to by danpost, about 12 years ago:
The 'public static int FlysEaten = 0;' statement will be used to keep track of how many flies that ALL of your spiders have eaten. I believe the 'canSee(Class cls)' and the 'eat(Class cls)' are methods inherited from the Animal class. The 'canSee' will check for intersecting flies with this object, and if there are any, the 'eat' will remove one. Then the counter increments with 'FlysEaten++'.
Playing sound if not playing?
By nooby123, with 2 replies.
Last reply by nooby123, about 12 years ago:
Thanks!
playerdata
By tylers, with 1 reply.
Replied to by tylers, about 12 years ago:
well ive fixed it now (could be a bug) i closed the program and restarted it
colours
By tylers, with no replies.
how do you change the colours of the text on the score board?
Little Problem with drawing ...
By arialdancer, with 1 reply.
Replied to by danpost, about 12 years ago:
From the code you have given, it appears that all you see is the note. You can only set one image to each object (but different objects of the same class can have different images). You are creating the fiveLine image and setting it to the object, then you are creating the note image and now setting it to the object (which replaces your fiveLine image). I do not see where you 'addObject' the note object into the world. From your act() method (drawFiveLine(); drawNote();), it appears that you are trying to create two different objects with the same object class. If this is so, you need t
Explosion help
By jdemshki, with 7 replies.
Last reply by davmac, about 12 years ago:
Okay, nevermind; (it doesn't say the URL, it just shows how to get there). Yes, the video is old and out-of-date. But you can easily get the support classes at the URL I provided above. Also Greenfoot 2.2.0 will come with several support classes that you can import into your scenarios.
Quick questions
By woodkami, with 15 replies.
Last reply by danpost, about 12 years ago:
You can just change the '8's to 'getWorld().getWidth() - 1' or 'getWorld().getHeight() - 1' (depending) and it will work for any size board. I checked up on 'Go (board game)' on Wikipedia. The corners are safe and the edges are fairly safe; so, what I had prior to the most recent code post was more to the rules of the game. That is, for lines 19 through 22 above, you would use:
help with getting objects to move towards another object
By mrub4, with 1 reply.
Replied to by Cesarferreir, about 12 years ago:
import java.util.List; public int pointTo(int x, int y) { int dX = x - getX();//get distance between mouse's X and player's X int dY = y - getY();//get distance between mouse's Y and player's Y double rotation = Math.atan2(dY, dX); rotation = Math.toDegrees(rotation); return (int)rotation; } List<Worm> crab = getObjectsInRange( 2000,Worm.class); if(crab.size()!=0){ pointAtObject(crab.get(0)); move(6.0);}
984
985
986
987
988
989
990
X