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
Add an object once score reaches certain point?
By ananyagarg, with 3 replies.
Last reply by danpost, almost 8 years ago:
@Jeph, I am quite sure there is a problem with this line: <Code Omitted>Also, not only will your loop add a rock at all location at one time, but the
if
condition will most probably be true for many act cycles in a row -- meaning rocks will be added in an abundance. Again, I urge that the adding of rocks dependent on the score be done in the
MyWorld
class act method. The "dying" of the world should be implemented there also. Without knowledge of the number of rocks initially in the world and if any are ever removed, it would be difficult to
Get random number problem
By Chipley, with 2 replies.
Last reply by danpost, almost 8 years ago:
Move line 12 to be line 35. At line 12, it is assigned a value only once (when the world is created). At line 35, it (as a new variable each time) will be assigned a (new) value each time you are creating a new BottomPipe object. Also, to get a number between 20 and 200, inclusive, use: <Code Omitted>
how to make actor keep walking on a square?
By jc5879, with 3 replies.
Last reply by danpost, almost 8 years ago:
jc5879 wrote...
<< Code Omitted >> like this way?
You got the 4th direction in; but, you still need to reset
steps
to zero when turning. There is also now a problem that
getRotation
returns a value between
0
, inclusive, and
360
, exclusive. It will never be
-90
, as your new condition compares it to.
Shooting Direction
By CosmicCaleb, with 3 replies.
Last reply by danpost, almost 8 years ago:
CosmicCaleb wrote...
You can shoot in all 4 directions, but I just had it like this so it would be easier to read and I wouldn't have to write quite as much.
This really did not answer my question. Nor, did it provide all of what I was trying to understand. I was hoping to get an answer to this, as well:
Does your player's rotation change dependent to the direction it moves and should shoot?
If not, then you need a single field for the "facing" direction (not two). Otherwise, the rotation of the player can be used, instead. If using a field, its values could be equi
How to increase points by more than one?
By ananyagarg, with 3 replies.
Last reply by danpost, almost 8 years ago:
ananyagarg wrote...
How would you code to add 5 points instead of one?
<Code Omitted>
how to stop actor when being clicked the ball?
By jc5879, with 4 replies.
Last reply by jc5879, almost 8 years ago:
Thank you ! I figure it out.
need help with counter
By Chipley, with 2 replies.
Last reply by Chipley, almost 8 years ago:
Thanks works great, thank you for the help.
Help
By nx117, with 3 replies.
Last reply by danpost, about 8 years ago:
nx117 wrote...
How do you call a method from another class?
You really need to be more specific. Show the two classes involved and point to what you are trying to access and from where. Non-static methods are always called on an object created from the class the method is in. If no object is explicitly given, then the method is being called from within the class (or from a subclass) and the object is the same as that which the calling method was executing on and can be referenced by the keyword '
this
'. Calling on a object created by a different class, you must explicitly g
I need help creating new objects based on the score
By Alexlife2002003, with 8 replies.
Last reply by Alexlife2002003, about 8 years ago:
oh Wow thanks, I did not notice that
Auf Variable Beziehen
By MrExamined, with 15 replies.
Last reply by MrExamined, about 8 years ago:
Vielen Dank für eure Hilfen, hat mir sehr geholfen.
isTouching only works once
By bommijn, with 2 replies.
Last reply by bommijn, about 8 years ago:
You were right i overlooked this. field Rotation was initialized in my constructor and given a random value which was than assigned to setRotation(). I could have actually used setRotation(Greenfoot.getRandomNumber(...)); When they collide it would set the rotation field from Actor to the new value but not rotation in my class which was used to calculate the new rotation. So it appeared as it was being ignored but it actually just set it to the same amount every time. Thanks for changing my point of view, was clueless here for a while.
Help with Snake Game
By ananyagarg, with 5 replies.
Last reply by danpost, about 8 years ago:
ananyagarg wrote...
If you use the code above, it only works for the first 5 cherries but then doesn't continue to add cherries after the first blueberry is eaten
Line 19 should add a cherry -- not a blueberry.
Having trouble moving invaders left and right
By ananyagarg, with 5 replies.
Last reply by danpost, about 8 years ago:
ananyagarg wrote...
In your game, why do your invaders shoot their bullets so fast, and where is the code in your game that determines the speed in which the bullets move?
The demo was geared toward the movement -- not really anything else. However, the shooting code is in the
Invader
class. The last line in its
act
method partly controls when a shot is fired by having each invader shoot randomly, but on an average of once every 200 act cycles. In the
shoot
method, shooting is further limited to only if the invader is the lowest one in its column. For some unkno
Having trouble about these pattern by using loop
By rickykwl, with 3 replies.
Last reply by danpost, about 8 years ago:
rickykwl wrote...
may i know what means about % and / ?,
The / is just division. Actually, in this case, it is integer division where any fractional remainder is discarded (only because we are working with integer values). The % is the modulus operator. It returns the remainder after division So, as the iterator, i, progresses from 0 to 31, i/8 will be 0 until i=8, then 1 until i=16, etc., while i%8 will repeatedly go from 0 to 7. One complete cycle from 0 to 7 will occur for each "increment" of i/8 (which will go from 0 to 3).
how to impose the multiple conditions for the
SCORE COUNTER
By LELETHU, with 1 reply.
Replied to by mik, about 8 years ago:
You might like to have a look at
this video
. The score counter starts at about 5:45.
237
238
239
240
241
242
243
X