diff options
author | slm <slm@slm-laptop.(none)> | 2010-06-15 19:17:55 (GMT) |
---|---|---|
committer | slm <slm@slm-laptop.(none)> | 2010-06-15 19:17:55 (GMT) |
commit | 896309ce593f066157b65d9e891834d7e4ea87f2 (patch) | |
tree | d6d077e6778220f021823440f6f448c1c9a9df89 /devtools/ScaleTypeTest/scaleTest.py | |
parent | 8106ee2dde014e33f17e6f945b52685ff18db99f (diff) |
Finished the Scale Test in the devtool/ directory.
Diffstat (limited to 'devtools/ScaleTypeTest/scaleTest.py')
-rwxr-xr-x[-rw-r--r--] | devtools/ScaleTypeTest/scaleTest.py | 163 |
1 files changed, 84 insertions, 79 deletions
diff --git a/devtools/ScaleTypeTest/scaleTest.py b/devtools/ScaleTypeTest/scaleTest.py index 7eab048..931f040 100644..100755 --- a/devtools/ScaleTypeTest/scaleTest.py +++ b/devtools/ScaleTypeTest/scaleTest.py @@ -1,14 +1,18 @@ -import sys, pygame, time +#! /usr/bin/env python +import pygame, time pygame.init() -print "Depreciated Scale Test - Authors Dave Silverman and Scott Mengel" +print "Scale Test - Authors Dave Silverman and Scott Mengel" print "Set size to 600 x 400 px" print "Running..." + + #-------------------------------------------------------------- #CONSTANTS AND VARIABLES make=input("How many images would you like to load? ") +trial=input("How many runs per trial? ") img={} ft="" #filetype r=0 #frame refreshes @@ -17,93 +21,94 @@ size = width, height = 600,400 #screen sizes t=0 #trial number n colorkey=(255, 152, 0) -ftArr=[ ["bmp","BMPs 16-Bits/"] , ["bmp","BMPs 24-Bits/"] , ["bmp","BMPs 32-Bits/"] , ["gif","GIFs/"] , ["gif","GIFs Transparent/"] , ["jpg","JPGs 1Low/"] , ["jpg","JPGs 2Medium/"] , ["jpg","JPGs 3High/"] , ["jpg","JPGs 4Max/"] , ["png","PNGs Indexed/"] , ["png","PNGs Transparent/"] ] +ftArr=[ ["bmp","BMP16100/","100%"] , ["bmp","BMP16173/","57.8%"] , ["bmp","BMP16200/","50%"] , ["bmp","BMP16400/","25%"] ,["bmp","BMP24100/","100%"] , ["bmp","BMP24173/","57.8%"] , ["bmp","BMP24200/","50%"] , ["bmp","BMP24400/","25%"] , ["gif","GIF100/","100%"] , ["gif","GIF173/","57.8%"] , ["gif","GIF200/","50%"] , ["gif","GIF400/","25%"] , ["gif","GIFT100/","100%"] , ["gif","GIFT173/","57.8%"] , ["gif","GIFT200/","50%"] , ["gif","GIFT400/","25%"] , ["png","PNG100/","100%"] , ["png","PNG173/","57.8%"] , ["png","PNG200/","50%"] , ["png","PNG400/","25%"] , ["png","PNGT100/","100%"] , ["png","PNGT173/","57.8%"] , ["png","PNGT200/","50%"] , ["png","PNGT400/","25%"] ] screen = pygame.display.set_mode(size) #Screen Set 600x400 background = 152, 251, 152 # pale green -#The switch function + #------------------------------------------------------------- +#The switch function + def chngImg(): - cnt=make - while cnt>0: - switcher = { - 1: pygame.image.load("%s2 Button.%s"%(ft[1],ft[0])), - 2: pygame.image.load("%s3 Button.%s"%(ft[1],ft[0])), - 3: pygame.image.load("%s4 Button.%s"%(ft[1],ft[0])), - 4: pygame.image.load("%s5 Button.%s"%(ft[1],ft[0])), - 5: pygame.image.load("%s6 Button.%s"%(ft[1],ft[0])), - 6: pygame.image.load("%s7 Button.%s"%(ft[1],ft[0])), - 7: pygame.image.load("%s8 Button.%s"%(ft[1],ft[0])), - 8: pygame.image.load("%s9 Button.%s"%(ft[1],ft[0])), - 9: pygame.image.load("%s1 Button.%s"%(ft[1],ft[0])) - } - img[cnt,0]=switcher.get(i,pygame.image.load("%s1 Button.%s"%(ft[1],ft[0]))) - img[cnt,0] = pygame.transform.scale(img[cnt,0],(20, 20)) - cnt=cnt-1 + cnt=make + while cnt>0: + switcher = { + 1: pygame.image.load("%s2.%s"%(ft[1],ft[0])), + 2: pygame.image.load("%s3.%s"%(ft[1],ft[0])), + 3: pygame.image.load("%s4.%s"%(ft[1],ft[0])), + 4: pygame.image.load("%s5.%s"%(ft[1],ft[0])), + 5: pygame.image.load("%s6.%s"%(ft[1],ft[0])), + 6: pygame.image.load("%s7.%s"%(ft[1],ft[0])), + 7: pygame.image.load("%s8.%s"%(ft[1],ft[0])), + 8: pygame.image.load("%s9.%s"%(ft[1],ft[0])), + 9: pygame.image.load("%s1.%s"%(ft[1],ft[0])) + } + img[cnt,0]=switcher.get(i,pygame.image.load("%s1.%s"%(ft[1],ft[0]))) + img[cnt,0] = pygame.transform.scale(img[cnt,0],(40, 40)) + cnt=cnt-1 + #----------------------------------------------------------------- -#Collision detection +#- Collision detection ------------------------------------------- def collision(): - cnt=make - while cnt>0: - if img[cnt,1].left < 0 or img[cnt,1].right > width: - img[cnt,2]=[ -img[cnt,2][0], img[cnt,2][1] ] - if img[cnt,1].top < 0 or img[cnt,1].bottom > height: - img[cnt,2]=[ img[cnt,2][0], -img[cnt,2][1] ] - img[cnt,1] = img[cnt,1].move(img[cnt,2]) - screen.blit(img[cnt,0],img[cnt,1]) - cnt=cnt-1 - pygame.display.flip() + cnt=make + while cnt>0: + if img[cnt,1].left < 0 or img[cnt,1].right > width: + img[cnt,2]=[ -img[cnt,2][0], img[cnt,2][1] ] + if img[cnt,1].top < 0 or img[cnt,1].bottom > height: + img[cnt,2]=[ img[cnt,2][0], -img[cnt,2][1] ] + img[cnt,1] = img[cnt,1].move(img[cnt,2]) + screen.blit(img[cnt,0],img[cnt,1]) + cnt=cnt-1 + pygame.display.flip() + + #----------------------------------------------------------------- +#- Number of dashed lined relates to loops ----------------------- + +while 1: + cnt=make + ft=ftArr[t] + print "Testing: "+ft[1]+" extension "+ft[0] + trialthis=trial + #----------------------------------------------------------------- + while trialthis>0: + + #------------------------------------------------------------- + while cnt>0: + img[cnt,0]= pygame.image.load("%s1.%s"%(ft[1],ft[0])) #image.load + img[cnt,0] = pygame.transform.scale(img[cnt,0],(20, 20)) + img[cnt,1]= img[cnt,0].get_rect() + img[cnt,2]= [2,2] #speed + m=cnt*40 # named m cause i wanted some m&ms + img[cnt,1]=img[cnt,1].move(m,m) #see? it wasn't as tastey though + cnt=cnt-1 + + #------------------------------------------------------------- + r=0 + start=time.time() + + #------------------------------------------------------------- + while 1: + chngImg() + i=i+1 + if i>9: i=1 + + collision() + screen.fill(background) + + r=r+1 + if r>500: break + + #------------------------------------------------------------- + print 1/((time.time()-start)/r) + trialthis=trialthis-1 + +#----------------------------------------------------------------- + t=t+1 + print "" + #----------------------------------------------------------------- #----------------------------------------------------------------- -while 1: - cnt=make - ft=ftArr[t] - print "Testing "+ft[1]+"N Button."+ft[0] - trial=5 - while trial>0: - while cnt>0: - img[cnt,0]= pygame.image.load("%s1 Button.%s"%(ft[1],ft[0])) #image.load - img[cnt,0] = pygame.transform.scale(img[cnt,0],(20, 20)) - img[cnt,1]= img[cnt,0].get_rect() - img[cnt,2]= [2,2] #speed - m=cnt*40 # named m cause i wanted some m&ms - img[cnt,1]=img[cnt,1].move(m,m) #see? it wasn't as tastey though - cnt=cnt-1 - r=0 - start=time.time() -# ----------------------------------------------------------------- - while 1: - chngImg() - i=i+1 - if i>9: i=1 - - for event in pygame.event.get(): - if event.type == pygame.QUIT: sys.exit() - -# speed1=collision(ballrect1,speed1) -# ballrect1 = ballrect1.move(speed1) - - collision() - screen.fill(background) - -# cnt=make -# while cnt>0: -# screen.blit(ball1, ballrect1) -# screen.blit(img[cnt,0],img[cnt,1]) -# cnt=cnt-1 -# -# pygame.display.flip() - - r=r+1 - if r>500: break - -# ----------------------------------------------------------------- -# ----------------------------------------------------------------- - - print 1/((time.time()-start)/r) - trial=trial-1 - t=t+1 |