コード例 #1
0
 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
コード例 #2
0
 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    
コード例 #3
0
 def __getitem__(self, index):
     albedo = load_image(join(self.albedo_path,'albedo-'+ self.image_filenames[index]))
     depth = load_image(join(self.depth_path, 'depth-'+self.image_filenames[index]))
     direct = load_image(join(self.direct_path,'direct-'+ self.image_filenames[index]))
     normal = load_image(join(self.normal_path, 'normals-'+self.image_filenames[index]))
     gt = load_image(join(self.gt_path, 'output-'+self.image_filenames[index]))
     return albedo, direct, normal, depth, gt
コード例 #4
0
 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"))        
コード例 #5
0
ファイル: player.py プロジェクト: linkinpark342/applesauce
 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
コード例 #6
0
def convert_lrgb_to_srgb(directory, gamma=2.0):
    with open(os.path.join(directory, "whitepoint_matrices.json")) as f:
        matrices = json.load(f)

    def transform(image, matrix):
        return (matrix @ image.reshape(-1, 3).T).T.reshape(image.shape)

    for index in range(1, 28):
        print("image", index, "of", 27)

        path = os.path.join(directory,
                            "input_with_gt_fgd/input/GT%02d.tif" % index)
        lrgb = util.load_image(path)
        lrgb = transform(lrgb, np.float64(matrices[str(index)]).reshape(3, 3))
        lrgb = np.maximum(0, lrgb)
        srgb = util.lrgb_to_srgb(lrgb, gamma)
        srgb = np.clip(srgb, 0, 1)

        image = srgb

        path = os.path.join(directory,
                            "input_with_gt_fgd/fgd/GT%02d.tif" % index)
        lrgb = util.load_image(path)
        lrgb = transform(lrgb, np.float64(matrices[str(index)]).reshape(3, 3))
        lrgb = np.maximum(0, lrgb)
        srgb = util.lrgb_to_srgb(lrgb, gamma)
        srgb = np.clip(srgb, 0, 1)

        foreground = srgb

        path = os.path.join(directory, "converted/image/GT%02d.bmp" % index)
        util.save_image(path, image)
        path = os.path.join(directory,
                            "converted/foreground/GT%02d.bmp" % index)
        util.save_image(path, foreground)
コード例 #7
0
    def __init__(self, ship_rect, ship_angle, left=False, special=False):
        pygame.sprite.Sprite.__init__(self)

        if not Cannonball.image:
            Cannonball.image = util.load_image("kuti")
        if not Cannonball.spec_image:
            Cannonball.spec_image = pygame.transform.flip(
                util.load_image("lokki2"), 1, 0)

        if not Cannonball.sound:
            Cannonball.sound = util.load_sound("pam")
        screen = pygame.display.get_surface()
        self.area = screen.get_rect()

        if special:
            self.image = Cannonball.spec_image
        else:
            self.image = Cannonball.image
        self.special = special
        self.underwater = 0

        #self.hitmask = pygame.surfarray.array_alpha(self.image)
        if (Variables.sound):
            Cannonball.sound.play()
        #self.dy = -5
        #self.dx = 10
        # Shoot at an angle of 25 relative to the ship

        self.angle = 0

        if not left:
            if special:
                velocity = 14.0
                self.rect = pygame.Rect(ship_rect.right, ship_rect.top,
                                        self.image.get_width(),
                                        self.image.get_height())
                self.vect = [
                    math.cos(
                        (-ship_angle - 15.0) / 180.0 * math.pi) * velocity,
                    math.sin((-ship_angle - 15.0) / 180.0 * math.pi) * velocity
                ]
            else:
                velocity = 11.0
                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) * velocity,
                math.sin((-ship_angle - 25.0) / 180.0 * math.pi) * velocity
            ]
        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
            ]
コード例 #8
0
ファイル: ground.py プロジェクト: srBruning/T-RexAi
 def __init__(self,context, direction=-1):
     self.image,self.rect = load_image( 'ground.png',-1,-1,-1)
     self.image1,self.rect1 = load_image( 'ground.png',-1,-1,-1)
     self.rect.bottom = context.height
     self.rect1.bottom = context.height
     self.rect1.left = self.rect.right
     self.context = context
     self.direction = direction
