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
Debug
By sillycilly, with 2 replies.
Last reply by RcCookie, about 6 years ago:
Just set a breakpoint and the debugger will open
I NEED HELP
By hhh, with 4 replies.
Last reply by danpost, about 6 years ago:
Kostya20052011 wrote...
I forgot to say that variables are declared before methods, and are used in the method itself, is this an error?
It's not an error. It is just not always necessary. If the variables are assigned new values and only used within the method during the current act step, then it is probably best to declare them within the method. Also, if the variable is only used one in the method, it might be best to use the method call to get the value at the time it is needed and forego declaring a variable for it at all. So, with this:
Is there any way to create a percentage in Greenfoot?
By Pistolenkrebs, with 1 reply.
Replied to by danpost, about 6 years ago:
Pistolenkrebs wrote...
So I wanted to create a Universal Paperclip-like game, and for that I want to exponentially raise the prices of certain objects/upgrades. Is there any way to do so?
Just raise the price by multiplying by one more than the percentage required. That is, to increase by five percent, multiply by 1.05 (or multiply by 105/100).
hi how would i create a timer for a pistol so if i shot i had to wait before shooting again?
By Weeb.exe, with 2 replies.
Last reply by Weeb.exe, about 6 years ago:
ok thank you
Just cannot figure out how to change worlds
By NotGoodAtThis, with 3 replies.
Last reply by danpost, about 6 years ago:
NotGoodAtThis wrote...
Solved that. I moved the world change code to an actor that sits on the world I want to move from.
There is an
act
method defined in the
greenfoot.World
class. You can override it (just like it is done in a class extending
greenfoot.Actor
) in your
TitleScreen
class. It is just not provided by the
World
subclass template as it is when you create a new subclass of
Actor
.
I am supposed to create a method that detects the nearest object (minnow) to another object (shark). The code seems to have some errors, but I am not able to compile it.
By Atharva1912, with 1 reply.
Replied to by danpost, about 6 years ago:
minnow
is of type
Actor
but,
nearest
is of type
Minnow
. You need to typecast
minnow
as type
Minnow
in order to set it to
nearest
. That is, line 13 needs to be as follows: <Code Omitted>Also, your method is supposed to return the nearest minnow; not the last one in the list.
double pendulum
By ronald, with 10 replies.
Last reply by ronald, about 6 years ago:
ok thank you
Using methods from another class
By resh47, with 1 reply.
Replied to by danpost, about 6 years ago:
In line 3, you need to typecast the world as a
GameWorld
object (just as in line 2). To avoid double work, you can set the world to an object reference variable prior to line 2: <Code Omitted>It allowed for the rest to be pretty short as one line, so I combined your lines 2 and 3 as my line 3.
Write a new public method in your Ocean class called addMinnow(). This method should pick a random x/y location in the ocean and add a single minnow there.
By Atharva1912, with 2 replies.
Last reply by Atharva1912, about 6 years ago:
Thanks a lot
Help with Shield for Asteroids
By elsmog, with 3 replies.
Last reply by danpost, about 6 years ago:
elsmog wrote...
I am wondering how to implement a shield that deflects asteroids rather than ignoring them, as I do now. << Code Omitted >>
This may not be quite so easy to do. Remember that both the asteroids and the rocket are drifting/moving. It may not be enough just to change the direction of a colliding asteroid. In my
asteroids
scenario, which has shielding implemented, I had both colliding actors change their trajectories with the help of a smooth moving system. You may want to take a look at its codes -- especially the
showText method in World class
By SnowFlurry, with 1 reply.
Replied to by danpost, about 6 years ago:
SnowFlurry wrote...
Does the showText method in the MyWorld class allow one to change the font and colour of the text?
No.
How can i spawn some things random ?
By schniggi, with 3 replies.
Last reply by danpost, about 6 years ago:
schniggi wrote...
Could you please send me an example i donn know how to write this correctly
What have you tried?
pendulum
By ronald, with 9 replies.
Last reply by ronald, about 6 years ago:
great, thank you
Need help on what codes to use for my game
By popo88, with 3 replies.
Last reply by danpost, about 6 years ago:
Well, get that much done so you have something to work with.
need help using MouseClicked method with an actor
By Joshua09, with 1 reply.
Replied to by danpost, about 6 years ago:
The
mouseClicked
method does not look for clicks on classes. It looks for clicks on a specific object (or any click when the argument is
null
). If the code given is in your
Block
class you can use
this
as the argument. For the world, you can simply use
getWorld()
for the argument.
133
134
135
136
137
138
139
X