Reputation: 21
So if anyone has used pyganim to show sprite sheet animations and could tell me why my code is not showing the animation, I would thank you loads. ive tried moving coordinates and changing fill color. nothing is working and I'm not receiving any errors so I'm not sure what the problem is.
import pygame
from pygame.locals import *
import time
import random
import pyganim
import sys
import os
rects = [(0, 154, 94, 77),
(94, 154, 94, 77),
(188, 154, 94, 77),
(282, 154, 94, 77),
(376, 154, 94, 77),
(470, 154, 94, 77),
(564, 154, 94, 77),
(658, 154, 94, 77),]
file_name = ('explosion1.png')
images = pyganim.getImagesFromSpriteSheet(file_name, rects = rects)
frames = list (zip(images, [100] * len(images)))
animObj = pyganim.PygAnimation(frames)
animObj.play()
white = (255, 255, 255)
black = (0, 0, 0)
pygame.init()
display_width = 800
display_height = 600
gameDisplay = pygame.display.set_mode((display_width, display_height))
pygame.display.set_caption('sprite animations')
clock = pygame.time.Clock()
def game_loop():
gameDisplay.fill(black)
gameExit = False
while not gameExit:
for event in pygame.event.get():
if event.type == pygame.QUIT:
gameExit = True
animObj.blit(gameDisplay,(100, 50))
pygame.display.update()
clock.tick(15)
game_loop()
pygame.quit()
quit()
Upvotes: 0
Views: 171
Reputation: 21
Sprite was bad, had to change the sheet, and my gameDisplay.fill(..) was outside of the while loop!
Upvotes: 1