コード例 #9
0
 def __init__(self, x, y):
     image_on = util.load_image('images/ship2-on.png')
     image_off = util.load_image('images/ship2-off.png')
     self.sprite_on = pyglet.sprite.Sprite(image_on, x=x, y=y, batch=batch, group=ships)
     self.sprite_off = pyglet.sprite.Sprite(image_off, x=x, y=y, batch=batch, group=ships)
     self.sprite = self.sprite_off
     self.body = physics.Body(x, y, 12, fixed=False)
     self.fuel_usage = 0
コード例 #10
0
    def __load__(self, index):
        left_img_path = self.json_data[index]["imageL"]
        right_img_path = self.json_data[index]["imageR"]
        output_img_path = self.json_data[index]["output"]

        left_img = load_image(left_img_path)
        right_img = load_image(right_img_path)

        return left_img, right_img, output_img_path
コード例 #11
0
ファイル: health.py プロジェクト: zielmicha/funnyboat-android
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
コード例 #12
0
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
コード例 #13
0
def test_conversion(conversion):
    for i in range(1, 5):
        lr_orig = np.array(load_image(lr(IMG_PATH, i, 'png')))
        hr_orig = np.array(load_image(hr(IMG_PATH, i, 'png')))

        lr_conv = np.load(lr(ARR_PATH, i, 'npy'))
        hr_conv = np.load(hr(ARR_PATH, i, 'npy'))

        assert np.array_equal(lr_orig, lr_conv)
        assert np.array_equal(hr_orig, hr_conv)
コード例 #14
0
 def refresh_image(self):     
     super(Machinery, self).refresh_image()
     if self.sprite is None: return
     import pyglet
     img1=pyglet.image.AnimationFrame(util.load_image("images/machinery_40x40.png"),0.5 if self.active else None)
     img2=pyglet.image.AnimationFrame(util.load_image("images/machinery_40x40_1.png"),0.5)
     
     animation = pyglet.image.Animation([img1,img2])
     
     self.sprite.add_layer('Machinery',animation)                                                 
コード例 #15
0
ファイル: Prompt.py プロジェクト: xiaottang2/TicTacToeAI
 def __init__(self, result):
     pygame.sprite.Sprite.__init__(self)
     if result == WIN:
         self.image, self.rect = load_image("prompt_win.png")
     elif result == DRAW:
         self.image, self.rect = load_image("prompt_draw.png")
     elif result == LOSE:
         self.image, self.rect = load_image("prompt_lose.png")
     else:
         raise "Not valid result!"
コード例 #16
0
ファイル: Start_Game.py プロジェクト: Propo41/Run_Barry_Run
 def __init__(self, img_address, img_address_clicked, topleft_x, topleft_y,
              state):
     self.x = topleft_x
     self.y = topleft_y
     self.hovered = False
     self.img = load_image(img_address)
     self.img_hovered = load_image(img_address_clicked)
     self.rect = self.img.get_rect(topleft=(topleft_x, topleft_y))
     self.rect_hovered = self.img_hovered.get_rect(topleft=(topleft_x,
                                                            topleft_y))
     self.state = state
コード例 #17
0
    def __init__(self, window: Window):
        super().__init__(window)

        from constants import BUTTON_SIZE

        self.window_size = window.get_size()
        self.window_center = (self.window_size[0] / 2, self.window_size[1] / 2)

        dpi_factor = window.hidpi_factor

        button_size = (BUTTON_SIZE[0] * dpi_factor,
                       BUTTON_SIZE[1] * dpi_factor)
        button_font = Font('sans-serif', 16, dpi_factor)

        self.bg_image = util.load_image('assets/background.png')
        self.bg_size = (self.bg_image.get_width(), self.bg_image.get_height())
        self.bg_center = (self.bg_size[0] / 2, self.bg_size[1] / 2)

        self.logo = util.load_image('assets/logo.png')
        self.logo_size = (self.logo.get_width(), self.logo.get_height())
        self.logo_center = (self.logo_size[0] / 2, self.logo_size[1] / 2)

        self.max_score = 0
        self.last_active_level = None

        self.text_font = Font('monospace', 20, window.hidpi_factor)
        self.text_font_color = Color(255, 255, 255)

        # Template to create new button
        start_btn = Button(window,
                           '[ Start ]',
                           Vector(self.window_center[0] - button_size[0] / 2,
                                  self.window_center[1] - button_size[1]),
                           Vector(*button_size),
                           Color(0, 102, 255),
                           Color(255, 255, 255),
                           Color(0, 80, 230),
                           Color(255, 255, 255),
                           font=button_font)
        start_btn.set_click_handler(self.start)
        self.children.append(start_btn)

        help_btn = Button(window,
                          '[ Help ]',
                          Vector(self.window_center[0] - button_size[0] / 2,
                                 self.window_center[1] + button_size[1]),
                          Vector(*button_size),
                          Color(0, 102, 255),
                          Color(255, 255, 255),
                          Color(0, 80, 230),
                          Color(255, 255, 255),
                          font=button_font)
        help_btn.set_click_handler(self.help)
        self.children.append(help_btn)
コード例 #18
0
    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')
コード例 #19
0
    def test_img_save_and_load(self):
        test_img = util.load_image(test_img_dir / '2.png', size=64)
        self.assertEqual(type(test_img), np.ndarray)
        self.assertEqual(test_img.shape, (64, 64, 3))
        self.assertEqual(test_img.dtype, np.float64)

        util.save_image(test_img_dir / 'test.png', test_img)
        file = (test_img_dir / 'test.png')
        self.assertTrue(file.exists())
        self.assertTrue(file.is_file())
        self.assertTrue(np.allclose(test_img, util.load_image(file)))
        file.unlink()
コード例 #20
0
ファイル: map.py プロジェクト: bpa/renegade
 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]
コード例 #21
0
    def __load__(self, index):
        left_img_path = os.path.join(self.dataset_root, self.json_data[index]["imageL"])
        right_img_path = os.path.join(self.dataset_root, self.json_data[index]["imageR"])
        left_normal_path = os.path.join(self.dataset_root, self.json_data[index]["normalL"])
        right_normal_path = os.path.join(self.dataset_root, self.json_data[index]["normalR"])

        left_img = load_image(left_img_path)
        right_img = load_image(right_img_path)
        left_normal = load_normal(left_normal_path)
        right_normal = load_normal(right_normal_path)

        return left_img, right_img, left_normal, right_normal
コード例 #22
0
ファイル: billboard.py プロジェクト: andsve/pxf-gamejam
    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
コード例 #23
0
 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
コード例 #24
0
ファイル: cost.py プロジェクト: rajr0/convolver
def main():
    p = argparse.ArgumentParser(
        description=
        'Given two images and some kernels, report the difference per kernel.')
    p.add_argument('a', help='input image filename')
    p.add_argument('b', help='expected image filename')
    p.add_argument('kernels', nargs='*', help='kernel directory')
    p.add_argument(
        '-gamma',
        type=float,
        default=1.0,
        help='gamma correction to use for images (default: no correction)')
    p.add_argument('-crop_x',
                   type=int,
                   default=0,
                   help='crop X offset in pixels, range is [0..width-1]')
    p.add_argument(
        '-crop_y',
        type=int,
        default=0,
        help=
        'crop Y offset in pixels, range is [0..height-1] where 0 is the TOP')
    p.add_argument('-crop_w', type=int, default=0, help='crop width in pixels')
    p.add_argument('-crop_h',
                   type=int,
                   default=0,
                   help='crop height in pixels')
    args = p.parse_args()

    img1 = util.load_image(args.a, args)
    img2 = util.load_image(args.b, args)
    assert img1.shape == img2.shape, (img1.shape, img2.shape)
    print('# Loaded images. Shape is', img1.shape)

    img_input = tf.constant(img1)
    img_expected = tf.constant(img2)
    sess = util.make_session()

    for kfn in args.kernels:
        step, kernel = util.load_kernel(kfn)
        n = kernel.shape[0]
        border = (n + 1) // 2

        # Convolve and calculate costs.
        img_actual = util.convolve(img_input, kernel)
        dcost = sess.run(
            util.diff_cost(util.diff(img_actual, img_expected, border)))
        rcost = sess.run(util.reg_cost(kernel))

        print(kfn, 'n', n, 'diffcost %.12f' % dcost, 'regcost', rcost,
              'avg-px-err', util.avg_px_err(dcost, args.gamma))
コード例 #25
0
ファイル: environment.py プロジェクト: Merfie/Space-Train
 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')
