![]() ![]() * key and a sound file, which is played when the key is pressed. ![]() ![]() * This method makes the below keys when compile is hit or the program opens.ĪddObject (new Key ("g", "3a.wav"), i*63 + 54, 140) * A piano that can be played with the computer keyboard. Import greenfoot.* // (World, Actor, GreenfootImage, and Greenfoot) Here is the code example from the piano class: I am confused in general how the program knows that the keys are set from left to right in the first place. The remaining keys should be next to each other, with no space between them." Rewrite it (in this document only-not in your working Greenfoot program) to create the keys from right to left, instead of left to right, and force the rightmost key to be flush against the right side of the screen. With this information in mind, copy the new loop code you entered to correctly place the keys in the space below. Recall that the piano is 800 pixels wide. "According to the text, Greenfoot refers to objects by the midpoint of their lengths and widths. I am working on exercise 5.18 (not the same as the book example) and it says: * Alternate the crab's image between image1 and image2.I am working on my assignment for school and this question has thrown me for a loop, no pun intended, this chapter is about loops and arrays. * Act - do whatever the crab wants to do. Image2 = new GreenfootImage("crab2.png") * Create a crab and initialize its two images. Scenarios Tutorial 4: Saving the World, Making and Playing Sound This tutorial will explain how to initialise the world with actors, as well as how to play and record sounds. I need to create a counter within the act method that changes the image every time it reaches 3, then resets itself to 0. I am new to Greenfoot and was hoping I could also get some assistance with the mentioned book problem. * Return false if there is no such object here.Īctor Mydog = getOneObjectAtOffset(0, 0, clss) * Animate dog by switching between images. * Check whether a key has been pressed and if so move the dog accordingly. * I sleep for a specified length of time and snore too! * This dog gets sleepy when its energy hits 20 and needs to walk slower. Force the player-controlled Dog to fall asleep when its energy reaches 0, and once it wakes up, set its energy to 100.įor (int counter = 0 counter < 1 counter++) Make the player-controlled Dog move more slowly whenever the method isTired returns a value of true.Ä£. Write a loop that subtracts one from the Dogâs energy for every 30 steps that the Dog takes. It all compiles but it just won't do what I want.Ä¡. I also need to make the dog interact with other dogs in the world but I can't get him to. I have a counter but it doesn't seem to count. When he is sleeping I need his energy to replenish. I am trying to make the dog sleep when his energy reaches zero but I can't get his energy to deplete. Hello, I am trying to do the same scenario and I am stuck at the same point that rgadue was at. * Look for stationary dogs and greet (bark) when interacting. * Return true if we can see an object of class where we are.Īctor actor = getOneObjectAtOffset(0, 0, clss) Ah i see, hmm it says expected after the Volume in setVolume.* Dog moves north, south, east, west, northeast, northwest, southeast, and southwest. GreenfootSound sound new GreenfootSoun ('GunShoot2.wav') // create a sound object tVolume (25) // adjust the volume of the sound ay () // play the sound. * This dog gets sleepy when its energy hits 20 or lower. * the 'Act' or 'Run' button gets pressed in the environment. To gain more control over the music, you must create and retain a GreenfootSound object in a field so you can call methods of the. It will only stop when you re-compile or leave the app. ![]() * Act - do whatever the MyDog wants to do. Download Greenfoot for free: runs on Windows, Mac and Linux The Book Introduction to Programming with Greenfoot is the official book used by both teachers and students The Greenroom. If you are using aySound ('Theme1.mp3') to start the music, then because you do not retain a reference to the sound, you cannot stop it. Make the player-controlled Dog move more slowly whenever the method isTired returns a value of true.Ä¡0.Äorce the player-controlled Dog to fall asleep when its energy reaches 0, and once it wakes up, set its energy to 100. Write a loop that subtracts one from the Dogâs energy for every 30 steps that the Dog takes.Ä©. I got it to compile and now I'm struggling with my next step.Ĩ. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |