本文整理汇总了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
示例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
示例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
示例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)
示例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)
示例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
示例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()
示例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
示例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
示例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)
示例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
示例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
示例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
示例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
示例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