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

danpost's Comments

Back to danpost's profile

@Watchb, absolutely.
@Peach, if the world was wide enough to hold them, it would be 24+38*i, 510. The world width would have to be about 1000.
@Peach, obviously it is a call to 'addObject', a method in the World class that uses the signature 'addObject(actor, int, int)'. The actor is a new Letter object that is being placed within the array of letters declared near the top of the class. This line is found within a 'for' loop that iterates 'i' through the numbers 0 to 25 (for each letter of the alphabet). Notice in the scenario how I split the 26 letters into two rows of 13 letters each. The first int (the x-coordinate of where to place the letter actor) is '24+38*(i%13)'. This says to start at x-coordinate 24 and add 'i' factors of 38 (the distance between each letter). Taking the modulus 13 of 'i' starts the factor back at zero again for the second row. The second int (the y-coordinate of where to place the letter actor) is '510+30*(i/13)'. This says to start at y-coordinate 510 and add a factor of 30 for the second row ('i/13' will return 0 until 'i' reaches 13; then it will return one for the rest of the loop).
@Watchb, the 'getGenericActor' method is within the Hangman class.
@Watchb, just run the scenario and click on the buttons near the top-right of the window to look at the classes.
@KellyEmmerich, click on the 'Run' button and click on one of the buttons in the top right.
@Watchb, in the middle section of the act method, you will see where I detect a keystroke, make it uppercase and call the 'letterClicked' method if the key is between "A" and "Z" inclusive. key.charAt(0) returns the ascii code value for the first (and only) character in the 'key' String object ('A' = 65 and 'Z' = 90); subtracting 65 from that gives a range of 0 to 25, which is the index of the Letter actor in the 'letters' array that contains the image of the 'key' letter. The 'letters' array contains the Letter actors that can be clicked on near the bottom of the screen. The Letters class can be found at the end of the Hangman class code.
@mandyg233, log in, click 'Run', move the mouse so that your button touches a smiley, click on a button (other that 'New Game') along the bottom of high score screen.
@Peach, did I do so? if not, then no.