Example #1
0
 def spawn_squid(self):
     spawn_location = (int(random() * IMAGE_WIDTH * ROW_LENGTH),
                       int(random() * IMAGE_HEIGHT * ROW_LENGTH))
     if random() <= SPAWN_RATE * 1.2 and math.sqrt(
         ((self.player.get_location()[0] - spawn_location[0])**2) +
         (self.player.get_location()[1] - spawn_location[1])**2) >= 50:
         self.squids.append(Squid((40, 40), spawn_location))
Example #2
0
    def __init__(self, setting: settings, shoot_sound):
        self.shoot_sound = shoot_sound
        self.fleet = list()
        self.move_speed = setting.alien_speed
        self.creep_speed = setting.creep_speed
        self.gun = Gun(setting)
        self.setting = setting
        self.saucer = Saucer(setting, Vector2(-64, 64 * 2))

        for i in range(10):
            self.fleet.append(Squid(setting, pygame.Vector2(70 * i, 70)))
        for i in range(10):
            self.fleet.append(Squid(setting, pygame.Vector2(70 * i, 70 * 2)))
        for i in range(10):
            self.fleet.append(Jelly(setting, pygame.Vector2(70 * i, 70 * 3)))
        for i in range(10):
            self.fleet.append(Jelly(setting, pygame.Vector2(70 * i, 70 * 4)))
        for i in range(10):
            self.fleet.append(Crab(setting, pygame.Vector2(70 * i, 70 * 5)))
        for i in range(10):
            self.fleet.append(Crab(setting, pygame.Vector2(70 * i, 70 * 6)))
Example #3
0
    def __call__(self, download_path, target, debug=False, log=None, force=False):
        if log is None:
            log = lambda s: None

        if self.time:
            opts = [("restore-time", self.time)]
        else:
            opts = []

        if iamroot():
            log("// started squid: caching downloaded backup archives to " + self.cache_dir + "\n")

            squid = Squid(self.cache_size, self.cache_dir)
            squid.start()

            orig_env = os.environ.get('http_proxy')
            os.environ['http_proxy'] = squid.address

        _raise_rlimit(resource.RLIMIT_NOFILE, RLIMIT_NOFILE_MAX)
        args = [ '--s3-unencrypted-connection', target.address, download_path ]
        if force:
            args = [ '--force' ] + args

        command = Duplicity(opts, *args)

        log("# " + str(command))

        command.run(target.secret, target.credentials, debug=debug)

        if iamroot():
            if orig_env:
                os.environ['http_proxy'] = orig_env
            else:
                del os.environ['http_proxy']

            log("\n// stopping squid: download complete so caching no longer required\n")
            squid.stop()

        sys.stdout.flush()
Example #4
0
    def __call__(self, download_path, target):
        if self.time:
            opts = [("restore-time", self.time)]
        else:
            opts = []

        squid = Squid(self.cache_size, self.cache_dir)
        squid.start()

        orig_env = os.environ.get('http_proxy')
        os.environ['http_proxy'] = squid.address

        _raise_rlimit(resource.RLIMIT_NOFILE, RLIMIT_NOFILE_MAX)
        Duplicity(opts, '--s3-unencrypted-connection', target.address, download_path).run(target.secret, target.credentials)

        if orig_env:
            os.environ['http_proxy'] = orig_env
        else:
            del os.environ['http_proxy']

        sys.stdout.flush()

        squid.stop()
Example #5
0
def create_alien(game_settings,
                 screen,
                 aliens,
                 alien_number,
                 row_number,
                 enemy_type=1):
    alien = Alien(game_settings, screen)
    if enemy_type == 2:
        alien = Squid(game_settings, screen)
    elif enemy_type == 3:
        alien = Virus(game_settings, screen)

    alien_width = alien.rect.width
    alien.x = alien_width + 2 * alien_width * alien_number
    alien.rect.x = alien.x
    alien.rect.y = alien.rect.height + 1.1 * alien.rect.height * row_number
    aliens.add(alien)
Example #6
0
 def gen_sprites(self):
     self.sprite_models.append(
         Crab(
             self.setting,
             Vector2(self.screen_dim.x / 2 - 128,
                     self.screen_dim.y / 10 * 3)))
     self.sprite_models.append(
         Jelly(
             self.setting,
             Vector2(self.screen_dim.x / 2 - 128,
                     self.screen_dim.y / 10 * 4)))
     self.sprite_models.append(
         Squid(
             self.setting,
             Vector2(self.screen_dim.x / 2 - 128,
                     self.screen_dim.y / 10 * 5)))
     self.sprite_models.append(
         Saucer(
             self.setting,
             Vector2(self.screen_dim.x / 2 - 128,
                     self.screen_dim.y / 10 * 6)))
Example #7
0
    def __call__(self,
                 download_path,
                 target,
                 debug=False,
                 log=None,
                 force=False):
        if log is None:
            log = lambda s: None

        if self.time:
            opts = [("restore-time", self.time)]
        else:
            opts = []

        if iamroot():
            log("// started squid: caching downloaded backup archives to " +
                self.cache_dir + "\n")

            squid = Squid(self.cache_size, self.cache_dir)
            squid.start()

            orig_env = os.environ.get('http_proxy')
            os.environ['http_proxy'] = squid.address

        _raise_rlimit(resource.RLIMIT_NOFILE, RLIMIT_NOFILE_MAX)
        args = ['--s3-unencrypted-connection', target.address, download_path]
        if force:
            args = ['--force'] + args

        command = Duplicity(opts, *args)

        log("# " + str(command))

        command.run(target.secret, target.credentials, debug=debug)

        if iamroot():
            if orig_env:
                os.environ['http_proxy'] = orig_env
            else:
                del os.environ['http_proxy']

            log("\n// stopping squid: download complete so caching no longer required\n"
                )
            squid.stop()

        sys.stdout.flush()