Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devtools/Dave's Test Kit/DODirtyTest.py
blob: 88e2309ac61f79c2731b3e497855a9e44df2308c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /usr/bin/env python
import pygame
from pygame.locals import *
from time import time
from Scene import Scene
from DrawableObject import DrawableObject
from DynamicDrawableObject import DynamicDrawableObject
pygame.init()

FRAME=500 #setting number of frames per trial
screenWidth = 600 #screen width
screenHeight = 400 #screen height
numImages = 1 #number of copies of images
maxTrial = 5 # multiple trials, but hard coded in this test
dirtyList=[] #list for objects to be updated

#print the height and width
print "width,height",
print screenWidth,
print ",",
print screenHeight

screen = pygame.display.set_mode( [int(screenWidth),
    int(screenHeight)] ) #Setting the screen size to the given size
pygame.display.set_caption("Sprite Speed Test Window")
background = pygame.image.load("Room.gif")#Loading my background image
screen.blit(background,[0,0])#blitting my background to screen
pygame.display.flip()#flipping screen

#Creating my list of images to use later
surfaceList = [
    pygame.image.load(
        "./Animation Styles/IndividualFrames/bmp16/a2/1.bmp").convert(),
    pygame.image.load(
        "./Animation Styles/IndividualFrames/bmp16/a2/2.bmp").convert(),
    pygame.image.load(
        "./Animation Styles/IndividualFrames/bmp16/a2/3.bmp").convert(),
    pygame.image.load(
        "./Animation Styles/IndividualFrames/bmp16/a2/4.bmp").convert(),
    pygame.image.load(
        "./Animation Styles/IndividualFrames/bmp16/a2/5.bmp").convert(),
    pygame.image.load(
        "./Animation Styles/IndividualFrames/bmp16/a2/6.bmp").convert(),
    pygame.image.load(
        "./Animation Styles/IndividualFrames/bmp16/a2/7.bmp").convert(),
    pygame.image.load(
        "./Animation Styles/IndividualFrames/bmp16/a2/8.bmp").convert(),
    pygame.image.load(
        "./Animation Styles/IndividualFrames/bmp16/a2/9.bmp").convert()
    ]

for aTrial in range(maxTrial):
    start = time()#starting timer

    d = DynamicDrawableObject(surfaceList,'', 100) #creating my DynamicDrawableObject object using my previously made images list

    group1=Scene(d) #creating my scene
    groups=[group1] #creating my array of scenes
    #printing time to load images and stuff
    print (time()-start) ,
    print " -- Time to load"

    #setting up timer stuff
    clock = pygame.time.Clock()
    clock.tick()
    start = time()
    #loop that goes through and upodates my objects
    for frame in range(FRAME):
        dirtyList=[]
        for image in range(numImages):
            groups[image].update(clock.get_time())#calls the update function for my DDO
            clock.tick()#ticks clock
            dirtyList.extend(groups[image].draw(screen))#adding stuff that has been updated to my dirty list

        pygame.display.update(dirtyList)#updates the screen with the dirty list
        for image in range(numImages):
            groups[image].clear(screen, background)#clears stuff behind images based on given background image.