コード例 #26
0
ファイル: gameobject.py プロジェクト: andsve/pxf-gamejam
    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()
コード例 #27
0
ファイル: restore.py プロジェクト: jojonas/img-restoration
def process(params):
    # unpack arguments (needed for multiprocessing)
    filename, args = params

    if args.out:
        outname = join_out_filename(args.out, os.path.basename(filename))
    else:
        outname = compute_out_filename(filename)

    print("Processing", filename, "=>", outname)

    array, info = load_image(filename)

    restored_image = restore(array, args)

    if info:
        # transfer exif info
        try:
            import piexif
        except ImportError:
            warnings.warn("Python module 'piexif' is required in order to preserve EXIF information.")
            exif_bytes = b''
        else:
            exif_dict = piexif.load(info['exif'])
            # remove thumbnail from exif info (new appearance)
            del exif_dict['thumbnail']
            exif_bytes = piexif.dump(exif_dict)
    else:
        exif_bytes = b''

    save_image(outname, restored_image, quality=args.quality, exif=exif_bytes)
コード例 #28
0
 def refresh_image(self):     
     super(SolarPanel, self).refresh_image()
     if self.sprite is None: return
     img = util.load_image("images/solarpanel_horiz.png")
     img.anchor_x, img.anchor_y = [2,15]
     self.sprite.add_layer('SolarPanel',img)
     self.sprite.layer['Equipment'].visible=False        
コード例 #29
0
ファイル: cannonball.py プロジェクト: rkuklins/funnyboat
    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]
