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
AI must shoot towards my tank
By brothermic, with 1 reply.
Replied to by danpost, almost 10 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, almost 10 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, almost 10 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, almost 10 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, almost 10 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, almost 10 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, almost 10 years ago:
thnx
Editing actor images to not have white background
By JWK3986, with 8 replies.
Last reply by Nosson1459, almost 10 years ago:
anytime
Make a Airplane drop a bomb
By mmccurdy, with 9 replies.
Last reply by danpost, almost 10 years ago:
Nosson1459 wrote...
so do<Code Omitted>(bec it moves in increments of 10)
The range would have to be ten, if the speed is ten: <Code Omitted>and that is only if the actor has a rotation of 90. Like I said before, the placement and rotation of the actor are two factors that determine where it will be positioned on each act cycle.
getting an tire cannot be cast to Car error message plz help
By hockeydude1155, with 5 replies.
Last reply by Nosson1459, almost 10 years ago:
my bad stupid mistake not wat I meant though
problem
By Nosson1459, with 2 replies.
Last reply by Nosson1459, almost 10 years ago:
thnx
how to reset car back when it hits the border
By hockeydude1155, with 1 reply.
Replied to by danpost, almost 10 years ago:
The code from line 18 to 21 resets the car. Add the condition to line 17: <Code Omitted>
Calling method from another class
By Shadow7, with 1 reply.
Replied to by Super_Hippo, almost 10 years ago:
So you need the variable in your world? Save a reference to the object when creating it. Then you can use the methods on this object. <Code Omitted>
adding multiple actors using one constructor.
By Shadow7, with 1 reply.
Replied to by Super_Hippo, almost 10 years ago:
Is this what you want? <Code Omitted>
IOException
By Nosson1459, with 2 replies.
Last reply by Nosson1459, almost 10 years ago:
i tried to open a class and it didnt open just showed an error window with that error 4 times and i fixed it by closing and opening the program i just wanted to know wat it is
434
435
436
437
438
439
440
X