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
Death Condition
By aprianil, with 5 replies.
Last reply by danpost, over 10 years ago:
JonSkyWalker wrote...
So the code you gave should work? but we need to add an instance int field in the class of the enemy?
This is an internal counter here. In your case, I thought you had a healthbar that is shown. The healthbar might have the instance int field in its class.
HP Decrease and Death Condition
By JonSkyWalker, with 5 replies.
Last reply by danpost, over 10 years ago:
You already have the Veylectra object as an Actor object called 'badguy'. You should get the healthbar from it. Something like this: <Code Omitted>
Time Counter
By Babyhoof, with 1 reply.
Replied to by danpost, over 10 years ago:
Babyhoof wrote...
I am trying to make an edited version of asteroids that instead counts the time you have been alive. Is there any way to do this?
Yes. You can have two counter fields -- one to track the act cycles and one to track "seconds" (or groups of act cycles -- usually around 55 per second). So every time the act counter reaches 55 add one to the timer and reset the act counter back to zero. You can use a simple actor object to display the time elapsed. This is discussed in my
Value Display Tutorial
scenario.
health
By Walker, with 2 replies.
Last reply by valdes, over 10 years ago:
I recomend you add an integer field, not boolean. After the declaration of your class, put private int health = some_number; this number will be the initial health of your Actor. In the if (), decrease the value of health. Example health--; Then you will have to add another if in the act() method to check if the Actor is dead and end the game. if (health <= 0)
Hair-pulling error, please help?
By thesaltyhobbit, with 2 replies.
Last reply by thesaltyhobbit, over 10 years ago:
Thanks!
why is my game skipping round two
By divinity, with 15 replies.
Last reply by danpost, over 10 years ago:
divinity wrote...
as soon as i fixed everything else i will delete the junk codes and dem
At least remove lines 224 to 233. If execution makes it to that 'while' loop, it will run forever (an infinite loop) as the value of 'wrongcount' is not incremented within that loop.
How do i use getObjectsInRange with enemy facing a certain direction, depending on what side they are on the character
By FutureCoder, with 6 replies.
Last reply by FutureCoder, over 10 years ago:
Thanks, it works now.
how to make my actor move per cell?
By Raftiana, with 3 replies.
Last reply by danpost, over 10 years ago:
You have your 'stepCounter' field getting assigned a value less than 100 at line 14. Now, the modulus ('%') result on that value will be zero on any number greater than or equal to 100. Therefore, the conditions on lines 25, 29, 44 and 47 will be true every time, It would be better on your 'if' statements to use the following format (this example would replace line 47): <Code Omitted>But the number compared with should be one that the field could possibly have assigned to it (a number less than 100).
How do i creating object on a random time but in the dafult coordinate
By Raftiana, with no replies.
we stuck on creating object on a random time but we put the default of coordinate. everytime press "run" it always creating the same object and it pile up . the object i use in this scenario is "coin" and "meteor". the code on space : <Code Omitted> The code on Controller : <Code Omitted> this Mockup Game that i meant : <Image Omitted>
How to make an Actor climb a ladder in greenfoot?
By Ed_Hazza, with 19 replies.
Last reply by FutureCoder, over 10 years ago:
They're extremely similar, but stride is a lot easier, because instead of typing a bunch of counters, and write the code for up and down, you can just type in jump().
Car not striking wall
By aamir1, with 2 replies.
Last reply by FutureCoder, over 10 years ago:
danpost is right, but if you want the game to stop, You need to write canMove(); in 'public void act' for it to work
object is hiding behind image
By madan, with 2 replies.
Last reply by FutureCoder, over 10 years ago:
You need to remove the car object, then add it in again and save the world, that should solve the problem, without have to put in any code. If the finishing line is added to the world while the code is running, it won't work, it has to be in the world from the very beginning, before it starts to run.
Animation method
By orangutan, with 6 replies.
Last reply by valdes, over 10 years ago:
If you say that animation() works, then I think the error is this: In the code you show, <Code Omitted> is not initialized. In the constructor <Code Omitted> add <Code Omitted>or change the call to <Code Omitted> and delete the variable numOfImgs_KanyeIdle
Getting music to stop when world changes
By EK021, with 1 reply.
Replied to by danpost, over 10 years ago:
Out of curiosity, what code do you have in the Back class?
Label size
By zobear888, with 4 replies.
Last reply by zobear888, over 10 years ago:
Thank You!Here is the url to my finished game! http://www.greenfoot.org/scenarios/16534
473
474
475
476
477
478
479
X