def initSprites(): maxValue = (windowWidth) / spriteSize * (windowHeight) / spriteSize flag = True print maxValue currentValue = 0 while currentValue < maxValue: if flag: testSprite = AnimatedSprite("./media/imgs/macks/mage1.png", 12, 32, 32, 3) testSprite.startAnimation(0, 2, 0.5, True) flag = False else: testSprite = AnimatedSprite("./media/imgs/macks/pet1.png", 12, 32, 32, 3) testSprite.startAnimation(0, 2, 0.25, True) flag = True sprites.append(testSprite) currentValue += 1
# -*- coding: utf-8 *-* import pygame import sys from pygame.locals import * from animation.animatedsprite import AnimatedSprite as AnimatedSprite from animation.animationtimer import * # global variables clock = pygame.time.Clock() sprites = [] spriteSize = 32 # means 64x64 windowWidth = 512 windowHeight = 512 oneSprite = AnimatedSprite("./media/imgs/macks/mage1.png", 12, 32, 32, 3) oneSprite.startAnimation(0, 2, 0.5, True) pygame.init() surface = pygame.display.set_mode((windowWidth, windowHeight), pygame.HWSURFACE | pygame.DOUBLEBUF, 32) surface.fill((0, 0, 0)) pygame.display.set_caption('Animation - Test') def initSprites(): maxValue = (windowWidth) / spriteSize * (windowHeight) / spriteSize flag = True print maxValue
#animPath.startAnimation() # test aimap aiMap = AiMap() aiMap.generateMapFromTmx(tmxMap) #path = aiMap.getAiPath((5, 5), (2, 10)) path = aiMap.getAiPathWithCoordinates((5, 5), (28, 28), True) print path #testPath = ([256, 256], [256, 288], [288, 288], [288, 256], [256, 256]) animPath = AnimatedPath(path, 0.5, True) animPath.startAnimation() #test sprite testSprite = AnimatedSprite("./media/imgs/macks/mage1.png", 12, 32, 32, 3) testSprite.startAnimation(0, 1, 1, True) # run the game loop while True: clock.tick(60) # surface.blit(tmxMap.tilesets[0].image, (0, 0)) tmxMap.drawMap(surface, (0, 0, currentSize.width, currentSize.height)) gameMessages.drawMessages(surface, pygame.Rect(0, 640, 1024, 128)) for event in pygame.event.get(): if event.type == QUIT: testSprite.stopAnimation() pygame.quit() sys.exit()