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
why is this not the answer I thought it was
By ipeefreely, with 2 replies.
Last reply by Super_Hippo, over 11 years ago:
@azazeel: I think this code was given and you have to find out the value of 'sales'. If you change the given code like you did, you will get a different result. @ipeefreely: You used 'bonus0' in the code above. If 'bonus0' is 0 or 'bonus', then at the end, 'bonus' will be 20. The reason is the following: 'if (sales>300)' checks if 'sales', which is 500, is greater than 300. It is, so it executes the if-block (which is the next line). So 'bonus' is set to 'bonus0+20'. The next condition isn't even checked because it has this 'else' before the 'if'. That means it would only check the conditi
Re-adding an object when it's been removed
By vampire-wannabe, with 2 replies.
Last reply by danpost, over 11 years ago:
azazeel wrote...
what is this ?
I wonder this myself. This is what I see: <Code Omitted>Your line 48 and 49 get some random numbers that are not being used; so line 46 through 50 are meaningless. Besides, the actor would have to come in contact with two Zuko object at one time for line 46 to detect one because you are removing one in the previously calle
what is the value of sum after the following code is executed?
By ipeefreely, with 1 reply.
Replied to by danpost, over 11 years ago:
The code will not compile as 'sum' and 'x' are not declared anywhere. However, if you had this: <Code Omitted>then sum = 0+2, +3, +4, +5 = 14. I believe that this would work also: <Code Omitted>In fact, this may even work: <Code Omitted>
Please explain how to work this
By ipeefreely, with 3 replies.
Last reply by ipeefreely, over 11 years ago:
never mind. someone else explained it but thanks for your reply. I got sum is initialized to be 0. x = 2; x < 6 (true), sum = 0 + 2 = 2 x = 3; x < 6 (true) sum = 2 + 3 = 5 x = 4; x < 6 (true) sum = 5 + 4 = 9 x = 5; x < 6 (true) sum = 9 + 5 = 14 x = 6; x < 6 (false) The program terminated The last value of sum is 14 I didnt understand how to distribute the handy chart you provided but now I understand
Coding Help
By Code10, with 2 replies.
Last reply by danpost, over 11 years ago:
Code10 wrote...
ive tried using If ObjectClicked(actor) do this: AddObject(actor)
This is an improper way of showing what you have tried. You need to show the actual code you tried. Please read the 'Posting code? read this!' link below the reply box before posting the actual code you tried.
Gameproblem
By AdventureGameDE, with 8 replies.
Last reply by AdventureGameDE, over 11 years ago:
ok thx
multilevel counter.
By possumprior, with 10 replies.
Last reply by possumprior, over 11 years ago:
Thank you so much danpost what u said worked
Double actor trouble
By Corrupted, with 21 replies.
Last reply by Corrupted, over 11 years ago:
Thank you, if works perfectly! I get an error at the end when the player dies, but I'll be able to fix that myself. Once again, thank you!
Need some help with character moving
By ac130kire, with 1 reply.
Replied to by danpost, over 11 years ago:
Gravity is just a continuous adding to the vertical velocity. That is, represent the vertical speed of your character with a field (instance variable) and add a constant (gravity) to it every act cycle (continuous adding). Do not forget to use the field when moving the actor vertically. Using the background color would be very tedious -- especially since there are already methods available in the Actor class to check for intersection with other objects. Create Actor subclasses for the objects that represent Ground or Platform (black); also, do the same for the Gate or Door (red)
How do you get the act() method for world classes working?
By 298812kl2, with 1 reply.
Replied to by davmac, over 11 years ago:
I think you should read that API documentation more carefully:
This method does nothing. It should be overridden in subclasses to implement an world's action.
That gives you the answer to your question. Incidentally, the wording is almost the same as for the Actor's act method:
The default implementation does nothing. This method should be overridden in subclasses to implement an actor's action.
In other words, the act() method for the World and Actor subclasses works in exactly the same way. The only difference is that when you create an actor subclass, the class wil
Problem With Bouncing
By Tommy99, with 7 replies.
Last reply by Tommy99, over 11 years ago:
I made a few changes and it now works perfectly. Thanks for the help, danpost and davmac.
A question about Frames
By akkartik, with 2 replies.
Last reply by akkartik, over 11 years ago:
I have no idea what or where the greenroom is. But whatever.
attempting to make a recharging meter that stops an action if it is spent
By Spooks, with 8 replies.
Last reply by danpost, over 11 years ago:
You could add a boolean field and call it 'charging'. Use it to prevent boost, if charging, until recharged (when 'rechargemtr == 100', set 'charging' back to false). Set the 'charging' field to 'true' when 'rechargemtr == 0'. Only recharge ('rechargemtr++') when 'charging' is true). So, you would be doing the following two sets of steps at various places in your code:
How do I get my bluetank to move correctly and to stop going through the wall. I dont want the tank to get stuck, but to rather slightly bounce off.
By thenextsuperman, with 2 replies.
Last reply by danpost, over 11 years ago:
Moving is not the only thing here that may cause a collision with a Wall object. Rotating the actor may also be a cause. Therefore rotation must also be negated if it causes a collision. The following may be closer to what is required:
Carry score
By StuDent463212, with 8 replies.
Last reply by danpost, over 11 years ago:
StuDent463212 wrote...
I'm getting an error "<Identifier expected>" Between the first 'getScore' and the '()' in the second line
Show the code you are using. Cannot fix unseen code. This not only means what you used by my suggestion, but also the 'setScore' method in your world class as well.
563
564
565
566
567
568
569
X