本文整理汇总了Python中pygame.sprite.Group.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Group.__init__方法的具体用法?Python Group.__init__怎么用?Python Group.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pygame.sprite.Group
的用法示例。
在下文中一共展示了Group.__init__方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, bounds):
Group.__init__(self)
self.bounds = bounds
self.spawn_rate = COIN_SPAWN_RATE * 1000
self.spawn_timer = 0
示例2: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, moving_sprite,
speedx = 0,
maxspeedx = -1,
speedy = 0,
maxspeedy = -1,
posx = 0,
posy = 0,
thrust_strength = 0,
accelx = 0,
accely = 0,
gravity = 1000,
decrease_speed_ratio = 2.0):
Group.__init__(self)
self.moving_sprite = moving_sprite
self.speedx = speedx
self.speedy = speedy
self.maxspeedx = maxspeedx
self.maxspeedy = maxspeedy
self.posx = posx
self.posy = posy
self.thrust_strength = thrust_strength
self.accelx = accelx
self.accely = accely
self.gravity = gravity
self.decrease_speed_ratio = decrease_speed_ratio
self.bumping_walls = []
示例3: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, map, imageCache, rectPixelView, imWidth, imHeight):
Group.__init__(self)
self._changeListeners = []
self.map = map
self.worldRect = Rect(0, 0, self.map.width * imWidth, self.map.height * imHeight)
self.imageCache = imageCache
self.imageSize = (imWidth, imHeight)
self.offsetX = 0
self.offsetY = 0
self.setView(rectPixelView)
示例4: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, map, imageCache, rectPixelView, imWidth, imHeight):
Group.__init__(self)
self._changeListeners = []
self.upperLeft = [0, 0]
self.numTiles = (int(rectPixelView.width / imWidth), int(rectPixelView.height / imHeight))
self.map = map
self.imageCache = imageCache
self.imageSize = (imWidth, imHeight)
self.offsetX = 0
self.offsetY = 0
self.setView(rectPixelView)
示例5: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self):
Group.__init__(self)
BaseModel.__init__(self)
# load image
_money_image = pygame.image.load(
get_file_path('img/item/money.png')).convert_alpha()
_subsurface_data = [(25, 24), (25, 24), (33, 30), (32, 31)]
_y = 0
self.money_images = []
for _sub_data in _subsurface_data:
_tmp_list = [_money_image.subsurface(
(i*_sub_data[0], _y), _sub_data) for i in range(4)]
_y += _sub_data[1]
self.money_images.append(_tmp_list)
_item_rare_image = pygame.image.load(
get_file_path('img/item/rare_42x44.png')).convert_alpha()
self.item_rare_images = [_item_rare_image.subsurface(
(i*ITEM_RARE_SIZE[0], 0), ITEM_RARE_SIZE) for i in range(6)]
# load icons, but now only load one image
self.item_icons = pygame.image.load(
get_file_path('img/item/04000019.png')).convert_alpha()
示例6: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, target, sprite_filename, formation, target_position):
Group.__init__(self)
self.target = target
self.sprite_filename = sprite_filename
self.target_position = target_position
#this image is passed to each Cell object
cell_image = pygame.image.load(sprite_filename).convert_alpha()
#convert formation list into table of cell sprites
#offsets are the difference between current cell and target cell
#since first cell is (0, 0) these start as negative of the target
row_offset = -target_position[0]
cells = []
for row in formation:
col_offset = -target_position[1]
cells_row = []
for col in row:
#0 means the cell is empty
if col == 0:
cells_row.append(None)
#1 means a cell sprite should be added here
elif col == 1:
new_cell = Cell(row_offset, col_offset, cell_image, target)
Group.add(self, new_cell)
cells_row.append(new_cell)
#anything else means wtf are you doing
else: raise
col_offset += 1
cells.append(cells_row)
row_offset += 1
self.cells = cells
self.delay = 0
示例7: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, bullets):
"""Initializes the group and makes a wave of enemies
window_size is a tuple with the window dimensions (width, height)
rows, cols are the height and width resp. of enemies in the waves
gap is the number of pixels between each sprite
speed is the number of pixels moved at once
move_delay is the number of frames waited between movements
shoot_delay is the number of frames between enemy shots
bullets is a Group that will hold the enemies' bullets
sprite_filename is the sprite file for the ships
"""
Group.__init__(self)
self.window_size = window_size
self.rows = wave_rows
self.cols = wave_cols
self.gap = wave_gap
self.speed = enemy_speed
self.move_delay = enemy_delay
self.shoot_delay = enemy_shoot_delay
self.bullets = bullets
self.sprite_filename = enemy_filename
self.build_wave()
示例8: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, *sprites):
Group.__init__(self, *sprites)
示例9: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, count):
Group.__init__(self)
self.count = count
示例10: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, count):
Group.__init__(self)
self.max = count
示例11: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self):
Group.__init__(self)
示例12: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self):
"""
Constructor.
"""
Group.__init__(self)
示例13: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, bounds):
Group.__init__(self)
self.bounds = bounds
self.spawn_timer = 0
示例14: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self):
Group.__init__(self)
dispatcher.connect(self.add_sprite, signal=signals.NEW_OBJECT, sender=Player)
示例15: __init__
# 需要导入模块: from pygame.sprite import Group [as 别名]
# 或者: from pygame.sprite.Group import __init__ [as 别名]
def __init__(self, *sprites):
self._spritelist = []
Group.__init__(self, *sprites)