-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSpriteUnitTest.py
executable file
·49 lines (35 loc) · 1.74 KB
/
SpriteUnitTest.py
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
import sys
sys.path.append('/Library/Python/2.6/site-packages/')#this is for phong's computer
import pygame
from pygame.locals import *
import sprites
from sprites import AnimatedSprite, Actor
pygame.init()
screen = pygame.display.set_mode((800,600))
background = pygame.Surface([800,600])
background.fill([0,0,0]) #'''black background'''
PrincessImageSet = sprites.load_sliced_sprites(64, 64, 'images/pigman/pigman_walk.png')
PrincessSprite = Actor(150,400,PrincessImageSet[0], PrincessImageSet[0], PrincessImageSet[0], PrincessImageSet[0], PrincessImageSet[0], PrincessImageSet[0], PrincessImageSet[0], PrincessImageSet[0], PrincessImageSet[0], 'princess', 'friendly', 0, 0, 0, 0, 0)
BossImageSet = sprites.load_sliced_sprites(192, 128, 'images/wiggly5.png')
BossSprite = Actor(150,100,BossImageSet[0], BossImageSet[0], BossImageSet[0], BossImageSet[0], BossImageSet[0], BossImageSet[0], BossImageSet[0], BossImageSet[0], BossImageSet[0], 'wiggly', 'friendly', 0, 0, 0, 0, 0)
Characters = pygame.sprite.RenderUpdates()
Characters.add(PrincessSprite)
Characters.add(BossSprite)
clock = pygame.time.Clock()
while 1:
for event in pygame.event.get():
if event.type == QUIT: sys.exit(0)
if not hasattr(event, 'key') or event.type!=KEYDOWN: continue
if event.key == K_RIGHT: PrincessSprite.Move("Right")
elif event.key == K_LEFT: PrincessSprite.Move("Left")
elif event.key == K_UP: PrincessSprite.Move("Up")
elif event.key == K_DOWN: PrincessSprite.Move("Down")
clock.tick(30)
time = pygame.time.get_ticks()
Characters.clear(screen, background)
Characters.update(time)
rectList = Characters.draw(screen)
pygame.display.update(rectList)
# PrincessSprite.update(time)
# screen.blit(PrincessSprite.image, PrincessSprite.rect)
# pygame.display.flip()