From f8e9eefdb7327aac9951539b9c038b740756c93f Mon Sep 17 00:00:00 2001 From: slm Date: Fri, 30 Jul 2010 19:10:02 +0000 Subject: Some minor changes to the reworkFinalDirtyTest which is the standalone version of the code planned to be incorporated into the final test suite. --- (limited to 'devtools/CompleteTestKit') diff --git a/devtools/CompleteTestKit/DynamicDrawableObject.py b/devtools/CompleteTestKit/DynamicDrawableObject.py index 8d2737d..b7fe90f 100644 --- a/devtools/CompleteTestKit/DynamicDrawableObject.py +++ b/devtools/CompleteTestKit/DynamicDrawableObject.py @@ -1,13 +1,12 @@ -import pygame -from DrawableObject import DrawableObject - -class DynamicDrawableObject(DrawableObject, pygame.sprite.Sprite): - - def __init__(self,images,textfileName,fps = 10, x = 0, y = 0, xVelocity = 0, yVelocity = 0): - - DrawableObject.__init__(self, images, textfileName, fps, x, y, xVelocity, yVelocity) - - def addImages(self, images): +import pygame +from DrawableObject import DrawableObject + +class DynamicDrawableObject(DrawableObject, pygame.sprite.Sprite): + + def __init__(self,images,textfileName,fps = 10, x = 0, y = 0, xVelocity = 0, yVelocity = 0): + + DrawableObject.__init__(self, images, textfileName, fps, x, y, xVelocity, yVelocity) + def addImages(self, images): self._images.extend(images) diff --git a/devtools/CompleteTestKit/reworkFinalDirtyTest.py b/devtools/CompleteTestKit/reworkFinalDirtyTest.py new file mode 100644 index 0000000..c483f4f --- /dev/null +++ b/devtools/CompleteTestKit/reworkFinalDirtyTest.py @@ -0,0 +1,78 @@ +#! /usr/bin/env python +import pygame +from pygame.locals import * +from boxes import BouncingBox +from time import time +from Scene import Scene +from DrawableObject import DrawableObject +from DynamicDrawableObject import DynamicDrawableObject +pygame.init() + +#2345678911234567892123456789312345678941234567895123456789612345678971234567898 +#2345678911234567892123456789312345678941234567895123456789612345678971234567898 + +screenWidth = 600 +screenHeight = 400 +maxImage = 5 +maxGroup = 1 # not implemented for the first step + # groups are scenes within our code - our Scene inherits Group and ergo + # functions as such +maxTrial = 1 # multiple trials, but hard coded in this test +maxFrame=500 # temperary +infoFilePath = 'animInfo.txt' + +screen = pygame.display.set_mode(( screenWidth,screenHeight) ) +pygame.display.set_caption("Testing Custom Objects - FinalDirtyTest.py") +background = pygame.image.load("Room.gif") + +start = time() + +for trial in range(maxTrial): + print "New trial" + screen.blit( background , [0,0] ) + pygame.display.flip() + + start = time() + surfaceList = [] + drawObject = [] + scenesList = [] + + drawObject = [ DrawableObject( + surfaceList, infoFilePath, None, 0 , 0 , 1 , 1) ] + drawObject[0].goToAnim("anim1") + + for img in range(maxImage)[1:]: + surfaceList.append(pygame.image.load( + "./Animation Styles/IndividualFrames/bmp16/a2/",img, + "1.bmp").convert())) + drawObject[img] = DynamicDrawableObject( + surfaceList,infoFilePath,24,img*40,img*40,1,1) + drawObject[img].goToAnim("anim1") + if img==1: + scene1[] = Scene( drawObject[img] ) + scenesList.append(scene1) + else: + scene1.addObjects( [ drawObject[img] ] ) + scenesList.append(scene1) + +# 'scenesList' is a list filled with Scene objects (those inherit/extend Group) + + print (time()-start) , + print " -- Time to load and sort animations into scenesList" + + clock = pygame.time.Clock() + clock.tick() # <--Updates the clock variable in milliseconds + + start = time() + for maxFrame in range(maxFrame): + dirtyList=[] + + scenesList[1].update( clock.get_time() ) ## hard coded for now + clock.tick() + dirtyList.extend( scenesList[grp].draw(screen) ) + print dirtyList + pygame.display.update(dirtyList) # <-- is there a faster way to place? + + scenesList[grp].clear(screen, background) + + print "Trial's average framerate was " , str(1/((time()-start)/maxFrame)) -- cgit v0.9.1