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
Stalling an AI
By Samummy1, with 1 reply.
Replied to by danpost, over 6 years ago:
Samummy1 wrote...
I have code for an AI that I am creating for pong. I am trying to get it so that it will have to wait based on a small probability. If anyone has code or an idea on how to program this please reply
Add a timer field (outside any method): <Code Omitted>Give a wait time (in act cycles) to
waitTimer
on small chance (in
act
or in a method called from
act
): <Code Omitted>Do normal AI stuff only if waitTimer is zero; otherwise, do nothing more than chalk time:
Hit detection.
By Will5230, with 3 replies.
Last reply by danpost, over 6 years ago:
Will5230 wrote...
Sorry , could you be more clear? I tried to change signs in line 150 but that mixed up both of the sides.
Changing something in one should not effect the other at all. What is your new line 150? Show what you changed.
Updating Money score.
By DragonL68, with 16 replies.
Last reply by danpost, over 6 years ago:
DragonL68 wrote...
<Code Omitted>
The clickable objects are not shops, but, in essence, buttons. Their classes should extend the
Actor
class.
problem with "imageHeight has private acces in greenfoot.Actor"
By Andrees6, with 2 replies.
Last reply by Andrees6, over 6 years ago:
Thank you, it works :>
Problem with "Greenfoot.mouseClicked"
By Nahquin, with 38 replies.
Last reply by Nahquin, over 6 years ago:
Nvm find out it have to pic up minimum 1 apple
Returning values
By Rod53, with 1 reply.
Replied to by danpost, over 6 years ago:
You can only return one thing back to the calling method. If you require more than one
int
value to be returned, it must be wrapped in another object. For 2
int
values, you could return a
Point
object that holds two
int
s: <Code Omitted>or more simply an array: <Code Omitted>Just change the return type of the method from '
int
' to '
Point
" or '
int
' followed by empty square
maze
By BlueberryGaming, with 3 replies.
Last reply by danpost, over 6 years ago:
BlueberryGaming wrote...
i want it to swap worlds like if i finish world one and i reach end point it changes to world 2 or i am on finale level it ends game i am new to code
As you have basically said -- in pseudo-code: <Code Omitted>
Keep getting null pointer exception
By Will5230, with 5 replies.
Last reply by Will5230, over 6 years ago:
Thanks a lot!!
Animations
By Legitimacy, with 3 replies.
Last reply by danpost, over 6 years ago:
Nahquin wrote...
<< Code Omitted >> Try this
Best would be to put the image set, or their numbers, in an array and use a factor of the act counter to get the index of the current image: <Code Omitted>
Splitting up objects?
By CharBun, with 1 reply.
Replied to by danpost, over 6 years ago:
CharBun wrote...
if the planet size becomes over 25, it splits into tinier planets who go their own way. I tried modifying the code from the astroids (where the asteroids go half the size if they get hit by a bullet) but I got completely lost.
Just create two new Body objects, add them into the world at the over-sized body's location, set their vectors to that of the over-sized body and maybe turn them a bit in opposite directions; then remove the over-sized one. Well, it should be as simple as that, except for the fact that you cannot currently get the direction of a body -- you can
How to turn towards actor?
By 343qwm29, with 2 replies.
Last reply by 343qwm29, over 6 years ago:
Thank you for your help, and there is only one dancing queen so this works.
How to change hitbox (?)
By darkangel998, with 3 replies.
Last reply by danpost, over 6 years ago:
darkangel998 wrote...
<< Code Omitted >>
Cool -- I like the mix of blue and green in the user icon. I tested the code given and the hit box seems to coincide with the size of the actor as it grows.
Project Freezes
By Anonymous1313169, with no replies.
I finished one of my projects a few days ago and found out that when I export it to a JAR file, it freezes after about an hour of running. This problem does not appear on normal Greenfoot, just on the JAR file. I tried every technique I could think of, but it still freezes.
how to make power ups
By Mustafa405, with 6 replies.
Last reply by Mustafa405, over 6 years ago:
i have a question if i use the isTouching method once i move from the object will the actor return to normal or will it stay as the new actor edit:nevermind
How do you define WorldEdge? How do I make objects disappear under defined circimstances?
By Blyat, with 1 reply.
Replied to by danpost, over 6 years ago:
There is no method with that name listed in the
Actor class documentation
. The method you want is there, however.
222
223
224
225
226
227
228
X