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
Bullet Hoses
By ZacBuzzsaw, with 3 replies.
Last reply by danpost, over 9 years ago:
@SPower, I see where you see an assignment symbol ( '=' ) in place of a conditional equality symbol ( '==' ); however, it will never actually change the value there as it was just set to 'true' in a previous line. What this means is that the question does need to be asked. Removing lines 9, 10 and 14 will not change what the code does. Also, a timer is not what ZacBuzzsaw is going to need -- a boolean field is indeed what is wanted (like the 'isShot' field), but the way it is used is incorrect (hence, its name is also misleading). The field should track the state of the "space" key or shou
Using getImage().mirrorHorizontally()
By moretinshop, with 2 replies.
Last reply by moretinshop, over 9 years ago:
Thanks for your help, I ended up using a solution similar to the one found in this thread: http://www.greenfoot.org/topics/200 BTW, lines 11-15 do not work without a method, the linked thread uses a for loop to do something similar.
stopGame problem
By smcgee, with 10 replies.
Last reply by smcgee, over 9 years ago:
I appreciate that - you do great work and so many benefit from your contribution to teaching future programmers.
Why wont this make a triangle?
By flash007, with 1 reply.
Replied to by danpost, over 9 years ago:
For one thing, once the method has completed its execution, the 'bg' variable is lost. By creating a
new
GreenfootImage object, you are not dealing with the image returned by the use of 'getBackground'. but making a copy of the background image.
Problem with Space Invaders!
By Yvonne, with 4 replies.
Last reply by danpost, over 9 years ago:
Yvonne wrote...
I am not sure why the Aliens are not shooting. Is the code wrong?
The 'shoot' method in the Alien class is not being called at all. You should probably have it called from the act method under some random condition.
World not being constructed, no zero-argument constructor available?
By moretinshop, with 2 replies.
Last reply by moretinshop, over 9 years ago:
My hero <3
Delay method creating problems with objects moving after spawning
By CrimsonGuitarist, with 3 replies.
Last reply by danpost, over 9 years ago:
@SPower, if it is done the way you suggest, there will have to be a way to determine beforehand which note is to be added when one is to be added. That means the a representation of the order of notes and the wait time between them must be listed in a string or with the use of one or more arrays or lists. My suggestion for this is to use a song string that has letters for the notes and numbers for the times. The numbers can be reduced to one digit numbers by dividing the wait time by a common factor (in the code given by CrimsonGuitarist, that factor would be 25). Then the playSong code wo
How do I close one world and open another?
By senga9872, with 1 reply.
Replied to by Super_Hippo, over 9 years ago:
It could be like this in the start screen act method: <Code Omitted>
How can I stop a counter from counting once it has reached a certain number?
By Sonarwave, with 6 replies.
Last reply by Sonarwave, over 9 years ago:
Hey guys, I'm sorry to say that the code here didn't work :( but on the bright side, a friend of mine helped out and it is all fixed. thanks for everyone's efforts in helping :D
Pacman Game
By JayHawk, with 5 replies.
Last reply by danpost, over 9 years ago:
JayHawk wrote...
now how do i get a actor to randomly move?
For a pacman ghost, you would do something like this: (1) turn to face current direction moving (2) move (3) determine and list possible directions to proceed from new location (4) randomly choose a direction from the list (5) set possibly new current direction to move as determined by random choice in (4) (6) reset rotation back to zero
How to apply gravity and air resistance?
By Michael1000, with 10 replies.
Last reply by danpost, over 9 years ago:
I have written a support class for smooth movement and rotation that has a subclass to apply gravity and drag (air-resistance). They are both included in my
GQActor Superclass Demo
scenario.
How to make text appear and conter
By prifkin, with 2 replies.
Last reply by danpost, over 9 years ago:
prifkin wrote...
I need a way so when the if statement executes, I can make a line appear that says"Press space to respawn". Also, how can I make a counter that every time I collect a certain object, the counter goes up. This should be a visible counter.
These are both a matter of displaying values (one is an integer value and the other is a string value). You could check out my
Value Display Tutorial
to see how this can be done.
Help with parallel strings!
By jpcp8000, with 5 replies.
Last reply by danpost, over 9 years ago:
jpcp8000 wrote...
I cant see what line 34 should be. can you repost it?
It was this: <Code Omitted>That probably shows the same way however. It can be re-written like this: <Code Omitted>
Pacman
By sultan.haider95@gmail.com, with no replies.
The Ghosts must pose a threat to Clara, and as such, they must kill her if they catch her. In order to do so, you will need to check if they have collided with Clara. To do so, you will need to use the methods “intersects(Actor)”, “getClara()” and “makeClaraDead()” inside the Ghost class. Clara will need to use the method “isClaraDead()” to signal that the game is over. It is important for the Ghosts to be continually checking whether they have caught Clara, and it is important for Clara to check whether she is dead to prevent further movement and animation. Once you have Clara capable of checking whether she is dead, you will need to show the appropriate death image, with Clara’s method “animateDead()” and play the appropriate sound with the method “playClaraDieSound()”. It is important that the method “playClaraDieSound()” is only called once. It is also important that you stop processing keyboard input from the player at the point of Clara’s death. Note that Clara’s “animateDead()” method only contains one frame, and so it is acceptable to run it every time the act method is called after Clara is dead. Part 10 – Eating Mushrooms and Making Ghosts Eatable Clara will need to able to eat mushrooms and get her super power. In order to do so, you will need to use methods “onMushroom()” and “removeMushroom()”. Then you will need to appropriately place the method “makeScared()” when Clara has eaten a mushroom. The Ghosts will need to check whether or not they should be scared, and switch to the appropriate animation when they are. You will need to use the methods “isScared()” and “animateScared()”. Note that the “animateScared()” method will need to be run every so many times that the act method is called, just like the “animate()” method. It is acceptable, but not compulsory to increase the Ghosts’ speed when they are scared, but they should be slower than Clara. You will then need to ensure that the Ghosts don’t kill Clara when they collide with her if they are scared, and instead, die themselves. It will be up to you to create your own variable that checks if the Ghosts are dead. You will need the “animateDead()”and “playGhostEatenSound()” methods. It is important to note that the Ghosts do not stop moving when they are dead, and that the Ghost’s “animateDead()” method will need to be run every so many times that the act method is called, just like the “animate()” method. It is also important that the Ghosts should not harm Clara when they are scared or when they are dead. Also note that the game will automatically decide how long the Ghosts should be scared for. Part 11 - Ghosts and Regeneration When a Ghost is dead, it will need to return to the Ghost Healer, which is the red object near where the Ghosts start. It will be up to you to decide how they should logically make their way back to the Ghost Healer object. You will need to use the “isAboveMe(Actor)”, “isBelowMe(Actor)”, “isToMyLeft(Actor)”, “isToMyRight(Actor)” and “getGhostHealer()” methods to make this happen. Note that the “isAboveMe(Actor)”, “isBelowMe(Actor)”, “isToMyLeft(Actor)”, “isToMyRight(Actor)” methods need to be sent an Actor, and that only two are available to you, through the “getGhostHealer()” and “getClara()” methods. You will need to send those ‘get’ methods to the ‘is’ methods in order to get an appropriate answer. An example of how to use the above functions is below: “isAboveMe( getGhostHealer() );” If the above example returns true, then the Ghost Healer is above the Ghost. When the Ghost returns to the Ghost Healer object, it will need to make itself no longer dead. You will need the “intersects(Actor)” and “getGhostHealer()” methods to make this work. How do you do this PART? Stuck at these three
'Run' Problem
By Ty1erH00ven, with 2 replies.
Last reply by danpost, over 9 years ago:
Some things you could do: (1) add a 'Greenfoot.start();' line in your initial world constructor so the user does not have to press the 'Run' button at all; (2) add a 'public void started()' method to your initial world class and remove the button so that pressing 'Run' starts the first level;
Ty1erH00ven wrote...
Or at least a way I can press 'Run' then 'Start'?
This is what you should already have.
Ty1erH00ven wrote...
I don't want to have to press 'Run' then 'Start' then 'Run' again just to play
Unless you have a 'Greenfoot.stop();' line in one of your world class construct
459
460
461
462
463
464
465
X