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


Python Sprite.__init__方法代码示例

本文整理汇总了Python中sprite.Sprite.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Sprite.__init__方法的具体用法?Python Sprite.__init__怎么用?Python Sprite.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sprite.Sprite的用法示例。


在下文中一共展示了Sprite.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
    def __init__(self):
        Sprite.__init__(self)
        self.pos=[0,0,5] #like every other thing, pos is at center bottom

        self.speed=[0,0,0]
        self.size=2 #ball radius, for goal accuracy (used in y, and 2* in z)
        self.owner=0 #0 if ball is free

        self.anim_index=0
        self.direction=1# +1: right, -1: left  TODO : add more directions ?
        self.state="roll1"
        
        self.anim={}#dictionnary for left and right
        self.anim[1]={} #dictionnary of all animation looking to the right
        self.anim[1]["roll1"]=[]
        self.anim[1]["roll1"].append(pygame.image.load("data/_ball_roll1_A.png"))
        self.anim[1]["roll1"].append(pygame.image.load("data/_ball_roll1_B.png"))
        self.anim[1]["roll1"].append(pygame.image.load("data/_ball_roll1_C.png"))
        self.anim[1]["roll1"].append(pygame.image.load("data/_ball_roll1_D.png"))
        self.anim[1]["roll1"].append(pygame.image.load("data/_ball_roll1_E.png"))
        self.anim[1]["roll1"].append(pygame.image.load("data/_ball_roll1_F.png"))
        
        #flip all anims to look left
        self.anim[-1]={}
        for key in self.anim[1]:
            self.anim[-1][key]=[]
            for img in self.anim[1][key]:
                self.anim[-1][key].append(pygame.transform.flip(img, 1, 0))
        
        self.image = self.anim[self.direction][self.state][int(self.anim_index)] #this is how we get the current picture
开发者ID:andru255,项目名称:pyNekketsu,代码行数:32,代码来源:ball.py

示例2: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, world, obj):
     if obj.gid is None:
         print >>sys.stderr, 'Player: must be created from tile object'
         sys.exit(1)
     self.left=False
     self.world = world
     self.gid = obj.gid
     tile = world.data.tiles[self.gid]
     Sprite.__init__(self,
             world,
             obj.kind,
             '{} ({},{})'.format(obj.kind, obj.x, obj.y),
             tile.get_width(), tile.get_height(),
             obj.x, obj.y,
             (16.0, 16.0))
     self.addForce('friction', (1.0, 0.0), 'slowdown')
     self.addForce('gravity', (0.0, 1.0), 'constant')
     self.count = 0
     self.coins = 0
     pygame.font.init()
     self.font = pygame.font.SysFont("Helvetica", 36)
     self.font2 = pygame.font.SysFont("Courier New", 20)
     self.text_color = (255,255,255)
     self.score_color = (255, 0, 0)
     self.score_x = 10
     self.score_y = 30
     self.game_x = 230
     self.game_y = 240
     self.coins = 0
     self.lives = 3
     self.newlife = 0
     self.hurt = False
     self.active = True
开发者ID:adirksen,项目名称:Python,代码行数:35,代码来源:player.py

示例3: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, imagen, velocidad):
     self.image = imagen
     Sprite.__init__(self)
     self.rect = self.image.get_rect()
     self.x = random.randint(-50, int(config.WIDTH))
     self.rect.y = random.randint(-20, int(config.HEIGHT * 0.9))
     self.velocidad = velocidad
开发者ID:gcoop-libre,项目名称:ayni,代码行数:9,代码来源:nubes.py

示例4: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, scene):
     color = (43,73,85)
     grid_color = (170,170,170)
     self.size = (16,16)
     Sprite.__init__(self, scene, self.size, color)
     if config.DEBUG:
         offset = self.rect.move([1,1])
         draw.rect(self.image, grid_color, offset, 1)
开发者ID:derrida,项目名称:shmuppy,代码行数:10,代码来源:room.py

示例5: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self):
     Sprite.__init__(self)
     self.image = common.load('title.png', True, (config.WIDTH * 0.3, 0))
     self.rect = self.image.get_rect()
     self.rect.right = config.WIDTH * 0.9
     self.y = config.HEIGHT
     common.tweener.addTween(self, y=self.y * 0.05, tweenTime=1700, 
             tweenType=pytweener.Easing.Elastic.easeInOut)
