Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devtools/SpriteTypeTest/BMPs 16-Bits/ntest.py
diff options
context:
space:
mode:
authorolpc <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)
commit299d4792e4859ef6540a75fd277ba60a92540f69 (patch)
treea99b71134bebfd1c068fe80236c1b1982b2db7a5 /devtools/SpriteTypeTest/BMPs 16-Bits/ntest.py
parent7972356e06aa7b29fdf42ed6844e7b4f61c02ef1 (diff)
Previous entry incorrect, this push adds new directories and files
Diffstat (limited to 'devtools/SpriteTypeTest/BMPs 16-Bits/ntest.py')
-rwxr-xr-xdevtools/SpriteTypeTest/BMPs 16-Bits/ntest.py103
1 files changed, 103 insertions, 0 deletions
diff --git a/devtools/SpriteTypeTest/BMPs 16-Bits/ntest.py b/devtools/SpriteTypeTest/BMPs 16-Bits/ntest.py
new file mode 100755
index 0000000..22c019f
--- /dev/null
+++ b/devtools/SpriteTypeTest/BMPs 16-Bits/ntest.py
@@ -0,0 +1,103 @@
+import sys, pygame, time
+pygame.init()
+
+ft="bmp"
+r=0
+i=1
+size = width, height = 600,400
+
+print "Nightmare test - Authors Dave Silverman and Scott Mengel"
+print "Set size to 600 x 400 px"
+print "Running..."
+speed1=speed2=speed3=speed4=[2, 2]
+black = 0, 0, 0
+
+screen = pygame.display.set_mode(size)
+
+ball1=ball2=ball3=ball4=pygame.image.load("1 Button.%s"%ft)
+
+ballrect1 = ball1.get_rect()
+ballrect1 = ballrect1.move( 200, 0)
+
+ballrect2 = ball2.get_rect()
+ballrect2 = ballrect2.move( 0, 200)
+
+ballrect3 = ball3.get_rect()
+ballrect3 = ballrect3.move( 200, 200)
+
+ballrect4 = ball4.get_rect()
+ballrect4 = ballrect4.move( 0, 0)
+
+# ballrect = ballrect.move( 0, 0)
+
+print "Ball Loaded, collision detection ready, Initiating Loop:"
+
+start=time.time()
+
+#-----------------------------------------------------------------
+
+def chngImg(thisBall):
+ switcher = {
+ 1: pygame.image.load("2 Button.%s"%ft),
+ 2: pygame.image.load("3 Button.%s"%ft),
+ 3: pygame.image.load("4 Button.%s"%ft),
+ 4: pygame.image.load("5 Button.%s"%ft),
+ 3: pygame.image.load("4 Button.%s"%ft),
+ 3: pygame.image.load("4 Button.%s"%ft),
+ 5: pygame.image.load("6 Button.%s"%ft),
+ 6: pygame.image.load("7 Button.%s"%ft),
+ 7: pygame.image.load("8 Button.%s"%ft),
+ 8: pygame.image.load("9 Button.%s"%ft),
+ 9: pygame.image.load("1 Button.%s"%ft)
+ }
+ return switcher.get(i,pygame.image.load("1 Button.%s"%ft))
+
+#-----------------------------------------------------------------
+
+def collision(thisBallRect,thisSpeed):
+ if thisBallRect.left < 0 or thisBallRect.right > width:
+ return -thisSpeed[0],thisSpeed[1]
+ if thisBallRect.top < 0 or thisBallRect.bottom > height:
+ return thisSpeed[0],-thisSpeed[1]
+ else: return thisSpeed
+#-----------------------------------------------------------------
+
+while 1:
+ ball1 = chngImg(ball1)
+ ball2 = chngImg(ball2)
+ ball3 = chngImg(ball3)
+ ball4 = chngImg(ball4)
+
+ 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)
+
+ speed2=collision(ballrect2,speed2)
+ ballrect2 = ballrect2.move(speed2)
+
+ speed3=collision(ballrect3,speed3)
+ ballrect3 = ballrect3.move(speed3)
+
+ speed4=collision(ballrect4,speed4)
+ ballrect4 = ballrect4.move(speed4)
+
+ screen.fill(black)
+ screen.blit(ball1, ballrect1)
+ screen.blit(ball2, ballrect2)
+ screen.blit(ball3, ballrect3)
+ screen.blit(ball4, ballrect4)
+
+ pygame.display.flip()
+
+ r=r+1
+
+ if r>500: break
+
+#-----------------------------------------------------------------
+
+print 1/((time.time()-start)/r)