本文整理汇总了Python中pygame.sprite.Sprite类的典型用法代码示例。如果您正苦于以下问题:Python Sprite类的具体用法?Python Sprite怎么用?Python Sprite使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Sprite类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, bounds, level, facing):
Sprite.__init__(self)
self.image = self.proj
self.facing = facing
self.rect = self.image.get_rect()
self.bounds = bounds
self.level = level
示例2: __init__
def __init__(self, velocity, image, *groups):
Sprite.__init__(self, *groups)
self.velocity = velocity
self.image = image
self.rect = self.image.get_rect()
self.position_vec = [0., 0.]
self.velocity_vec = [0., 0.]
示例3: __init__
def __init__(self, x, y, area, ball, ai=False):
Sprite.__init__(self)
self.direction = 0
self.image, self.rect = _load_image('games/pong/bat.png', x, y)
self.area = area
self.ball = ball
self.ai = ai
示例4: __init__
def __init__ (self):
Sprite.__init__(self)
self.image=pygame.image.load(join('games','fall','ball.png')).convert_alpha()
self.rect=self.image.get_rect()
self.velocity=(0,0)
self.rect.x=400
self.rect.y=500
示例5: __init__
def __init__(self, img1,x1,y1, img2=None,x2=None,y2=None):
Sprite.__init__(self)
self.prevDist = None
self.img1 = None
self.img2 = None
#corrector for gaps - there are still gaps though -_-
self.gapCorrector = 5
#corrector for loading levels
self.loadCorrector = 900
self.totalx = 0
self.prevx = None
self.dx = 0
if img1:
self.img1 = StaticAnimation(img1)
self.rect1 = self.img1.get_rect()
self.rect1.topleft = (x1,y1)
#copy of the first image for when img1 is done
self.x1copy = False
self.rect1copy = self.img1.get_rect()
self.rect1copy.topleft = (x1,y1)
if img2:
self.img2 = StaticAnimation(img2)
self.rect2 = self.img2.get_rect()
self.rect2.topleft = (x2,y2)
#copy of the second image for when img2 is done
self.x2copy = False
self.rect2copy = self.img2.get_rect()
self.rect2.topleft = (x2,y2)
示例6: __init__
def __init__(self, position, radius=5):
Sprite.__init__(self)
self.position = position
self.duration = 10
self.expandto = 18
self.radius = radius
self.add(explosions)
示例7: __init__
def __init__(self,vel):
Sprite.__init__(self)
self.screen = window
self.pos = [0,0]
self.vel = vel
self.show(pygame.color.THECOLORS["red"])
self.update()
示例8: __init__
def __init__(self,enemy2):
Sprite.__init__(self)
self.rect = Rect(enemy2.rect.midbottom,(self.width, self.height))
self.image = Surface(self.rect.size)
self.image.fill((0,0,0))
self.image.set_colorkey((0,0,0))
pygame.draw.ellipse(self.image,yellow,self.image.get_rect())
示例9: __init__
def __init__(self, theword, thefont):
Sprite.__init__(self)
self.myFont = thefont
self.selected = False
self.image = self.myFont.render(theword, True, white)
self.theword = theword
self.rect = self.image.get_rect()
示例10: __init__
def __init__(self, color):
Sprite.__init__(self)
self.color = color
self.rect = pygame.Rect( 0,0,Visitor.size[0],Visitor.size[1] )
self.realPos = MyRect( self.rect )
self.image = Surface( self.rect.size )
self.image.fill( self.color )
self.speed = 0.5
self.shouldLeaveThePark = False
self.desiredRides = []
self.timeEnteredRecentLine = None
self.attractionBoredomTimeout = 300
self.lineupPadding = simulation.humanWidth*2
self.lineup = None
self.car = None
self.carSeat = None
self.ejectLocation = None
self.moveDirection = None
self.currentDestination = None
self.currentDestPoint = None
self.wanderMode = True
self.nextDecisionCounter = 0
self.correctionCounter = 0
示例11: __init__
def __init__(self):
Sprite.__init__(self)
self.vx = 0
self.vy = 0
self.anim = PlayerAnimation(self, "mario", 60)
self.image = self.anim.get_current_frame()
self.rect = self.image.get_rect()
示例12: __init__
def __init__(self, screen, anchor, hydrophytes, flies, ai):
Sprite.__init__(self)
self.screen = screen
self.anchor = anchor
self.anchor.jumped_on()
self.hydrophytes = hydrophytes
self.flies = flies
self.ai = ai
imm = Frog.imgs_ai if ai else Frog.imgs
self.ai_prey = random.choice(self.flies)
self.ai_tanchor = anchor
self.ai_target = self.ai_prey
self.images = [pygame.image.load(ur).convert_alpha() for ur in imm]
self.image = self.images[0]
self.image_w, self.image_h = self.image.get_size()
self.angle = 0
self.velocity = point2vec(0, 0)
self.base_position = anchor.get_position_v()
self.rel_position = point2vec(0, 0)
self.state = Frog.SITTING
self.jumping_time = 0
self.already_jumping_time = 0
self.already_eating = 0
self.eating_time = 0.25
self.eaten_flies = 0
self.ai_resting_time = 1
self.ai_already_resting_time = 0
示例13: __init__
def __init__(self,x,y):
Sprite.__init__(self);
self._load_images();
self.paso = 0;
self.retraso = 5;
self.image,self.rect = cargar_imagen('boom1.png', -1)
self.rect.center =(x,y)
示例14: __init__
def __init__(self, loc):
Sprite.__init__(self)
self.anim = CoinAnimation(240)
self.image = self.anim.get_current_frame()
self.rect = self.image.get_rect()
self.rect.center = loc
示例15: __init__
def __init__(self, parent):
Sprite.__init__(self)
self.parent = parent
self.name = parent.name
if parent.name == "baby":
self.size = 40,40
self.color = parent.color
self.image = Surface(self.size)
self.rect = self.image.get_rect()
self.rect.centerx = self.parent.rect.centerx
self.rect.centery = self.parent.rect.centery
self.dir = dir
try:
self.image = load_image(self.name+'bot')
print "found family sprite"
except:
self.image.fill(self.color)
print "failed to load family image"
self.image = pygame.transform.scale(self.image, self.size)
self.image.set_colorkey((255,255,255))