开发者ID:hectorsanchez,项目名称:ayni,代码行数:10,代码来源:title_sprite.py

示例6: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, level, pos, facing):
     Sprite.__init__(self, level, pos, facing)
     
     level.destructibles.add(self)
     level.solids.add(self)
     
     self.tile = 2, 2
     self.rotate = True
开发者ID:saltire,项目名称:roverchip,代码行数:10,代码来源:shooter.py

示例7: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self):
     Sprite.__init__(self)
     self.image = common.load('presents/presents.png', False, (config.WIDTH * 0.3, 0))
     self.rect = self.image.get_rect()
     self.rect.centerx = config.WIDTH / 2
     self.rect.y = config.HEIGHT * 0.8
     self.alpha = 0
     self.update()
开发者ID:gcoop-libre,项目名称:ayni,代码行数:10,代码来源:presents.py

示例8: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, x, y, w, h):
     Sprite.__init__(self, x, y)
     self.model = None
     self.w = w
     self.image = pygame.Surface((w + 2, h))
     self.rect = self.image.get_rect().move(x, y)
     self.z = -1000
     self.collision_rect = None
开发者ID:HieuLsw,项目名称:sbfury,代码行数:10,代码来源:energy.py

示例9: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, scene, size, color, name, speed, hp):
     Sprite.__init__(self, scene, size, color)
     self.name = name
     self.speed = speed
     self.hp = hp
     self.weapon_id = 0
     self.weapon = scene.weapon_list[self.weapon_id]
     self.firing = False
     self.last_fired = 0
开发者ID:derrida,项目名称:shmuppy,代码行数:11,代码来源:character.py

示例10: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self):
     Sprite.__init__(self)
     self.image = common.load('level_complete.png', True, (config.WIDTH * 0.5, 0))
     self.rect = self.image.get_rect()
     self.rect.centerx = config.WIDTH / 2
     self.y = -self.rect.h * 2
     self.rect.y = self.y
     common.tweener.addTween(self, y=config.HEIGHT * 0.4, tweenTime=1700, 
             tweenType=pytweener.Easing.Elastic.easeInOut)
开发者ID:gcoop-libre,项目名称:ayni,代码行数:11,代码来源:level_complete.py

示例11: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, stage_objects=[]):
     Sprite.__init__(self)
     pygame.mouse.set_visible(False)
     self._load_frames()
     self.show()
     self.set_frame('normal')
     self.rect = self.image.get_rect()
     self.stage_objects = stage_objects
     self.z = -50
开发者ID:hectorsanchez,项目名称:ayni,代码行数:11,代码来源:editor_mouse.py

示例12: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, level, pos, facing=0):
     Sprite.__init__(self, level, pos, facing)
     
     level.destructibles.add(self)
     level.solids.add(self)
     
     self.tile = 1, 2
     self.facing = 2
     self.layer = 1
     self.rotate = True
开发者ID:saltire,项目名称:roverchip,代码行数:12,代码来源:rover.py

示例13: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, level, pos, facing=0):
     Sprite.__init__(self, level, pos, facing)
     
     level.movables.add(self)
     level.solids.add(self)
     
     self.layer = 1
     
     self.is_sinkable = True
     self.moves_continuously = False
开发者ID:saltire,项目名称:roverchip,代码行数:12,代码来源:movable.py

示例14: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, x, y, font):
     Sprite.__init__(self, x, y)
     self.background = common.load_image("energy_view.png")
     self.model = None
     self.font = font
     self.image = self.background.convert_alpha()
     self.rect = self.image.get_rect()
     self.to_y = y
     self.rect.move_ip(x, y)
     self.rect.y = -50
开发者ID:HieuLsw,项目名称:sbfury,代码行数:12,代码来源:energy.py

示例15: __init__

# 需要导入模块: from sprite import Sprite [as 别名]
# 或者: from sprite.Sprite import __init__ [as 别名]
 def __init__(self, level, pos, facing):
     Sprite.__init__(self, level, pos, facing)
     
     level.destructibles.add(self)
     level.enemies.add(self)
     level.solids.add(self)
     
     self.layer = 1
     self.speed = 250
     self.rotate = True
开发者ID:saltire,项目名称:roverchip,代码行数:12,代码来源:enemy.py


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