s1famej
가입: 올린 글: 7
|
올려짐: 2010 2월 09 11:07 am 주제: 고수님들 Picture Viewer만들기라는데요... |
|
|
Picture Viewer를 만들라는데요....
교수님이 이런식으로 만들라고 써놓으셨습니다..
고수님들 도움부탁드립니다.
•Use the caption at the top of the screen to inform the user to "Press f for Frame, p for pictures" Use pygame.display.set_caption(...)
•When f is clicked, use pygame.draw.rect(...) to draw a frame. You can get creative as follows:
for i in range (1,20, 2):
#draw an unfilled square
pygame.draw.rect(background, (255,0,0), ((200+i, 100+i), (300, 300)), 15)
pygame.draw.rect(background, (0,0,255), ((200+i+1, 100+i+1), (300, 300)), 15)
.. or you can just use a thicker line
•Each time the user presses the p key, the slide show progresses to the next image in sequence. You can store references to the images in a list, like this:
myFaceList = ["Neil1.jpg", "Neil2.jpg", "Neil3.jpg" ]
Here is a trick for cycling through a list. Below, myFaceList is the list and faceIndex is the list index.
... a loop for cycling through the slide show ..
myFace = pygame.image.load(myFaceList[faceIndex])
myFace = pygame.transform.scale(myFace, (280,280))
myFace = myFace.convert()
faceIndex += 1
faceIndex = faceIndex % len(myFaceList)
The modulus operator (in Python this is the % character) takes care of returning the index to 0 when it goes out of bounds. |
|