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
Stop loop if condition is not met anymore?
By ChristianStachelhaus, with 3 replies.
Last reply by danpost, over 8 years ago:
Another way might be that you make all your instruction methods return a boolean value and place the following line at the end of each one: <Code Omitted>Then, your code would look like this: <Code Omitted>The semi-colon at the end of the while loop acts as an empty block of code to execute (no operations).
Determining the Actor subclass of mouseInfo.getActor()
By tonyreks, with 3 replies.
Last reply by danpost, over 8 years ago:
tonyreks wrote...
At that point, I feel like there might as well be an Actor method mouseClickedThis()
The method can not only be used for specific Actor objects, but also the World object; and it can also be used generically, where it does not matter what was clicked on, only that a click was detected. I often use it for specific Actor object where the code is placed in a World subclass. It is also used for cases where one wishes to detect when a mouse button was released (in situations where the pressing of the mouse is either unimportant or dealt with separately).
AI must shoot towards my tank
By brothermic, with 1 reply.
Replied to by danpost, over 8 years ago:
brothermic wrote...
I wanna write a tankgame. But my enemy's must be able to shoot towards my tank when my tank gets close enough. I have no idea how to make them shoot their bullets or flametrowers etc towards me. I found somewhere it has something to do with vectors correct?
Asked and answered
here
.
I need help with delay/wait
By Sk1llG4m3r, with 1 reply.
Replied to by danpost, over 8 years ago:
Sk1llG4m3r wrote...
i want that if the actor hits an object that just the actor freezes for 1 second
Add an instance int field to the class to count down the act cycles it is to be frozen for. For each execution of the act method, if the value of the field is zero, then the actor is not frozen (act normally); if it is not zero, decrement its value. When it hits the object in question, set the value of the field to something around 50, or 60. This would look something like the following:
greenfoot.ask
By Everardo_Chao, with 1 reply.
Replied to by danpost, over 8 years ago:
On this line: <Code Omitted>the single quotes around the three causes it to be treated as the character '3'. The character three has an int value of 51, which, obviously, is not 3. Remove the quotes from around the 3.
getMouseClick
By Everardo_Chao, with 2 replies.
Last reply by Everardo_Chao, over 8 years ago:
thank you very much!
Damage
By Sepho, with 11 replies.
Last reply by Sepho, over 8 years ago:
This was just a try. I just want that the zombie dies not with one hit but with few hits depending on the damage the Bullet does. for example: Bullet does 5 damage and the zombie has 10 hitpoint so he dies with 2 hits.
AI must shoot towards my tank
By brothermic, with 1 reply.
Replied to by danpost, over 8 years ago:
brothermic wrote...
I wanna write a tankgame. But my enemy's must be able to shoot towards my tank when my tank gets close enough. I have no idea how to make them shoot their bullets or flametrowers etc towards me. I found somewhere it has something to do with vectors correct?
Yes, it does have something to do with vectors; but, you do not have to deal with them directly. You can use the 'turnTowards' method of the Actor class to direct the "projectiles" toward your tank.
I need to get variables from MyWorld into an actor
By Shadow7, with 3 replies.
Last reply by danpost, over 8 years ago:
Shadow7 wrote...
thank you, this works but then it produces a java.nullexperiance when I try add an actor to the world
The code supplied cannot throw that exception, unless you misplaced the last line of code given (it should be in act method or method called by the act method).
ShootingBall
By danieli45, with 1 reply.
Replied to by danpost, over 8 years ago:
I am finding it difficult to follow your code here. I presume that the code is in a ShootingBall class, which creates ShootingBall objects. It does not matter what image you give the objects, they will always be ShootingBall objects. If you want to turn one into a brick, add a new brick object and remove the ShootingBall object ('this'). Possibly you should have an Arrow class also to do similarly with, instead of calling 'buildUpArrowImage'. With these changes, in all cases, no ShootingBall object will be in the world; so, your world class can just ask one question to shoot a new ball:
Exercise 6.32
By Klaud, with 1 reply.
Replied to by danpost, over 8 years ago:
Klaud wrote...
How do you add a second loop to your setup() method that places some more bubbles. This loop places 10 bubbles in a horizontal line, starting at x=300,y=100, with x increasing by 40 every time and y being constant.
??? Maybe copy the first loop and change the y-coordinate value ???
Countdown Fuel
By mmoodle, with 1 reply.
Replied to by danpost, over 8 years ago:
The first statement within the method will reset the value of 'fuelElapsed' back to '100' every time the method is called. Its value should be set to 100 when the Rocket object is created (or when it is added into the world). Next, "Space" should be "space" (with a lowercase 's'). The two lines executed when the spacebar is pressed are both problematic. The first line will automatically sets 'fuelElapsed' to a value less then '10' and the second line called the method that is currently being executed. This is not unlike an infinite loop and will freeze the program until an exception is th
Method not being found from an Actor
By SavioKing, with 1 reply.
Replied to by danpost, over 8 years ago:
The method is in the TrafficLight class, not the Actor class. Therefore, the field holding the TrafficLight object needs to hold a TrafficLight object, not just any Actor object: <Code Omitted>
isKeyDown
By Nosson1459, with 4 replies.
Last reply by Nosson1459, over 8 years ago:
thnx
Editing actor images to not have white background
By JWK3986, with 8 replies.
Last reply by Nosson1459, over 8 years ago:
anytime
431
432
433
434
435
436
437
X