* Turn the headlights on when the key "space" is pressed. * Turn the car to the right every time the key "right" is pressed * Turn the car to the left every time the key "left" is pressed The method is called isKeyDown and is part of the Greenfoot class. Section 2: Keyboard Control Greenfoot allows us to determine if particular keys are currently pressed. In this chapter we will discuss each of these four concepts and how they work in Greenfoot. in front of the call to isKeyDown, since this method is defined in the. Again Greenfoot provides this capability for us. * Move the car back every time the key "down" is pressed Introduction to Programming with Greenfoot: Object-Oriented Programming in Java. * Move the car forward every time the key "up" is pressed From your Greenfoot lessons, the keyDown method is Mark for located in which class Review (1) Points Actor Greenfoot () GreenfootImage World Correct 41. But the important part that I am having trouble with is calling a method from the lobster to the Crab instance created by the CrabWorld. For your sake, Ill just post the well documented code for you to read. It contains 5 classes named Crab, Lobster, Worm, Counter, and CrabWorld. * Method that is being always invoked when the program is running Every time you eat a worm, the score goes up by 10. Sets the image that appears in the screen at the beginning to the one in file1 SetImage2(file2) // Sets the attribute image2 to file2 SetImage1(file1) // Sets the attribute image1 to file1 * Class that models objects of type "car" I would like to make something like ("up") and ("w") for moveForward(), ("down") and ("s") for moveBack() etc. I would like to move two cars differently one using "up", "down", "left", "right" for the car1 and "w", "s", "a", "d" respectively. Class Greenfoot greenfoot.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |