本文整理汇总了Python中util.load_image函数的典型用法代码示例。如果您正苦于以下问题:Python load_image函数的具体用法?Python load_image怎么用?Python load_image使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load_image函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self, big, location, constraint, flyers, bombs, boomboxes, turkeyshakes, *groups):
if big == True:
effects.SpriteSheet.__init__(self, util.load_image( "playerBigMove_sheet.png" ), (60,90) )
self.max_speed = 5
else:
effects.SpriteSheet.__init__(self, util.load_image( "playerMove_sheet.png" ), (30,45) )
self.max_speed = 4
self.constraint = constraint
self.movement = { 'up':0, 'down':0, 'left':0, 'right':0 }
self.facing = 'right'
self.flyers = flyers
self.bombs = bombs
self.boomboxes = boomboxes
self.turkeyshakes = turkeyshakes
self.contacting = ''
self.time = 0
self.anim_frame = 0
self.state = 0
self.flipped = False
self.booltop = True
self.wait = 0
self.bomb_place = False
self.placing = 0
self.end = False
self.rect.center = location
if big:
self.rect.height -= 45
else:
self.rect.height -= 22.5
示例2: refresh_image
def refresh_image(self):
super(WaterTank, self).refresh_image()
if self.sprite is None: return
if 'Gray Water' in self.filter.target:
self.sprite.add_layer('GrayDrop',util.load_image("images/graywdrop_40x40.png"))
else:
self.sprite.add_layer('WaterDrop',util.load_image("images/waterdrop_40x40.png"))
示例3: __init__
def __init__(self, big, location, direction, *groups):
self.type = 'turkeyshake'
pygame.sprite.Sprite.__init__( self, *groups )
self.movement = { 'up':0, 'down':0, 'left':0, 'right':0 }
if big == True:
self.image = util.load_image( "smoothie_TurkeyBig.png" )
else:
self.image = util.load_image( "smoothie_Turkey.png" )
self.rect = self.image.get_rect()
self.time = 30
self.exploded = False
self.big = big
if pygame.mixer.get_init():
self.sound = pygame.mixer.Sound(pkg_resources.resource_stream("applesauce", "sounds/Slurping Smoothie.ogg"))
self.sound.set_volume(0.8)
self.sound.play()
else:
self.sound = None
if direction.endswith( 'up' ):
self.movement['up'] = 1
elif direction.endswith( 'down' ):
self.movement['down'] = 1
if direction.startswith( 'left' ):
self.movement['left'] = 1
elif direction.startswith( 'right' ):
self.movement['right'] = 1
if self.movement['up'] ^ self.movement['down'] == 1 and self.movement['left'] ^ self.movement['right'] == 1:
self.speed = math.sqrt( 50 )
else:
self.speed = 10
self.rect.center = location
示例4: refresh_image
def refresh_image(self):
super(DockingRing, self).refresh_image()
if self.open:
self.sprite.add_layer('DockingRing',util.load_image("images/open_hatch.png"))
else:
self.sprite.add_layer('DockingRing',util.load_image("images/closed_hatch.png"))
self.sprite.layer['Equipment'].visible=False
示例5: init
def init():
Health.heart = util.load_image("sydan")
Health.heart_empty = util.load_image("sydan-tyhja")
Health.heart_broken = util.load_image("sydan-rikki")
heart_broken = pygame.Surface((Health.heart_broken.get_rect().width, Health.heart_broken.get_rect().height))
heart_broken.fill((255,0,255))
heart_broken.set_colorkey((255,0,255))
heart_broken.blit(Health.heart_broken, heart_broken.get_rect())
Health.heart_broken = heart_broken
示例6: get_tile
def get_tile(self, name, colorkey=None, tile_pos=None):
key = (name, tile_pos)
if not self.tiles.has_key( key ):
image = util.load_image(TILES_DIR, name)
image = util.load_image(TILES_DIR, name).convert()
if tile_pos is not None:
tmp = Surface( (TILE_SIZE, TILE_SIZE) )
rect = Rect(tile_pos[0]*TILE_SIZE, tile_pos[1]*TILE_SIZE,TILE_SIZE,TILE_SIZE)
tmp.blit(image, (0,0), rect)
image = tmp.convert()
self.tiles[key] = image
return self.tiles[key]
示例7: explode
def explode(self):
if self.exploded == False:
self.time = 200
self.exploded = True
if self.big == True:
self.image = util.load_image( "hit_smoothie_TurkeyBig.png" )
else:
self.image = util.load_image( "hit_smoothie_Turkey.png" )
tmp = self.image.get_rect()
tmp.center = self.rect.center
self.rect = tmp
for value in self.movement.keys():
self.movement[value] = 0
示例8: __init__
def __init__(self,pos,offset = 16):
#load imgs
self._default = util.load_image("data/bw_key0.png")
self._red = util.load_image("data/red_key0.png")
self._green = util.load_image("data/green_key0.png")
self._blue = util.load_image("data/blue_key0.png")
self.red = self._default
self.green = self._default
self.blue = self._default
self.offset = offset
self.draw_pos = pos
示例9: __init__
def __init__(self, name, group=None):
self.name = name
info_path = util.respath('environments', name, 'info.json')
with pyglet.resource.file(info_path, 'r') as info_file:
info = json.load(info_file)
self.background_tile_rows = info['tile_rows']
self.background_tile_cols = info['tile_columns']
self.background_batch = pyglet.graphics.Batch()
self.background_sprites = []
self.overlay_batch = pyglet.graphics.Batch()
self.overlay_sprites = []
self.width = 0
self.height = 0
background_sprites_dict = {}
tile_w = 0
tile_h = 0
for x in range(self.background_tile_cols):
this_y = 0
for y in range(self.background_tile_rows):
img = util.load_image(util.respath('environments',
name,
'%d_%d.png' % (x, y)))
tile_w, tile_h = img.width, img.height
new_sprite = pyglet.sprite.Sprite(img, x=x*tile_w, y=y*tile_h,
batch=self.background_batch,
group=group)
self.background_sprites.append(new_sprite)
background_sprites_dict[(x, y)] = new_sprite
for x in range(self.background_tile_cols):
self.width += background_sprites_dict[(x, 0)].width
for y in range(self.background_tile_rows):
self.height += background_sprites_dict[(0, y)].height
gamestate.camera_max = (self.width-gamestate.norm_w//2, self.height-gamestate.norm_h//2)
for x in range(self.background_tile_cols):
for y in range(self.background_tile_rows):
overlay_tile_path = util.respath('environments', name, 'overlay_%d_%d.png' % (x, y))
try:
img = util.load_image(overlay_tile_path)
new_sprite = pyglet.sprite.Sprite(img, x=x*tile_w, y=y*tile_h,
batch=self.overlay_batch)
self.overlay_sprites.append(new_sprite)
except pyglet.resource.ResourceNotFoundException:
pass # Ignore if no overlay
self.draw = self.background_batch.draw
self.draw_overlay = self.overlay_batch.draw
self.behind = util.load_image('environments/spacebackground.png')
示例10: __init__
def __init__(self, pos, image, space, anim_name="", num_frames=1, sequence=[0, 1], frequency=8):
self.is_movable = True
GameObject.__init__(
self, pos, util.to_sprite(util.load_image("data/info_sign0.png")), space, OBJECT_TYPE_INFO, pm.inf
)
self.body, self.shape = create_box(space, (pos.x, pos.y), frequency, 12.0)
self.shape.collision_type = OBJECT_TYPE_INFO
self.info_bubble = util.load_image(image)
space.add_static(self.shape)
self._show_info = False
self.cool_down = 0.0
if not anim_name == "":
self.animation = animation.new_animation(anim_name, "png", num_frames, frequency, sequence)
self.animation.play()
示例11: __init__
def __init__(self, *args, **kwargs):
''' Not perfect but the bike uses hardcoded constants
Warning! Lots of opaque physics and math
'''
super(Bike, self).__init__(*args, **kwargs)
# Not ideal to use white as the color key
# Not ideal to hardcode the bike image asset
self.original, self.rect = util.load_image('bike.png', (255,255,255))
self.image = self.original
self.speed = 0
self.max_speed = 5
# Is this bike moving?
self.driving = 0
# Each bike has its own target
self.target = Target()
# start at the origin
self.x, self.y = self.rect.centerx, self.rect.centery
self.angle = 0.0
self.dt = 0.0
# Some physics constants. These and the image ought to be parameters
# F_c = mv*v/r --> v_max = sqrt(F_traction/m) * sqrt(r)
self.ft = 5.0
self.mass = 200.0
self.brake = 0.1
self.accel = 0.05
self.draw_cb = []
示例12: __init__
def __init__(self, ship_rect, ship_angle, left = False):
pygame.sprite.Sprite.__init__(self)
if not Cannonball.image:
Cannonball.image = util.load_image("kuti")
if not Cannonball.sound:
Cannonball.sound = util.load_sound("pam")
screen = pygame.display.get_surface()
self.area = screen.get_rect()
self.image = Cannonball.image
self.hitmask = pygame.surfarray.array_alpha(self.image)
Cannonball.sound.play()
#self.dy = -5
#self.dx = 10
# Shoot at an angle of 25 relative to the ship
if not left:
self.rect = pygame.Rect(ship_rect.right, ship_rect.centery, self.image.get_width(), self.image.get_height())
self.vect = [math.cos((-ship_angle - 25.0) / 180.0 * math.pi) * 11.0,
math.sin((-ship_angle - 25.0) / 180.0 * math.pi) * 11.0]
else:
self.rect = pygame.Rect(ship_rect.left, ship_rect.centery, self.image.get_width(), self.image.get_height())
self.vect = [math.cos((-ship_angle + 180.0 + 25.0) / 180.0 * math.pi) * 11.0,
math.sin((-ship_angle + 180.0 + 25.0) / 180.0 * math.pi) * 11.0]
示例13: init
def init(self,image_map,tile_x=0,tile_y=0,color_key=None):
"""MapEntity(Surface, tile_x, tile_y, direction)
Surface should be obtained from util.load_image
tile_x & tile_y specify what image map to use if you join
multiple images into one map (Characters, Entities, etc)
legal values are positive integers representing zero based index
direction is what direction the entity should face,
can also be set later with MapEntity.face(direction)
legal values are map.NORTH, map.EAST, map.SOUTH, & map.WEST"""
image = util.load_image(CHARACTERS_DIR, image_map, True, color_key)
Sprite.__init__(self)
self.image_args = (image_map, True, color_key)
self.pos = (0,0)
self.map = None
self.image = image
self.image_base_x = tile_x * 3 * TILE_SIZE
self.image_base_y = tile_y * 4 * TILE_SIZE
self.frame = 0
self.image_tile = Rect( self.image_base_x, self.image_base_y,
TILE_SIZE, TILE_SIZE )
self.rect = Rect(0,0,TILE_SIZE,TILE_SIZE)
self.face(NORTH)
self.next_frame()
self.velocity = (0,0)
self.speed = 4
self.moving = False # For tile based motion
self.always_animate = False
self.animation_count = 1
self.animation_speed = 6
self.entered_tile = False
self.can_trigger_actions = 0
示例14: get_HOG_features
def get_HOG_features(data_path, pickle_name):
size = len(data_path)
rowPatchCnt = 4
colPatchCnt = 4
var_features = np.zeros((size, colPatchCnt*rowPatchCnt*3))
print var_features.shape
image = color.rgb2gray(data.astronaut())
#print image
fd, hog_image = hog(image, orientation = 8, pixels_per_cell=(16, 16), cells_per_block = (1,1), visualise=True)
print fd
im = util.load_image(data_path[0])
#print im
#for i in range(size):
#if i % 500 == 0: print "{}/{}".format(i, size)
#im = util.load_image(data_path[i])
#patchH = im.shape[0] / rowPatchCnt
#patchW = im.shape[1] / colPatchCnt
#pass
#im = np.array(im)
pass
示例15: __init__
def __init__(self, usealpha):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.Surface((SCREEN_WIDTH, SCREEN_HEIGHT))
self.rect = self.image.get_rect()
if not Water.raster_image:
Water.raster_image = pygame.transform.scale(util.load_image("rasteri"), (SCREEN_WIDTH, SCREEN_HEIGHT))
self.water_levels = []
for i in xrange(self.rect.width):
self.water_levels.append(0.0)
self.t = 0
self.usealpha = usealpha
self.target_amplitude = self.amplitude = SCREEN_HEIGHT / 8.0
self.target_wavelength = self.wavelength = 0.02 * SCREEN_WIDTH / 2.0 / math.pi
self.target_speed = self.speed = 0.06 / math.pi / 2.0 * FPS
self.target_baseheight = self.baseheight = SCREEN_HEIGHT / 24.0 * 8.0
if self.usealpha:
self.image.set_alpha(110)
self.update()