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
making a object randomly choose to either turn up, down, left, or right (180, -90, 0, 90)
By Miguel.Valdez, with 14 replies.
Last reply by Miguel.Valdez, over 8 years ago:
awesome THANK YOU!!!!! I have learned A LOT between yesterday and today in how to make simple things functions..... all i know is things will start getting much more complicated though,
loop-practice throws a java.lang.NullPointerException
By paubel, with 5 replies.
Last reply by danpost, over 8 years ago:
For a transparent background, you can change the line to this: <Code Omitted>
How do I set a string only once
By CarmanRose, with 4 replies.
Last reply by CarmanRose, over 8 years ago:
Thanks, it works!
My actor gets moved to the right edge if it hits the left edge
By Recorsi, with 2 replies.
Last reply by Recorsi, over 8 years ago:
I don't know why, but that fixed the issue. Thank you :)
how do i use a variable (not a method) in a separate class?
By i_made_this_account_to_ask_this_question, with 1 reply.
Replied to by Vercility, over 8 years ago:
<Code Omitted><Code Omitted>
Im trying to make my actor change when he turns:
By Kushaal, with 7 replies.
Last reply by Kushaal, over 8 years ago:
Thanks a lot, the problem is solved... I just used this code and it worked out:<Code Omitted>
Starting timer if boolean is true?
By Recorsi, with 13 replies.
Last reply by danpost, over 8 years ago:
Recorsi wrote...
Just to make it clear: if (boolean) is the same thing as ==true and if (!boolean) is the same thing as ==false, right?
I believe you got it right. if (!boolean) is also the same as != true.
Tick Speed in Greenfoot
By Agent40, with 1 reply.
Replied to by danpost, over 8 years ago:
You can change the speed of the scenario by moving the handle on the speed slider to the right of the Run button or you can set it programmatically (usually in the world constructor) using: <Code Omitted>
Problem dabei etwas an einem zufälligem Ort spawnen zu lassen aber auf bestimmten koordinaten nicht
By Iiuz, with 28 replies.
Last reply by Iiuz, over 8 years ago:
import greenfoot. *; public class Healkit extends Actor { long lastAdded = System.currentTimeMillis (); int randomX; int randomY; public Healkit() { randomX = Greenfoot.getRandomNumber (18) +1; randomY = Greenfoot.getRandomNumber (14) +1; } protected void addedToWorld(World world) { if (getOneIntersectingObject(Baum.class) != null ) getWorld().removeObject(this); } public void act() { long curTime = System.currentTimeMillis(); if (curTime == lastAdded + 20
When an object has hit an edge 8 times, have the object disappear
By Miguel.Valdez, with 20 replies.
Last reply by Vercility, over 8 years ago:
"I Googled it" is always a legitimate answer, assuming you Actually understood it and didn't just copy paste :P Aside from that, that's how I do it as well, for said reason but also because you can never know if there might be a mistake if you don't understand yourself
Trying to sync object with music
By Brantgarron, with 8 replies.
Last reply by danpost, over 8 years ago:
An act counter would be like this: <Code Omitted>The timer is incremented every act cycle and is dependent on the act cycles which varies time-wise from machine to machine. The '40' suggests something like 3 beats in about every 2 seconds. The '200' would be the number of beats in the entire song. Using the syst
He can touch, when he has score > 5.
By Findr, with 5 replies.
Last reply by Yehuda, over 8 years ago:
I wasn't sure which one to do, so I went according to the title and figured if there is a problem it will be mentioned, I didn't want to assume this information wasn't known.
Delay the entry of the first balls
By R0mane, with 8 replies.
Last reply by Vercility, over 8 years ago:
danpost wrote...
Vercility wrote...
Is that greenfoot specific? Because Im pretty sure int values are null by default, the compiler will also throw this when trying to use an uninitialized value (A fresh array of ints will also contain null everywhere, doesnt it.) << Code blocks omitted >>
The codes you gave are showing local variables being declared. That is not the same as the aforementioned instance field declared at line 27. Also, an array, regardless of the type of elements it will hold, is an object and an array field is an Object reference and therefore is null when declared and
Still problems with my timer
By Kolyma, with 3 replies.
Last reply by Vercility, over 8 years ago:
danpost wrote...
Vercility wrote...
If you want it to last 15 s use something like this << Code Omitted >>
Using
while
will halt the entire program as the timer runs. That behavior is rarely wanted. Also,
while
cannot be capitalized. @Kolyma, if you want your timer to run longer than 15 act cycles (probably about one-quarter of a second), you need to increase its initial value. Something like 900 act cycles would run for about 15 seconds. Change
%15
to
%60
in line 24 and change
timer
to
(timer/60)
in lines 17 and 26.
Hmm does it
Strange navigation of tank
By Timmy_11, with 5 replies.
Last reply by Timmy_11, over 8 years ago:
Thank you so much!!!! My tank now navigates reliably.
276
277
278
279
280
281
282
X