Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devtools/Dave's Test Kit/FontDirtyTest.py
blob: 22a66617f7a6dd933f18b032cfffd67fcc5dc9be (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
#! /usr/bin/env python
import pygame
from pygame.locals import *
from time import time
from Scene import Scene
from DrawableObject import DrawableObject
from DrawableFontObject import DrawableFontObject
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

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

    font = pygame.font.SysFont("cmr10", 100) #creating my font object
    d = DrawableFontObject("hello world", font) #creating my DrawableFontObject object using my previously made font object

    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=[]
        d.changeText(str(frame))#updates my text for my DFO
        for image in range(numImages):
            groups[image].update(clock.get_time())#calls the update function for my DFO
            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.