On execution it is finding that only the block class gets executed even though the leaf class is defined to perform its action in the world. The leaf is made to move in random across the world and the image of the leaf gets toggled. In the same way class Leaf is defined in such a way to make leaf blow across the screen. It checks between the images and keeps on changing the image according to the condition.īy investigating the above scenario it is found that the Class block defined, starts moving horizontally towards “right” till the end of the world and bounces back towards “left” until it reaches the either end. O The method “changeImage()” is used to toggle between the images. You should include sound for when the PLAYER wins the game. You should include sound for when the PLAYER catches or eats a FOOD. You should include sound for when the PLAYER is caught by the ENEMY. These can be either inbuilt or created by you. O The “act ()” method is used to make actor Leaf move randomly throughout the world. Sound: You should include sound effects that fit the theme of your game. O Class Leaf contains “act ()” is used to make the leaf move across the screen in random. The class “Leaf” is used to make leaf that blows across the screen. As the snake moves you can just increment over the array and change the points to take into account the direction of movement and how far to move.The method “checkMouseClick()” is used to check for the mouse button action that is performed.The method “checkEdge()” is used validate the edge such that it bounces back when reaches the edge.The method “move()” is used to make the block move sideways towards left and right. O The “act ()” method contains the following methods “move()”, “checkEdge()”, “checkMouseClick()”to perform certain action in the world defined. O Class Block contains “act ()” is used to move across the screen and, bounce off when it reaches the edges. The class “Block” is used to make the block bounce back and forth across the screen.O Method “Myworld” is defined and fix the size of the world The class “MyWorld” is used to define the world that is created. docx, 103.23 KB zip, 29.6 MB This is a full saving and making sounds lesson, via Greenfoot, is an easy to understand lesson with full teaching code, and completely editable.* If condition to make the leaf move randomly SetRotation(Greenfoot.getRandomNumber(360)) Speed = Greenfoot.getRandomNumber(3) + 1 generate random speed ranging from 1 to 3 GreenfootImage img2 = new GreenfootImage(" GreenfootImage img1 = new GreenfootImage("
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |