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
Unsure how to make certain loop
By Ni3ls, with 1 reply.
Replied to by danpost, over 7 years ago:
Unless I entirely misunderstand what you are wanting to do, I do not see why you would need a loop. On any given act step, the value of the
shotDelay
field will only go down once. If its value is not negative, you will only add one extra block into the world. On any act step a shot is fired, you would just remove all the blocks from the world. None of these actions requires a loop on your part.
setSpeed() for a single Actor
By coreXtream, with 2 replies.
Last reply by danpost, over 7 years ago:
I guess the other possibility is to double the width and height of the world and halve the cell size. Then, without changing the size of the images, you can have the bullet move faster. Actually from 21 x 14, you can go to 43 x 29, place and allow turning only on odd valued x- and y-coordinates so as not to really change anything other than non-bullet objects "half-stepping" it. This would also solve the bullet/edge issue. Restrict the rover and other non-bullet objects to x >= 1, y >= 1, x <= world width -2, and y <= world height - 2.
How do you detect a click in an area on the world
By TobyRoby, with 10 replies.
Last reply by TobyRoby, over 7 years ago:
awesome, thank you very much you beautiful greenfoot user <3
How can I restart a loop early?
By lm_s, with 3 replies.
Last reply by danpost, over 7 years ago:
I think you may have a misunderstanding about the way the act method works. You need to program it for what you want done at each instance of time. The act method is repeatedly called while your project is in a running state -- which is like the initial animation loop. Assuming that there will always be a right or left path to go if not able to go forward: <Code Omitted>should be sufficient. A choice would need to be made if left and right were both possible ways to go. You can repeat line 2 (copy/
How to check if you have detected a different color
By pablo0826, with 3 replies.
Last reply by danpost, over 7 years ago:
pablo0826 wrote...
<< Images Omitted >> Above are images of my world before and after running the program. And below is the code for the lander. << Code Omitted >>
What is the size of your world? what is the size of the image assigned to the
Mountains
class? and, where was your
Mountains
object addied into the world at? Do you have scrolling implemented? You may want to track the location coordinates of your Rocket object as double values so as not to lose precision (makes for smoother acceleration/deceleration).
how to make actor react on noise through microphone
By Dhiraj, with 1 reply.
Replied to by danpost, over 7 years ago:
Use the
Greenfoot.getMicLevel
method. If the returned value is less than a certain value, move right as normal, otherwise (
else
) move left. Btw, the commented text in the code reads moving left is normal and move right when noise is being made.
Swapping Actors in a 2d array
By M123D, with 1 reply.
Replied to by danpost, over 7 years ago:
M123D wrote...
I'm trying to make a game based off of candy crush but I can't seem to get the swapping of the actors right. In my code, all the different coloured candies extend a Candy class and they are placed in MyWorld according to how many pixels apart they are.
Please show
Candy
class code and
MyWorld
class code.
PLEASE HELP ME FOR THE LOVE OF GOD
By Swangbee, with 4 replies.
Last reply by danpost, over 7 years ago:
If the
HealthBar
object is contained by the
SpaceShip
object, then it would make good sense to have the space ship look for the Powerup object and not the other way around.
Get an actor to bounce back when egde is hit.
By Notted, with 7 replies.
Last reply by danpost, over 7 years ago:
Notted wrote...
So, if this << Code Omitted >> is not setting the direction of the actor, will setRotation(), do the job? If not, what will?
Yes, but your actor will not the be upright. Just negate the speed of the actor.
I want to use the boundaries of the image as the bombs hitting the bucket. How do I do this, since I don't know?
First, see if there is an intersecting bomb. If so, then get the image and determine whether the location of the bomb is in the collectible region. The left edge of the basket would be at:
I have a question
By imdojangbob, with 6 replies.
Last reply by danpost, over 7 years ago:
imdojangbob wrote...
What should I do with my animal class?
Personally, I would totally remove the
Animal
class from the project. I see only one "possibly" useful method in it (the
move
method) and it is not used in the
Human
class. All the others either have a method now in the
Actor
class that can be used in lieu of it (
canSee, eat, turn, atWorldEdge
); or, are badly written (
access, removeObject
); or, are related to poor design (displayMessage, clear). From a design standpoint, it would be better to use an actor, or actors, to display messa
Logic errors(?). boomArea no checking to see if bomb has hit class
By Notted, with 17 replies.
Last reply by Notted, over 7 years ago:
Thanks!
我到底那里错了?
By NanyuKe, with no replies.
<Code Omitted>
Highscores
By ant, with 2 replies.
Last reply by data17, over 7 years ago:
With this method you can read the highscore file: <Code Omitted>
Problem with the removing of something
By Tommes, with 3 replies.
Last reply by danpost, over 7 years ago:
Tommes wrote...
Thank you, you are my hero!
And you are my 500th fan (follower). Thank you.
Colordetection
By xandreas_1, with 6 replies.
Last reply by danpost, over 7 years ago:
xandreas_1 wrote...
Is there a way to get a scrolling background in the worldclass while pressing w and s for forwards and backwards?
See my
Scroller Class Demos
scenario.
Answer for Q2: Size World(1500, 750, 1) Size Background Actor(1500px x 210px) Localisation Background Actor(750, 650)
Would take a bit of calculating to just figure out which pixel in the background image would need to be looked at.
I should mentioned some facts about my game: One of my Actorclasses is my scrollingbackground(not with the col
219
220
221
222
223
224
225
X