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 Summer 2006

Questions:

*chirp, chirp*

said the little birdie ...

Actually, I believe the intent was cricket noises, in reference to the silence of this page.

Usually people ask questions which are somewhat related to the hw on this page. Is the hw just too easy or is it so confusing you don't know which question to start with? - Bobby Mathew

How's about we actually post homework questions so everyone will stop complaining and work on it?

In the sample code, when I try to change the code from "repaint" to "writePictureTo" JES only creates ONE file, and constantly updates it as it scrolls across. So instead of 100 frames, I get 1 frame updated 100 times. How can I make the program write out each frame as it updates it?
Put the writePictureTo statement inside the loop, and make sure you're renaming the new file, otherwise it will just copy over. Example: writePictureTo(c, directory + "//frame" + str(frame) +".jpg") - Bobby Mathew

Any helpful hints about how to make a "list of sprites" and have them recycle and copy throughout the code?
Just load each sprite and add it to a list. Example: sprites = [makePicture(...........), makePicture(.........), ...]. To recycle them, switch the order of the sprites around within the list. - Bobby Mathew

If the sprites and the "recycling" of the sprites are in the for loop, then won't they copy onto each frame, or should I make a new for loop just for the sprites?
You should load all the sprites before the nested loops. The sprites should be in a list. Inside the nested for loop you have to use only one sprite. Once the loop is over, you have to put a statement to update the sprite outside the inner loop but still within your frames loop. - Bobby Mathew

Is there a function like addPic() or something like that, that would add both my background and my sprite into one picture??
No, but when you make a frame with the background image on it, you can just call another function that puts your animated person on the same frame at a certain position. - Bobby Mathew

im using megaman, how do you get the boerder around him to disappear and coincide with the mario background?
Use the distance function to check the color of the picture and the color you want to remove (in this case its green). - Bobby Mathew

when your talking about recycling of the sprites and making a statement to update, is it an if statement or like a sprites + 1 type of deal, and if its an if statement whats a hint on how to write it?
You can update sprites a number of ways. The one I was talking about doesn't need an if statement. Just rearrange the order of the sprites within your list so that the first one is always different. Example: When I'm in my loop and I want to use one sprite, I'll use sprites[0] (sprites is my list which has all the sprites). Before I go through the loop the next time, I'm going to rearrange my list so that sprites[0] is different. - Bobby Mathew

Can you tell us what the grading TA will type in to execute the function?
You have to submit the background image and the sprites on webwork. So, we'll put all the sprites and pictures you used in a folder. You can use either makePicture(getMediaPath("pic1.jpg")) or makePicture(directory + "pic1.jpg") to get your sprites into JES. So, we would use either setMediaPath() or pickAFolder() and after that we would do >>> movieFun(dir) where dir is a directory we choose. - Bobby Mathew



can we use the copy function to put our sprite on the background (like in hw2 with the mirroring) or do we use another method
You have to use something similar to a copy function to do it. - Bobby Mathew

whats happening when i am changing my character and not the border around him in my chromokey?
I don't know what that question means. Please rephrase it. -Bobby Mathew

when i have my if statement with distance trying to match the border of my background and megaman background and look at my frames when im done i notice that megaman has changed (he's now blue) and not the annoying green border i was trying to get rid of.
You need to check the distance between the color of the sprite and green, not with the color of the background. If the distance is not big enough, then it won't copy over.- Bobby Mathew

doesnt seem to work, but here is what im trying to do and i found the border of mario to be (0,255,0)
 for p in getPixels(sprites[0]):
         if distance(getColor(p), green) <= 20:
            setColor(p, getColor(getPixel(sprites[0], getX(p),getY(p))))

Supposing both the colors you're comparing are green, the distance would be zero, which is fine based on your 'if' condition. Change your condition to > 20 and it might work providing the rest of the code is right. - Bobby Mathew

if that doesnt work what could be wrong
I'm not sure how your code is set up. Try messing around with it. If you can't get it, email your code to your TA. - Bobby Mathew

and how exactly does the sprite recycling work?
The easiest way of doing it is just switching the order of the sprites in your list, so that sprites[0] is always different every time you go through the loop. - Bobby Mathew

hey i dont really know how to start, give me at least a hint......maaaaaaaan i dont think i like this class, glad is the last lab
Look at the sample code, in the end you are just copying a picture onto another picture and doing it 100 times. -Albert d'Heurle

im still having trouble updating teh sprites, if its just outside the mini for loop for copying do we also have to refer to it some way in the copy loop or should it just be in there once outside the copy loop? (which for me doesnt work)
The updating sprite for loop should be under the main for loop that loops through all of the frames. Each time you creat a new frame you want to use a different sprite. -Albert d'Heurle

Quick question: Jython doesn't like my sprites function that is outside the main function. It doesn't like the way I've assigned a variable to the directory with my sprites. How can I assign a variable to a directory without hard coding it to my computer? I have tried: spritesdir=r"//john_cleese_" and then tried the for loop (for file in os.listdir(spritedir): Is the whole idea wrong?
I would try using getMediaPath() to give the location of the sprites. Remember when you use getMediaPath() you also have to use setMediaPath() before you run your program. -Albert d'Heurle

How do you copy each item in a list (spritelist) to a frame? getPixels,setColor, etc. don't work.

in the sample code, what is the "w" and "h" in def scrolly(pic, w, h)?

nevermind, i'm retarded

how do i resize the background image?

you would think a TA would get on within 1 1/2 hrs of the deadline.....