![]() ![]() |
| |||||||||
| Hotspots: Slides and Code TA Corner Comments? Announcements FAQ Static Webspace | ||||||||||
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() |
| You could break a single forward(n) into n instances of forward(1) with tiny delays between. I showed this in class, and there are posted examples of this technique already for both sections, so you didn't need to ask. Have a look at the posted code. It could answer other questions. Colin Potts |
| Though as a note, it's recommended you move more than 1 pixel at a time. Weird things occur when you try and move at angles for very small increments, because there is no such thing as a fraction of a pixel. Chris Phillips |
| Sure! But you can only use setVisible or hide to make the turtle become invisible immediately. If the background is a fixed color, you could change the color of the turtle gradually from its starting color to the RGB combination of the background. If the background is a picture with lots of local texture, you won't be able to do this easily because you won't know the color of the pixels under the turtle. Colin Potts |
| You want to have the time.sleep() calls at the points between the visible motions. So if you want to move one turtle and then another, you have two calls to time.sleep(). But if you want both turtles to appear to move together, move them both before you sleep. If you want to make them move smoothly by having them move a short distance (say a couple of pixels per call to forward), you will have to move the faster moving one further each time. Colin Potts |
| See previous answer. Colin Potts |
| Well, according to the directions, you must use either a .wav or a .aiff file and play it in JES, so this would not fulfill these requirements. Thanks! Brittany Duncan |
| This is something that you must find for yourself. If you search "Jython + turtle" on Google, that should put you on the right track. Thanks! Brittany Duncan |
| Check the slides and code page as well, it's on the turtle methods page. Chris Phillips |
| That's right. And while you're at it, you can change the height and width of the turtle independently, morphing its overall shape. You can even turn a turtle into a blob by making its body (i.e. legs and head) the same color as the background but leaving its shell visible. Experiment. Colin Potts |
| The most likely thing I can think of, is that your wav file is compressed. Use the link I provided in the bubble to convert it (from a wav) to a wav, and then in the conversion options, make sure that you have PCM, 22050 hz (22khz), 16 bit, mono, no noise filter. Provided it converts properly, you should be able to use the converted file (as it will be uncompressed). If that does not work, see a TA during office hours and let them figure out. Chris Phillips |
| No. You can't move the lines drawn by the pen after they're drawn. Think of it as a real pen. You can trace over it (with another turtle), you can clear the current path, and then retrace it (turtle.clearPath() to clear a turtle's drawn line), but you can't make the lines move. Chris Phillips |
| Make it in some way depend on the iterative variable in a for...range loop, or use the random function. For instance, you might have each turtle moving forward 5 times, but the amount is 5∗var, where var is the iterative variable (for var in range(...):). You can do a similar thing with turning.Chris Phillips |
| turtle.clearPath(). Chris Phillips |
| As mentioned below, findsounds.com has some wavs. However, you can convert pretty much any sound you have to a wav using the website mentioned in the bubble. Chris Phillips |
| Sounds like you opened the file, it defaulted to opening in Quicktime, then tried to save it from within Quicktime. Instead, on the webpage itself, either right click the link to the sound (the underlined blue thing), and choose Save Target As, or Save Link As, or similar, and then save the file somewhere, or, left click the speaker icon, and it should pop up a window asking you to either open the sound or save it. Choose to save it. If you're still having trouble, drop by a TA's office hours. Chris Phillips |
| It's a method. You call it using dot notation, with the turtle whose path you want cleared. You don't actually use 'turtle.clearPath()', unless you created the turtle in the variable 'turtle'. If you have a line that says, say, "bob = makeTurtle(world)", then you want "bob.clearPath()", to remove the path that 'bob' has drawn behind him. Etc. Chris Phillips |
| Afraid not. Either just play part of it (using playInRange()), or copy part of it to a new sound, and play that (using copy code demonstrated earlier in the semester), or, shorten the sound in another application, such as Audacity Chris Phillips |
| Talk to your grading TA on how to get it to them, if you absolutely must have the entire thing. Chances are good, though, that if the file is too large, then you're only playing a part of it anyway, and you could cut down the file size tremendously by using Audacity to remove the parts you don't need. Chris Phillips |
| You stop moving them. :P That probably wasn't the answer you were hoping, but there is no magical whenSoundStopsPlayingStopTurtlesDancing() function, I'm afraid (I wish). You're the one telling the turtles to move, and, more importantly, you're the one calling the time.sleep() functions. However much the time.sleep() function calls add up to, is (approximately) equal to the amount of time it will take the turtles to finish dancing. So if you call time.sleep(.1) 300 times in your function, you know that your music should only play 300*.1 seconds, or 30 seconds. You can either chop the sound to that length, or use playInRange() to make it play for only 30 seconds (as a warning, this function doesn't take in seconds, but rather starting and ending sample locations). Chris Phillips |
| Try just creating a world in the command area then, with "world = makeWorld()". If it still appears that nothing is happening, try ALT+TABing (or minimizing the JES window), to see if perhaps it's creating the world, but behind JES' main window. If it isn't, try a different computer, and see if it behaves differently there. It may be (though it seems unlikely) that there is some sort of weirdness specific to your computer. Chris Phillips |
| Sure. They also serve who only stand and wait (or sit and judge). Colin Potts |
They also serve who only stand and wait...tables. Chris Phillips |
| You have to drop a picture using a turtle created in the world. So, create a turtle in the world (for the point of later example, I'm going to assume you called it 'turtle'), hide it, put its pen up, have it move to the point 0,0, and then use turtle.drop(pic), where pic is a picture you've already made, with makePicture(). Chris Phillips |
| Any software that can resize an image will do. If you know of none, there is a tool on the software page of the coweb that can be used on a Mac to rescale the image. Chris Phillips |
| Umm...I'm not sure I'm understanding you. But, you'd make them small again with setWidth and setHeight. getWidth and getHeight only return the turtle's current width and height, they don't change anything. (You might use them if you wanted to, say, halve the height of every turtle in the world, and they're all different sizes, then you could set the width and height to what getWidth() and getHeight() return, divided by 2.) Chris Phillips |
| After making it smaller, try moving it forward one space, then back a space (no one will see it happen as long as you don't put a delay between the two movements). Due to how turtles are set to draw, sometimes the draw method isn't called properly. Moving has always fixed it in my experience. Chris Phillips |
| setPenWidth(x) where x is the width. This and many other useful methods are listed in turtle methods linked from the Slides/Code page. Colin Potts |
| Instead of moving each of the turtles in the list by a large amount one after another, move them a small amount on after another and repeat that sequence many times. Colin Potts |
| Can you just submit your code? If so, do that and send an email to your TA with your zipped picture/music as attachments. Colin Potts |