当前位置: 首页>>代码示例>>Python>>正文


Python sprite.Sprite类代码示例

本文整理汇总了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
开发者ID:nigelgant,项目名称:Puppy-Mt.,代码行数:7,代码来源:player.py

示例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.]
开发者ID:Bediko,项目名称:r0ket,代码行数:7,代码来源:entity.py

示例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
开发者ID:chenjr95,项目名称:SAAST-2014,代码行数:7,代码来源:game.py

示例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
开发者ID:ruijiezhou,项目名称:python_microgame,代码行数:7,代码来源:game.py

示例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)
开发者ID:j-a-c,项目名称:avengers,代码行数:31,代码来源:parallax.py

示例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)
开发者ID:bitpit,项目名称:CS112-Spring2012,代码行数:7,代码来源:oldshittyhw13.py

示例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()
开发者ID:samsath,项目名称:Colonise,代码行数:7,代码来源:bulletthrough.py

示例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())
开发者ID:sgoodspeed,项目名称:CS112-Spring2012,代码行数:7,代码来源:game.py

示例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()
开发者ID:secretknitter,项目名称:Model-Train-Set,代码行数:7,代码来源:test_twain.py

示例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
开发者ID:sjbrown,项目名称:theme_park_simulation,代码行数:25,代码来源:classes.py

示例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()
开发者ID:jwsander,项目名称:CS112-Spring2012,代码行数:7,代码来源:player.py

示例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
开发者ID:socumbersome,项目名称:frogery,代码行数:27,代码来源:frog.py

示例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)
开发者ID:irvingprog,项目名称:MonkeyBanana,代码行数:7,代码来源:Boom.py

示例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
开发者ID:AKilgore,项目名称:CS112-Spring2012,代码行数:7,代码来源:coin.py

示例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))
开发者ID:jlevey3,项目名称:Save-the-Robots-Game,代码行数:25,代码来源:robots.py


注:本文中的pygame.sprite.Sprite类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。