Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/devtools
diff options
context:
space:
mode:
authorslm <jtmengel@gmail.com>2010-07-27 18:51:49 (GMT)
committer slm <jtmengel@gmail.com>2010-07-27 18:51:49 (GMT)
commit431e0666a4561f7c27505d34f083ffbfe2c13457 (patch)
tree8c3559a951114fda06d7157d43ae04ce9c07f9f0 /devtools
parent95ce0140c9fc98365ed58b0ee2d227b0793e534c (diff)
Changed certain file names to indicate depreciated objects that will be temporarily kept for reference purposes.
Diffstat (limited to 'devtools')
-rw-r--r--devtools/CompleteTestKit/DynamicDrawableObject - depreciated.py (copied from devtools/CompleteTestKit/DynamicDO.py)42
-rw-r--r--devtools/CompleteTestKit/DynamicDrawableObject.py46
-rw-r--r--devtools/CompleteTestKit/DynamicDrawableObject.py~ (renamed from devtools/CompleteTestKit/DynamicDO.py)6
-rw-r--r--devtools/CompleteTestKit/FinalDirtyTest.py2
-rw-r--r--devtools/CompleteTestKit/FinalDirtyTest.py~96
-rw-r--r--devtools/CompleteTestKit/OriginalScene - Depreciated.py (renamed from devtools/CompleteTestKit/OriginalScene.py)0
6 files changed, 144 insertions, 48 deletions
diff --git a/devtools/CompleteTestKit/DynamicDO.py b/devtools/CompleteTestKit/DynamicDrawableObject - depreciated.py
index 5375807..0686bc5 100644
--- a/devtools/CompleteTestKit/DynamicDO.py
+++ b/devtools/CompleteTestKit/DynamicDrawableObject - depreciated.py
@@ -26,7 +26,7 @@ class DynamicDrawableObject(DrawableObject, pygame.sprite.Sprite):
# self._last_update = timePassed%self._delay
# self._last_update = timePassed
- def updateWithMovementself, right, bottom):
+ def update(self, right, bottom):
# If we're at the top or bottom of the screen, switch directions.
if (self.yPos + self.ySize) >= bottom or self.yPos < 0: self.ySpeed = self.ySpeed * -1
@@ -47,29 +47,33 @@ class DynamicDrawableObject(DrawableObject, pygame.sprite.Sprite):
self.image = self._images[self._frame]
- def update(self, t):
+ def updateCurrentAnimation(self, t):
- #if self.animations[cnt] == self._current_anim:
+ cnt = 0
+ while cnt < len(animations):
+
+ if animations[cnt] == self._current_anim:
+
+ timePassed = t + self._last_update
+ if timePassed > self._delay:
- print "last update ", self._last_update
- timePassed = t + self._last_update#getting the time since the last time I updated my frame and adding it to the time that I last updated my frame
- print "time passed ", timePassed
- if (timePassed) > self._delay:
- if self._frame < self.animations.get(self._current_anim)[0] or self._frame > self.animations.get(self._current_anim)[1]: #checking if I am in the animation and putting me there if I am not
- self._frame = self.animations.get(self._current_anim)[0]
+ if self._frame < self.animations.get(self._current_anim)[0] or self._frame > self.animations.get(self._current_anim)[1]: #checking if I am in the animation and putting me there if I am not
- self._frame += timePassed/self._delay
- print "frame ", self._frame
+ self._frame = self.animations.get(self._current_anim)[0]
- while self._frame >= self.animations.get(self._current_anim)[1]:
- framesPast = self._frame - self.animations.get(self._current_anim)[1]
- self._frame = framesPast - 1 + self.animations.get(self._current_anim)[0]
+ self._frame += timePassed/self._delay
+ while self._frame >= self.animations.get(self._current_anim)[1]:
+
+ framesPast = self._frame - self.animations.get(self._current_anim)[1]
+ self._frame = framesPast - 1 + self.animations.get(self._current_anim)[0]
+
+ self.image = self._images[self._frame]
+ self._last_update = timePassed%self._delay
+ self._last_update = timePassed
+
+ cnt = len(animations)
- self.image = self._images[self._frame]
- self._last_update = timePassed%self._delay
- else:
-
- self._last_update = timePassed
+ cnt += 1
def nextFrame(self):
diff --git a/devtools/CompleteTestKit/DynamicDrawableObject.py b/devtools/CompleteTestKit/DynamicDrawableObject.py
index 0686bc5..e46ef04 100644
--- a/devtools/CompleteTestKit/DynamicDrawableObject.py
+++ b/devtools/CompleteTestKit/DynamicDrawableObject.py
@@ -26,7 +26,7 @@ class DynamicDrawableObject(DrawableObject, pygame.sprite.Sprite):
# self._last_update = timePassed%self._delay
# self._last_update = timePassed
- def update(self, right, bottom):
+ def updateWithMovement(self, right, bottom): # causes objects to move and collide with walls
# If we're at the top or bottom of the screen, switch directions.
if (self.yPos + self.ySize) >= bottom or self.yPos < 0: self.ySpeed = self.ySpeed * -1
@@ -47,35 +47,31 @@ class DynamicDrawableObject(DrawableObject, pygame.sprite.Sprite):
self.image = self._images[self._frame]
- def updateCurrentAnimation(self, t):
+ def update(self, t): # just updates the frame / object
- cnt = 0
- while cnt < len(animations):
-
- if animations[cnt] == self._current_anim:
-
- timePassed = t + self._last_update
- if timePassed > self._delay:
+ #if self.animations[cnt] == self._current_anim:
- if self._frame < self.animations.get(self._current_anim)[0] or self._frame > self.animations.get(self._current_anim)[1]: #checking if I am in the animation and putting me there if I am not
+ print "last update ", self._last_update
+ timePassed = t + self._last_update#getting the time since the last time I updated my frame and adding it to the time that I last updated my frame
+ print "time passed ", timePassed
+ if (timePassed) > self._delay:
+ if self._frame < self.animations.get(self._current_anim)[0] or self._frame > self.animations.get(self._current_anim)[1]: #checking if I am in the animation and putting me there if I am not
+ self._frame = self.animations.get(self._current_anim)[0]
- self._frame = self.animations.get(self._current_anim)[0]
+ self._frame += timePassed/self._delay
+ print "frame ", self._frame
- self._frame += timePassed/self._delay
- while self._frame >= self.animations.get(self._current_anim)[1]:
-
- framesPast = self._frame - self.animations.get(self._current_anim)[1]
- self._frame = framesPast - 1 + self.animations.get(self._current_anim)[0]
-
- self.image = self._images[self._frame]
- self._last_update = timePassed%self._delay
- self._last_update = timePassed
-
- cnt = len(animations)
+ while self._frame >= self.animations.get(self._current_anim)[1]:
+ framesPast = self._frame - self.animations.get(self._current_anim)[1]
+ self._frame = framesPast - 1 + self.animations.get(self._current_anim)[0]
- cnt += 1
+ self.image = self._images[self._frame]
+ self._last_update = timePassed%self._delay
+ else:
+
+ self._last_update = timePassed
- def nextFrame(self):
+ def nextFrame(self): # push to next frame
self._frame += 1
if self._frame >= len(self._images):
@@ -85,7 +81,7 @@ class DynamicDrawableObject(DrawableObject, pygame.sprite.Sprite):
self.image = self._images[self._frame]
- def nextCurrentAnimFrame(self):
+ def nextCurrentAnimFrame(self): # push to the next frame of curr animation
cnt = 0
while cnt < len(animations):
diff --git a/devtools/CompleteTestKit/DynamicDO.py b/devtools/CompleteTestKit/DynamicDrawableObject.py~
index 5375807..7ccbc5a 100644
--- a/devtools/CompleteTestKit/DynamicDO.py
+++ b/devtools/CompleteTestKit/DynamicDrawableObject.py~
@@ -26,7 +26,7 @@ class DynamicDrawableObject(DrawableObject, pygame.sprite.Sprite):
# self._last_update = timePassed%self._delay
# self._last_update = timePassed
- def updateWithMovementself, right, bottom):
+ def updateWithMovement(self, right, bottom): # causes objects to move and collide with walls
# If we're at the top or bottom of the screen, switch directions.
if (self.yPos + self.ySize) >= bottom or self.yPos < 0: self.ySpeed = self.ySpeed * -1
@@ -47,7 +47,7 @@ class DynamicDrawableObject(DrawableObject, pygame.sprite.Sprite):
self.image = self._images[self._frame]
- def update(self, t):
+ def update(self, t): # just updates the frame / object
#if self.animations[cnt] == self._current_anim:
@@ -71,7 +71,7 @@ class DynamicDrawableObject(DrawableObject, pygame.sprite.Sprite):
self._last_update = timePassed
- def nextFrame(self):
+ def nextFrame(self): # push to next frame
self._frame += 1
if self._frame >= len(self._images):
diff --git a/devtools/CompleteTestKit/FinalDirtyTest.py b/devtools/CompleteTestKit/FinalDirtyTest.py
index 61a1968..b2c86fc 100644
--- a/devtools/CompleteTestKit/FinalDirtyTest.py
+++ b/devtools/CompleteTestKit/FinalDirtyTest.py
@@ -5,7 +5,7 @@ from boxes import BouncingBox
from time import time
from Scene import Scene
from DrawableObject import DrawableObject
-from DynamicDO import DynamicDrawableObject
+from DynamicDrawableObject import DynamicDrawableObject
pygame.init()
FRAME=500
diff --git a/devtools/CompleteTestKit/FinalDirtyTest.py~ b/devtools/CompleteTestKit/FinalDirtyTest.py~
new file mode 100644
index 0000000..61a1968
--- /dev/null
+++ b/devtools/CompleteTestKit/FinalDirtyTest.py~
@@ -0,0 +1,96 @@
+#! /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 DynamicDO import DynamicDrawableObject
+pygame.init()
+
+FRAME=500
+screenWidth = 600
+screenHeight = 400
+numImages = 1
+maxTrial = 5 # multiple trials, but hard coded in this test
+dirtyList=[]
+
+print "width,height",
+print screenWidth,
+print ",",
+print screenHeight
+
+screen = pygame.display.set_mode( [int(screenWidth),
+ int(screenHeight)] ) #Screen Set 600x400
+pygame.display.set_caption("Sprite Speed Test Window")
+GREEN = 0, 192, 0 # green
+background = pygame.image.load("Room.gif")
+screen.blit(background,[0,0])
+pygame.display.flip()
+start = time()
+frameList = [
+ pygame.image.load("./art/BMP24/1.bmp").convert(),
+ pygame.image.load("./art/BMP24/2.bmp").convert(),
+ pygame.image.load("./art/BMP24/3.bmp").convert(),
+ pygame.image.load("./art/BMP24/4.bmp").convert(),
+ pygame.image.load("./art/BMP24/5.bmp").convert(),
+ pygame.image.load("./art/BMP24/6.bmp").convert(),
+ pygame.image.load("./art/BMP24/7.bmp").convert(),
+ pygame.image.load("./art/BMP24/8.bmp").convert(),
+ pygame.image.load("./art/BMP24/9.bmp").convert(),
+]
+frameList2 = [
+ 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()
+
+ d = DynamicDrawableObject(frameList2,"text.txt",400,0,0,1,1)
+ d.goToAnim("anim1")
+ d2 = DynamicDrawableObject(frameList2,"text.txt",400,40,40,1,1)
+ d2.goToAnim("anim1")
+ d3 = DynamicDrawableObject(frameList2,"text.txt",400,80,80,1,1)
+ d3.goToAnim("anim1")
+ d4 = DynamicDrawableObject(frameList2,"text.txt",400,120,120,1,1)
+ d4.goToAnim("anim1")
+ d5 = DynamicDrawableObject(frameList2,"text.txt",400,160,160,1,1)
+ d5.goToAnim("anim1")
+
+ group1=Scene(d)
+ group1.addObjects([d2])
+ group1.addObjects([d3])
+ group1.addObjects([d4])
+ group1.addObjects([d5])
+ groups=[group1]
+ print (time()-start) ,
+ print " -- Time to load"
+
+
+ clock = pygame.time.Clock()
+ clock.tick()
+ start = time()
+ for frame in range(FRAME):
+ dirtyList=[]
+ for image in range(numImages):
+ #move / collision detection
+ groups[image].update(clock.get_time())
+ clock.tick()
+ #individually blit each image group - add to list for update
+ dirtyList.extend(groups[image].draw(screen))
+
+ #draw the images flip/update
+ pygame.display.update(dirtyList)
+ for image in range(numImages):
+ groups[image].clear(screen, background)
+
+ #print 1/((time()-start)/FRAME)
+ pygame.display.flip()
diff --git a/devtools/CompleteTestKit/OriginalScene.py b/devtools/CompleteTestKit/OriginalScene - Depreciated.py
index 4771f3b..4771f3b 100644
--- a/devtools/CompleteTestKit/OriginalScene.py
+++ b/devtools/CompleteTestKit/OriginalScene - Depreciated.py