2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by SgtMe
0

You would want some kind of input for detecting whether the user wants to go left or right. Consider using a loop to load the images into an array. For example, if you have the following file structure.

-main.py
-Pictures:
     -pic0.png
     -pic1.png
     -pic2.png
     -pic3.png

You could load the images like so:

import pygame
from pygame.locals import *

pygame.init()

print 'ENTER HOW MANY IMAGES IN GALLERY'
n=int(raw_input())


Pics=[]
BasePath="./Pictures/pic"
for i in range(0, n):
	print i
	Pics.append(pygame.image.load(BasePath+str(i)+".png"))
	print Pics[i]

I've attatched a Zip with the stuff in it so you can take a look if you want. I used pygame just for the image loading. The actual part of the program that loads images into the list is very short.

I even included asking the user how many images there were. However, you will need to be able to check for an error if the user puts in a value of n that is greater than the amount of images in the pictures folder or wherever.

You should have a variable which determines which number image you are on. This number should obviously change with user input (left or right adding or subtracting one), but making sure that when you hit zero, going down will make you go up to the top number, and when you get to the top, going round to zero again.

With regards to entering how many pictures are in the gallery, you can easily relate this to the range in my for loop.

Write out a code that works, then check back through and make it shorter. "Ooooh I could use a for loop there"..."I don't need that bit"...etc.

That should be plenty enough to get you started. Check back if you need more help :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.