############################################
#Tool To show and test my animations #
#Written By Derek Mcdonald #
############################################
#Released under the following liscense: #
# #
# i dont give a shit what you do. #
############################################
import pygame, os, sys
from pygame.locals import*
from pgu import gui
#clock to keep track of shit
pygame.time.Clock()
#screen crap
screen = pygame.display.set_mode((640,480))
#def to control animation when play button is pressed
def Play(self):
print "Play"
#frame counter variable
CurrentFrame = 0
#variable for delay between frames
global FPS
FPS = 30
Frame = ["Frame1.png","Frame2.png","Frame3.png","Frame4.png","Frame5.png"]
#loop variable to control the animation loop
global AnimationLoop
AnimationLoop = 1
#number of frames to import, set to three by defualt
NumberOfFrames = 3
#AnimationLoop
while AnimationLoop == 1:
#refreshes entire display
pygame.display.flip()
#Change Frame to next frame and checks to see if its the last frame, if so reset the frames
CurrentFrame = CurrentFrame + 1
if CurrentFrame == NumberOfFrames:
CurrentFrame = 0
#whats a given time
pygame.time.delay(FPS)
#load our frames to memory
FrameData = os.path.join ("Frames",Frame[CurrentFrame])
DrawFrame = pygame.image.load(FrameData)
#Draw The Frame
screen.blit (DrawFrame, (320,240))
###########################################################
#defs for other buttons to controll stop rewind exit etc etc
def Faster(self):
FPS = FPS - 10
def Slower(self):
FPS = FPS + 10
def Stop(self):
AnimationLoop = 0
def Exit(self):
exit()
##########################################################3
#gui elements and gui setup
app = gui.Desktop()
app.connect(gui.QUIT,app.quit,None)
main = gui.Container(width=640, height=480) #, background=(220, 220, 220) )
#play button
PlayButton = gui.Button("Play", width = 50)
main.add(PlayButton,10,450)
#is the play button clicked?
PlayButton.connect(gui.CLICK,Play,None)
#Speed Up Animation button
FastButton = gui.Button("Faster", width = 75)
main.add(FastButton,75,450)
FastButton.connect(gui.CLICK,Faster,None)
#Slow down animation button
SlowButton = gui.Button("Slow", width = 50)
main.add(SlowButton,165,450)
SlowButton.connect(gui.CLICK,Slower,None)
#Stop button to stop the animation
StopButton = gui.Button("Stop", width = 50)
main.add(StopButton,230,450)
StopButton.connect(gui.CLICK,Stop,None)
#Exit button
ExitButton = gui.Button("Exit", width = 50)
main.add(ExitButton,570,10)
ExitButton.connect(gui.CLICK,Exit,None)
app.run(main)
###############################################################