添加 '让外星人群里移动2'
This commit is contained in:
parent
93b522647c
commit
1933c11f4c
|
@ -0,0 +1,40 @@
|
|||
import random
|
||||
|
||||
class spaceInvader(pygame.sprite.Sprite):
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.image = pygame.image.load("spaceInvader.png")
|
||||
|
||||
self.x = 200
|
||||
|
||||
self.y = 390
|
||||
|
||||
self.shots = []
|
||||
|
||||
def handle_keys(self):
|
||||
|
||||
key = pygame.key.get_pressed()
|
||||
|
||||
dist = 5
|
||||
|
||||
if key[pygame.K_RIGHT]:
|
||||
|
||||
self.x+=dist
|
||||
|
||||
elif key[pygame.K_LEFT]:
|
||||
|
||||
self.x-=dist
|
||||
|
||||
def draw(self, surface):
|
||||
|
||||
surface.blit(self.image,(self.x,self.y))
|
||||
|
||||
for s in self.shots:
|
||||
|
||||
s.draw(screen)
|
||||
|
||||
class Alien(pygame.sprite.Sprite):
|
||||
|
||||
def __init__(self,x,y,direction,alienType):
|
||||
|
Loading…
Reference in New Issue