This site requires JavaScript, please enable it in your browser!
Greenfoot back

danpost's Comments

Back to danpost's profile

@Peach, please refer to the following webpage: http://docs.oracle.com/javase/8/docs/api/java/lang/Object.html
The 'word' field is declared third from last before the Hangman class constructor.
danpostdanpost

2014/4/30

In your Ball class act method, you have three separate 'if' blocks, each with a 'setLocation' statement that will move the ball. When more than 10 off the bottom only the middle one will execute. When within then and not at the bottom, the first and third will execute. When at the bottom, all three will execute. That is why your ball speeds up when it is 'rolling' at the bottom.
@Peach, they are just field declaration statements for the array of words and the random number generator which is used to produce a random index for the word in the array to use in the puzzle. Getting the current time produces a 'random' seed for the random number generator. Check the java.util.Random API documentation for additional information on this type of Object. Having these field as 'static' causes them to be set prior to any Objects being created from the class (actually, they are created during compilation; and resetting does not alter them); and as these two fields will not change throughout the running of the scenario, they should probably be made 'final' as well.
What about arrays '[ ]'?
@Peach, I do not have separate classes for each body part; however, even though they are created from within the Letter class, they are not Letter actors. In fact. they are not of any particular type of Actor (they are un-named, or generic). I felt no need to place them in separate classes as once they are drawn, their type is un-important (no collision checking or anything would need to know what class they are) and there is no further action for them to take (no act, fields or methods). Their only purpose is for image display and there was only a need for Actor class methods to accomplish that. Look at the 'getGenericActor' method, which is used to return a new generic Actor object. Also, look at some of my other recent uploads and view the codes within them for more examples of creating these un-named Actor object; as well as some that are named, but coded within another class (inner classes).
@AIMrOrange, it is possible the the UserInfo server was down and therefore the scenario was acting like you were not logged in.
AIMrOrange, your player object has two numbers in it. The top number is the number of hits remaining before you die (your color will turn more red as the top number decreases) and the bottom number is your score. Also, if you log in and play, your high score will be saved and the high scores/stats will be shown.
Now with viewable source from Stats world (which means you must be logged in and the game must have ended).