Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Homework 6 Questions- Spring 2008

Ask any questions, comments, or concerns about Homework 6 here.


READ BEFORE YOU ASK!
You can convert files, resize/crop sounds, etc, using Audacity.

If you just want to convert a file to a wav, you can do so without having to install any software using http://media-convert.com/



how can you make it so you actually see the turtle move, rather than just jump forward?
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

is there anyway to make a turtle disappear gradually?
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

Is there a way to make two turtles move at the same time but different distances? I'm trying to make two turtles begin moving at the same time and move at the same speed, but have turtle1 move backwards only 20 pixels and then stop while turtle2 moves forward 50 pixels (it will move the last 30 pixels after turtle1 stops).
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

Everything I try and do just has the turtles either move at the same time but with one turtle going much faster than the other or has only one turtle move at a time.
See previous answer. Colin Potts

I want to use a song from rent. how should i go about doing this? i dont have it on cd. could i tell the program to pull up a website (youtube) and comment in the beginning that the ta should press play on that before they run the program?
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

How do you change a turtle's size?
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

I have a song I want to use, but I keep getting the error "The error was: Exception during load of file /Users/kellyjones/Desktop/zzzhw6/lion22m.wav
I wasn't able to do what you wanted.
The error SoundException has occured
SoundException: Exception during load of file /Users/kellyjones/Desktop/zzzhw6/lion22m.wav"

Do you know the cause of this? I am thinking my file is too large. If so how can I clip the song on a mac to make it shorter?
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

is there a way to make the pen drawings move it once they're drawn that's it...
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

Do you have any recommendation on how to mass produce turtles to do a semi unique movement? I am trying to mess around with the for statements, but I'm struggling.
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


I have lines between turtles, and then I make all the turtles come to the middle. I want the line to disappear when they come to the middle, but penUp is not erasing these lines. I also tried redropping the picture and then penUp, but the lines are still there when the turtles move to the middle. Do you have a suggestion on how to make the lines disappear when the turtles go to the middle?
turtle.clearPath(). Chris Phillips

Where can we download wav files?
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

This is probably a really dumb question, but I am not very computer savvy. I went to the findsounds.com website and managed to find a sound that I like, but I'm not sure how to download it to my computer. I tried right clicking and selecting "save as source" but then I get a pop up box saying that I have to buy QuickTime Pro. How do I get around that?
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

How is the clearPath() function supposed to be used? I tried turtle.clearPath() and clearPath(turtle) and neither of the two worked.
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

Is there a way to stop playing a sound?
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


What if our song file is too big for tsquare to upload?
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

How do I make the turtles stop moving when the music stops playing at the end?
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

I can't get my world to appear for some reason? even when I just practice with the example online.
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

I am doing turtles dancing to the waltz. I have two couples, so four turtles and then three judges which just sit there and announce scores. I know the homework says 5-10 turtles but is what I have OK?
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

now a world is showing but it is blank rather than dropping the picture I have chosen. I have already set the media path...so I don't know why it is like that?
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

how do I change the dimensions of a picture on a mac? my world comes up too big...
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

nevermind..teehee

I want my turtles to get big and then small so I made the height the height and width larger by using setWidth and setHeight; however, when I try to make them small again by using getWidth and getHeight it doesn't work, the turtles just stay big...what am I doing wrong?
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

I meant set instead of get, the problem is it either gets big and small instantaneously when run back to back or won't get small if I add in a short sleep or any other function
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

How can I make the pen wider?
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

Is there a way that I can make multiple turtles move at the same time? I want them to move as line but they just go in order of my list.
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

I can't submit on t-square...it is saying that my limit of 400 has been exceeded....
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



Link to this Page