diff options
author | olpc <olpc@xo-10-A7-93.localdomain> | 2010-06-15 16:13:58 (GMT) |
---|---|---|
committer | olpc <olpc@xo-10-A7-93.localdomain> | 2010-06-15 16:13:58 (GMT) |
commit | 299d4792e4859ef6540a75fd277ba60a92540f69 (patch) | |
tree | a99b71134bebfd1c068fe80236c1b1982b2db7a5 /devtools/SpriteTypeTest/JPGs 4Max/bounce.py | |
parent | 7972356e06aa7b29fdf42ed6844e7b4f61c02ef1 (diff) |
Previous entry incorrect, this push adds new directories and files
Diffstat (limited to 'devtools/SpriteTypeTest/JPGs 4Max/bounce.py')
-rwxr-xr-x | devtools/SpriteTypeTest/JPGs 4Max/bounce.py | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/devtools/SpriteTypeTest/JPGs 4Max/bounce.py b/devtools/SpriteTypeTest/JPGs 4Max/bounce.py new file mode 100755 index 0000000..db16274 --- /dev/null +++ b/devtools/SpriteTypeTest/JPGs 4Max/bounce.py @@ -0,0 +1,70 @@ +import sys, pygame, time +pygame.init() + +size = width, height = 600,400 +print "\n\n ---- ---- ---- ---- ---- ---- \nFiltype test - Authors Dave Silverman and Scott Mengel" +print "Set size to 1200 x 900 px" +speed = [2, 2] +black = 255, 255, 255 + +screen = pygame.display.set_mode(size) + +ball = pygame.image.load("1 Button.jpg") +ballrect = ball.get_rect() +i=1 +print "Ball Loaded, collision detection ready, Initiating Loop:" + +# R is the Renewed time +# init is the time started +# tt is the test time, gathered by adding the previous test time with +#the new elapsed time which is test.time()'s difference from init + +r=0 + +start = time.time() + +while 1: + # Homemade switcher for the purpose of selecting which img to load + switcher = { + 1: pygame.image.load("2 Button.jpg"), + 2: pygame.image.load("3 Button.jpg"), + 3: pygame.image.load("4 Button.jpg"), + 4: pygame.image.load("5 Button.jpg"), + 5: pygame.image.load("6 Button.jpg"), + 6: pygame.image.load("7 Button.jpg"), + 7: pygame.image.load("8 Button.jpg"), + 8: pygame.image.load("9 Button.jpg"), + 9: pygame.image.load("1 Button.jpg") + } + ball = switcher.get(i,pygame.image.load("1 Button.jpg")) + + #ball = pygame.Surface(rect.size).convert() + #ball.blit(self.sheet, (0,0), rect) + colorkey = (255, 153, 0) + ball.set_colorkey(colorkey, pygame.RLEACCEL) + + i=i+1 + + if i>9: i=1 + + for event in pygame.event.get(): + if event.type == pygame.QUIT: sys.exit() + + ballrect = ballrect.move(speed) + + if ballrect.left < 0 or ballrect.right > width: + speed[0] = -speed[0] + if ballrect.top < 0 or ballrect.bottom > height: + speed[1] = -speed[1] + + screen.fill(black) + screen.blit(ball, ballrect) + pygame.display.flip() + + r=r+1 + + val=1/((time.time()-start)/r) + print val + print r + if r > 500: + sys.exit(0) |