コード例 #30
0
    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 = util.load_image("rasteri")

        self.water_levels = []
        for i in range(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()
コード例 #31
0
    def __init__(self, image_path, shape):
        self.image_path = image_path
        self.image = load_image(image_path, shape)
 
        self.height = self.image.shape[0]
        self.width = self.image.shape[1]
        self.num_channels = self.image.shape[2]
コード例 #32
0
 def refresh_image(self, imgfile, x_off = 0):     
     if self.sprite: self.sprite.delete()
     import graphics_pyglet
     self.sprite = graphics_pyglet.LayeredSprite(name=self.name,start_order = -30)
     img = util.load_image(imgfile )
     self.sprite.add_layer(self.name,img)    
     self.sprite._offset = [gv.config['ZOOM'] * 2 * x_off, 0]
コード例 #33
0
ファイル: mapClass.py プロジェクト: ChadbouM/IAI
 def __create__(self, file, name, size):
     # Open the generation Image:
     temp_file = util.load_image(file, util.config.settings['Screen_Size'])
     # Create new Folder
     self.name = name
     this_path = util.local_path('source/Maps', self.name)
     if os.path.exists( this_path ): return -1
     os.makedirs( this_path )
     os.makedirs( this_path + '/items')
     # Save Background
     temp_file.save( this_path + '/background.gif' )
     temp_file.close()
     # Write Config
     temp_file = open( this_path + '/config', 'w')
     ## Write Dimensions
     temp_file.write("%d, %d\n\n" % (size[0], size[1]))
     ## Write wall positions
     for i in range(size[1]):
         temp_file.write((' 0,' * size[0])[1:-1] + '\n')
     temp_file.write('\n')
     ## Write Object Start positions
     for i in range(size[1]):
         temp_file.write((' 0,' * size[0])[1:-1] + '\n')
     temp_file.write('\n')
     ## Write Object Defenitions: None
     ## Close config file and load from created files. 
     temp_file.close()
     self.__load__()
コード例 #34
0
ファイル: models.py プロジェクト: unmonoqueteclea/pygame-ML
 def __init__(self, posX):
     pygame.sprite.Sprite.__init__(self)
     self.image = util.load_image("images/pala.png")
     self.rect = self.image.get_rect()
     self.rect.centerx = posX
     self.rect.centery = util.HEIGHT / 2
     self.speed = 0.4
コード例 #35
0
ファイル: conv.py プロジェクト: rajr0/convolver
def main():
    p = argparse.ArgumentParser(description='Convolve an image with a kernel.')
    p.add_argument('img', help='input image filename')
    p.add_argument('k', help='path to kernel ')
    p.add_argument(
        '-gamma',
        type=float,
        default=1.0,
        help='gamma correction to use for images (default: no correction)')
    p.add_argument('-out', help='output to *.png file instead of viewing')
    args = p.parse_args()

    img = util.load_image(args.img, args, gray=False)
    n, h, w, c = img.shape
    assert n == 1, n
    out = np.zeros((h, w, c), dtype=np.float32)
    step, kernel = util.load_kernel(args.k)
    sess = util.make_session()
    for i in range(c):
        chan = sess.run(
            util.convolve(tf.constant(img[:, :, :, i:i + 1]), kernel))
        out[:, :, i] = chan[0, :, :, 0]
    out = util.from_float(out, args.gamma)

    if args.out is not None:
        util.save_image(args.out, out)
        print('Written to', args.out)
    else:
        print('Press ESC to close window.')
        util.viewer(None, lambda: out)
コード例 #36
0
ファイル: show_result.py プロジェクト: khanha2/ren
def show_pose(dataset_model, dataset_image, base_dir, outputs, list_file,
              save_dir, is_flip, gif):
    if list_file is None:
        names = util.load_names(dataset_image)
    else:
        with open(list_file) as f:
            names = [line.strip() for line in f]
    assert len(names) == outputs.shape[0]

    for idx, (name, pose) in enumerate(zip(names, outputs)):
        img = util.load_image(dataset_image,
                              os.path.join(base_dir, name),
                              is_flip=is_flip)
        img = img.astype(np.float32)
        img = (img - img.min()) / (img.max() - img.min()) * 255
        img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
        img = util.draw_pose(dataset_model, img, pose)
        cv2.imshow('result', img / 255)
        if save_dir is not None:
            cv2.imwrite(os.path.join(save_dir, '{:>06d}.png'.format(idx)), img)
        ch = cv2.waitKey(25)
        if ch == ord('q'):
            break

    if gif and save_dir is not None:
        os.system(
            'convert -loop 0 -page +0+0 -delay 25 {0}/*.png {0}/output.gif'.
            format(save_dir))
コード例 #37
0
ファイル: convert.py プロジェクト: zzm422/super-resolution
def convert(input_path, output_path, converter, extensions):
    """
    Converts DIV2K images using converter preserving the directory structure.

    :param input_path: path to DIV2K images
    :param output_path: path to DIV2K numpy array to be generated
    """

    img_paths = []

    for extension in extensions:
        img_paths_ext = glob.glob(os.path.join(input_path, '**',
                                               f'*.{extension}'),
                                  recursive=True)
        img_paths.extend(img_paths_ext)

    for img_path in tqdm(img_paths):
        img_dir, img_file = os.path.split(img_path)
        img_id, img_ext = os.path.splitext(img_file)

        rel_dir = os.path.relpath(img_dir, input_path)
        out_dir = os.path.join(output_path, rel_dir)

        if not os.path.exists(out_dir):
            os.makedirs(out_dir)

        img = load_image(img_path)
        converter(out_dir, img_id, img)
コード例 #38
0
def depth_inference(dataset='kitti'):
    if dataset == 'kitti':
        model_input_img_size = (416, 128)  # w,h
    elif dataset == 'euroc':
        model_input_img_size = (384, 256)  # w,h
    else:
        raise Exception('invalid dataset: {}'.format(dataset))

    img_in = load_image(FLAGS.input_image_path, resize=model_input_img_size)
    inference_model = model.Model(is_training=False,
                                  batch_size=1,
                                  img_height=model_input_img_size[1],
                                  img_width=model_input_img_size[0])
    saver = tf.train.Saver()
    depth_img = None
    with tf.Session() as sess:
        checkpoint = tf.train.latest_checkpoint(FLAGS.checkpoint_dir)
        saver.restore(sess, checkpoint)
        depth_imgs = inference_model.inference_depth([img_in], sess)
        depth_img = depth_imgs[0]
    print('depth image of dimension: {}\nsample pixel: {}'.format(
        depth_img.shape, depth_img[0, 0]))
    in_img_name = path.splitext(path.basename(FLAGS.input_image_path))[0]
    depth_map_path = '{}/{}_depth.npy'.format(FLAGS.depth_image_dir,
                                              in_img_name)
    # cv2.imwrite(depth_image_path, depth_img)
    np.save(depth_map_path, depth_img)
    logging.info('Depth map written to {}'.format(depth_map_path))
コード例 #39
0
ファイル: water.py プロジェクト: zielmicha/funnyboat-android
    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()
コード例 #40
0
def get_all_predictions(image):

    image_features_extract_model = get_architecture(architecture)
    attention_plot = np.zeros((max_length, attention_features_shape))

    hidden = decoder.reset_state(batch_size=1)

    temp_input = tf.expand_dims(load_image(image)[0], 0)
    img_tensor_val = image_features_extract_model(temp_input)
    img_tensor_val = tf.reshape(
        img_tensor_val, (img_tensor_val.shape[0], -1, img_tensor_val.shape[3]))

    features = encoder(img_tensor_val)

    dec_input = tf.expand_dims([tokenizer.word_index['<start>']], 0)
    result = []

    for i in range(max_length):
        predictions, hidden, attention_weights = decoder(
            dec_input, features, hidden)

        attention_plot[i] = tf.reshape(attention_weights, (-1, )).numpy()

        predicted_id = tf.random.categorical(predictions, 1)[0][0].numpy()
        result.append(tokenizer.index_word[predicted_id])

        if tokenizer.index_word[predicted_id] == '<end>':
            return result, attention_plot

        dec_input = tf.expand_dims([predicted_id], 0)

    attention_plot = attention_plot[:len(result), :]
    return result, attention_plot
コード例 #41
0
    def __init__(self, window: Window):
        super().__init__(window)

        from constants import BUTTON_SIZE

        window_size = window.get_size()
        window_center = (window_size[0] / 2, window_size[1] / 2)

        dpi_factor = window.hidpi_factor

        button_size = (BUTTON_SIZE[0] * dpi_factor,
                       BUTTON_SIZE[1] * dpi_factor)
        button_font = Font('sans-serif', 16, dpi_factor)

        self.bg_image = util.load_image('assets/background.png')

        back_btn = Button(window,
                          '[ Back ]',
                          Vector(window_center[0] - button_size[0] / 2,
                                 window_size[1] * 2 / 3),
                          Vector(*button_size),
                          Color(0, 102, 255),
                          Color(255, 255, 255),
                          Color(0, 80, 230),
                          Color(255, 255, 255),
                          font=button_font)
        back_btn.set_click_handler(self.back)
        self.children.append(back_btn)
コード例 #42
0
    def __init__(self, screen, menu, selection=0):
        self.screen = screen

        if not Menu.sky:
            Menu.sky = util.load_image("taivas")

        self.water = Water.global_water
        self.water_sprite = pygame.sprite.Group()
        self.water_sprite.add(self.water)

        if not Menu.logo:
            Menu.logo = util.load_image("logo")

        self.menu = menu
        self.selection = selection
        self.t = 0
コード例 #43
0
    def __load__(self, index):
        img_path = self.json_data[index]["image"]
        output_img_path = self.json_data[index]["output"]

        img = load_image(img_path)

        return img, output_img_path
コード例 #44
0
ファイル: bike.py プロジェクト: cuadue/touchmoto
    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 = []
コード例 #45
0
ファイル: menu.py プロジェクト: italomaia/turtle-linux
    def __init__(self, screen, menu, selection = 0):
        self.screen = screen

        if not Menu.sky:
            Menu.sky = util.load_image("taivas")

        self.water = Water.global_water
        self.water_sprite = pygame.sprite.Group()
        self.water_sprite.add(self.water)

        if not Menu.logo:
            Menu.logo = util.load_image("logo")

        self.menu = menu
        self.selection = selection
        self.t = 0
コード例 #46
0
ファイル: Hero.py プロジェクト: codelurker/pygame-tiling-test
    def __init__(self, image_filename, levelmap):
        self.levelmap = levelmap

        self.__img = util.load_image(image_filename, False, None)
        order = range(8)
        delay = 4  # each phase of the animation lasts 6 frames
        offset = Vector(0,16)  # the "position-point" of the hero is on
                # his left elbow...
        self.size = 16

        self.__walk_down = Animation(order)
        for down_rect in [ (4+i*24, 0, 16, 31) for i in range(8) ]:
            self.__walk_down.add_frame(self.__img, down_rect, delay, offset)

        self.__walk_up = Animation(order)
        for up_rect in [ (4+i*24, 32, 16, 31) for i in range(8) ]:
            self.__walk_up.add_frame(self.__img, up_rect, delay, offset)

        self.__walk_left = Animation(order)
        for left_rect in [ (4+i*24, 64, 16, 31) for i in range(8) ]:
            self.__walk_left.add_frame(self.__img, left_rect, delay, offset)

        self.__walk_right = Animation(order)
        for right_rect in [ (4+i*24, 96, 16, 31) for i in range(8) ]:
            self.__walk_right.add_frame(self.__img, right_rect, delay, offset)

        # initial values
        self.state = self.DOWN_WALK
        # Coordinates are relative to the map - not to the screen!
        self.pos = Vector(0,0)
        self.speed = 2
コード例 #47
0
ファイル: map.py プロジェクト: bpa/renegade
    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
コード例 #48
0
def main():
    # TODO: Erase dummy net
    net = None
    """
    TODO: Comment in
    deploy_fpath = 'deploy.prototxt'
    model_fpath = 'model.protobinary'

    caffe.set_mode_gpu()
    net = caffe.Net(deploy_fpath, model_fpath, caffe.TEST)
    """

    bpath = '../yandere-crawler/illust/'

    code_db = []

    # TODO: For train.txt
    with open('./test.txt') as f:
        for line in f:
            preview_fpath, _ = line.rstrip().split(' ')
            preview_fpath = bpath + preview_fpath

            print preview_fpath

            # Make BGR 227x227 image
            data = util.load_image(preview_fpath)

            # Make code
            code = util.make_code(net, data)

            code_db.append((code, preview_fpath))

    with open('./code_db.pickle', 'wb') as f:
        pickle.dump(code_db, f)
コード例 #49
0
def get_colorvariance_features(data_path, pickle_name):
    """
    Get Variance of Image Patch
    """
    size = len(data_path)
    rowPatchCnt = 4
    colPatchCnt = 4
    var_features = np.zeros((size, colPatchCnt*rowPatchCnt*3))
    print var_features.shape

    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
        im = np.array(im)

        #print "***** ", i,"th image, shape : ",  im.shape, " *****"
        #print "patchW = ", patchW
        #print "patchH = ", patchH

        #print "{}'s im shape {}".format(i, im.shape)
        for w in range(rowPatchCnt):
            for h in range(rowPatchCnt):
                #print "feature idx : ", 3*(w*rowPatchCnt+h), 3*(w*rowPatchCnt+h+1)
                #print "input : ", np.std(im[h*patchH:(h+1)*patchH, w*patchW:(w+1)*patchW].reshape((patchW*patchH, 3)), axis=0)
                var_features[i, 3*(w*rowPatchCnt+h):3*(w*rowPatchCnt+h+1)] = np.std(im[h*patchH:(h+1)*patchH, w*patchW:(w+1)*patchW].reshape((patchW*patchH, 3)), axis=0)

    pickle.dump(var_features, open(pickle_name, 'wb'), protocol=2)
コード例 #50
0
ファイル: water.py プロジェクト: italomaia/turtle-linux
    def __init__(self):
        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 = util.load_image("rasteri")

        self.water_levels = []
        for i in xrange(self.rect.width):
            self.water_levels.append(0.0)
        self.t = 0


        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

        self.xmul = 2.0 * math.pi / self.wavelength / float(SCREEN_WIDTH)
        self.tmul = math.pi * 2.0 / float(FPS) * self.speed

        self.image=self.image.convert_alpha()
        #~ if Variables.alpha:
            #~ self.image.set_alpha(110)

        self.update()
コード例 #51
0
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
コード例 #52
0
    def detect_files(self,
                     base_dir,
                     names,
                     centers=None,
                     dataset=None,
                     max_batch=64,
                     is_flip=False):
        assert max_batch > 0
        if dataset is None:
            dataset = self._dataset

        batch_imgs = []
        batch_centers = []
        results = []
        for idx, name in enumerate(names):
            img = util.load_image(dataset,
                                  os.path.join(base_dir, name),
                                  is_flip=is_flip)
            batch_imgs.append(img)
            if centers is None:
                batch_centers.append(self._center_loader(img))
            else:
                batch_centers.append(centers[idx, :])

            if len(batch_imgs) == max_batch:
                for line in self.detect_images(batch_imgs, batch_centers):
                    results.append(line)
                del batch_imgs[:]
                del batch_centers[:]
                print('{}/{}'.format(idx + 1, len(names)))
        if batch_imgs:
            for line in self.detect_images(batch_imgs, batch_centers):
                results.append(line)
        print('done!')
        return np.array(results)
コード例 #53
0
ファイル: water.py プロジェクト: AMDmi3/funnyboat
    def __init__(self):
        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 = util.load_image("rasteri")

        self.water_levels = []
        for i in range(self.rect.width):
            self.water_levels.append(0.0)
        self.t = 0

        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

        self.xmul = 2.0 * math.pi / self.wavelength / float(SCREEN_WIDTH)
        self.tmul = math.pi * 2.0 / float(FPS) * self.speed

        self.image = self.image.convert_alpha()
        #~ if Variables.alpha:
        #~ self.image.set_alpha(110)

        self.update()
コード例 #54
0
    def __init__(self, world: 'World', level: int, start_pos: Tuple[int, int],
                 scroll: Vector = Vector(0.05, 0)):
        self.level = level
        self.start_pos = Vector(
            start_pos[0] * BLOCK_SIZE,
            (GRID_SIZE[1] - start_pos[1] - 1) * BLOCK_SIZE
        )

        self.offset = Vector(0, 0)
        self.scroll = scroll

        self.items: List[LevelItem] = []
        self.finished = False

        self.counter = 0
        self.world = world
        self.world.source.last_active_level = self

        self.window_size = world.window.get_size()

        # Just some initialisation stuff here; less to compute later.
        self.background_offset = self.window_size[0] / 2
        self.background_image = load_image(LEVEL_BACKGROUND_IMAGE)
        self.bg_size = (self.background_image.get_width(), self.background_image.get_height())
        self.bg_center = (self.bg_size[0] / 2, self.bg_size[1] / 2)
コード例 #55
0
ファイル: view.py プロジェクト: riedelcastro/wumpusworld
    def __init__(self, group=None):
        pygame.sprite.Sprite.__init__(self, group)
        self.image = pygame.Surface((769, 50))
        self.image.fill(color['background'])
        self.text = ''
        self.ready = True
        self.light = False
        self.timer = 0

        self.red_light, self.red_pos = \
                        load_image('red_light.png', -1)
        self.green_light, self.green_pos = \
                          load_image('green_light.png', -1)
        self.red_pos.midleft = \
                             self.image.get_rect().move(10, 0).midleft
        self.green_pos.midleft = \
                               self.image.get_rect().move(10, 0).midleft
コード例 #56
0
ファイル: actor.py プロジェクト: facepalm/bliss-station-game
 def refresh_image(self):
     if gv.config['GRAPHICS'] == 'pyglet': 
         import graphics_pyglet           
         if self.sprite: self.sprite.delete()
         
         self.sprite = graphics_pyglet.LayeredSprite(name=self.name,batch=util.actor_batch )     
         self.sprite.add_layer('ActorBase',util.load_image("images/npc_crafty_bot__x1_idle0_png_1354839494_crop.png"))
         self.sprite.owner = self
コード例 #57
0
ファイル: ball.py プロジェクト: Margaruga/Games
 def __init__(self):
     self.sprite = util.load_image(Config.path_ballsprite)
     self.rect   = self.sprite.get_rect()
     self.rect.centerx = Config.widthwindow // 2
     self.rect.centery = random.randrange(0, Config.heightwindow - self.rect.h)
     self.dx = random.choice((1, -1))
     self.dy = random.choice((1, -1))
     self.speed = 1
コード例 #58
0
ファイル: menu.py プロジェクト: gruposeminario/ataleofmagick
 def __init__(self, screen):
   Menu.__init__(self, screen)
   self.x = 180
   self.y = 125
   self.increment = 40
   self.active = True
   self.current_option = 0
   self.background = load_image("ATOM.png")
   self.MenuOptions = ["Go Back"]
コード例 #59
0
ファイル: menu.py プロジェクト: gruposeminario/ataleofmagick
 def __init__(self, screen):
   Menu.__init__(self, screen)
   self.x = 180
   self.y = 125
   self.increment = 40
   self.active = True
   self.current_option = 0
   self.background = load_image("ATOM.png")
   self.MenuOptions = ["Begin Adventure", "Load Adventure", "Settings", "Quit"]