Exemple #1
0
 def __init__(self, settings, surface, position):
     super().__init__(settings, surface, position,
                      "resources/images/fire_flower_1.png")
     self.item_type = 3
     images =\
         [pygame.image.load("resources/images/fire_flower_" + str(x) + ".png").convert_alpha() for x in range(1, 4)]
     images.append(
         pygame.image.load(
             "resources/images/fire_flower_2.png").convert_alpha())
     self.sway_animation = Timer(images, wait=250)
Exemple #2
0
 def __init__(self, settings, surface, position, floating=False):
     super().__init__(settings, surface, position,
                      "resources/images/coin_1.png")
     self.item_type = 1
     self.y_limit = 30
     self.floating = floating
     images = [
         pygame.image.load("resources/images/coin_" + str(x) +
                           ".png").convert_alpha() for x in range(1, 5)
     ]
     self.spin_animation = Timer(images)
Exemple #3
0
class FireFlower(Item):
    def __init__(self, settings, surface, position):
        super().__init__(settings, surface, position,
                         "resources/images/fire_flower_1.png")
        self.item_type = 3
        images =\
            [pygame.image.load("resources/images/fire_flower_" + str(x) + ".png").convert_alpha() for x in range(1, 4)]
        images.append(
            pygame.image.load(
                "resources/images/fire_flower_2.png").convert_alpha())
        self.sway_animation = Timer(images, wait=250)

    def update(self, level, scrolling, vel_x=None):
        """Pops out and remains still."""
        if scrolling:
            if vel_x:
                self.rect.x += vel_x
            else:
                self.rect.x += self.scroll_rate
                if self.out_of_bounds():
                    self.kill()
        self.rect.y += self.velocity.y
        if self.rect.bottom >= self.position[1]:
            self.rect.bottom = self.position[1]
        self.fall()

    def draw(self):
        super().set_image(self.sway_animation.get_image())
        super().draw()
 def load_spin_animation(self):
     """Spins while moving."""
     animation = []
     for x in range(4):
         rotated_image = pygame.transform.rotate(self.image, 90 * x)
         animation.append(rotated_image)
     return Timer(animation)
 def load_walk_animation(self, wait):
     animation = []
     for x in range(self.data["frames"]["walking"]["sequence_sz"] - 1):
         animation.append(
             pygame.image.load(self.data["frames"]["walking"]["sequence"]
                               [x]).convert_alpha())
     return Timer(animation, wait)
Exemple #6
0
 def getWithLength(self, lengthBySeconds, outputPath, overWrite=True) :
     lengthOfVideo, lengthBySeconds = int(self.getDuration()), int(lengthBySeconds)
     start = random.randint(0, lengthOfVideo - lengthBySeconds)
     lengthBySeconds = Timer().convertToString(lengthBySeconds)
     start = Timer().convertToString(start)
     if overWrite :
         if os.path.isfile(outputPath) :
             os.remove(outputPath)
     command = self.commands['getSub'].format(
         self.program, 
         start,
         self.audioPath,
         lengthBySeconds,
         outputPath
     )
     text, exitCode = executor.runCommand(command)
     return exitCode == 0
 def __init__(self):
     today = Timer().getTodayString()
     self.rawDirectory = os.path.join(config['Local']['videoPath'], today,
                                      'raw')
     self.listFiles = set(
         open(os.path.join(self.rawDirectory,
                           'files.txt')).read().splitlines())
     self.internetDirectory = config['Internet']['videoPath']
Exemple #8
0
def load_fire_animation():
    animation = []
    normal_image = pygame.image.load("resources/images/mw1.png").convert_alpha()
    fire_image = pygame.image.load("resources/images/fm1.png").convert_alpha()
    for i in range(4):
        animation.append(fire_image)
        animation.append(normal_image)
    animation.append(fire_image)
    return Timer(animation, wait=80, loop_once=True)
 def load_death_animation(self):
     """Shrinks when collided with terrain."""
     animation = []
     death_image = pygame.image.load(
         "resources/images/boom.png").convert_alpha()
     for x in range(1, 7):
         scale = self.rect.width - 2 * x, self.rect.height - 2 * x
         scaled_image = pygame.transform.scale(death_image,
                                               scale).convert_alpha()
         animation.append(scaled_image)
     return Timer(animation, wait=self.death_delay / 6)
 def __init__(self):
     localPath = os.path.join(config['Local']['videoPath'],
                              Timer().getTodayString())
     self.inputFolder = os.path.join(localPath, 'preprocessed')
     self.tempFolder = os.path.join(localPath, 'temp')
     self.trashFolder = os.path.join(localPath, 'trash')
     self.outputFolder = os.path.join(localPath, 'done')
     self.videoSize = int(config['Video']['videoSize'])
     self.extensionAllowed = config['Video']['extension'].split(',')
     self.acceptSAR = config['Video']['acceptSAR'].strip()
     self.outputExtension = 'mp4'
     self.audioFolder = config['Local']['musicPath']
 def __init__(self):
     localPath = os.path.join(
         config['Local']['videoPath'], 
         Timer().getTodayString()
     )
     self.inputFolder  = os.path.join(localPath, 'raw')
     self.tempFolder   = os.path.join(localPath, 'temp')
     self.outputFolder = os.path.join(localPath, 'preprocessed')
     self.lastSeconds  = 4
     self.scaleSize = config['Video']['scaleSize']
     self.extensionAllowed = config['Video']['extension'].split(',')
     self.errorFiles = []
Exemple #12
0
 def __init__(self):
     today = Timer().getTodayString()
     videoPath = os.path.join(config['Local']['videoPath'], today)
     if not os.path.isdir(videoPath):
         os.makedirs(videoPath)
     for key, val in self.videoStructure.items():
         currentPath = os.path.join(videoPath, key)
         if not os.path.isdir(currentPath):
             os.makedirs(currentPath)
         if 'files' in val:
             filePath = os.path.join(currentPath, val['files'])
             if not os.path.isfile(filePath):
                 f = open(filePath, 'w')
                 f.close()
Exemple #13
0
def load_bigger_animation():
    animation = []
    small_image = pygame.image.load("resources/images/s_mw1.png").convert_alpha()
    scale = small_image.get_rect().width, small_image.get_rect().height + 5
    medium_image = pygame.transform.scale(small_image, scale).convert_alpha()
    scale = small_image.get_rect().width, small_image.get_rect().height + 10
    big_image = pygame.transform.scale(small_image, scale).convert_alpha()
    bigger_image = pygame.image.load("resources/images/mw1.png").convert_alpha()
    animation.append(medium_image)
    animation.append(big_image)
    animation.append(bigger_image)
    animation.append(big_image)
    animation.append(medium_image)
    animation.append(small_image)
    animation.append(medium_image)
    animation.append(big_image)
    animation.append(bigger_image)
    return Timer(animation, wait=80, loop_once=True)
 def reduceVideo(self,
                 lastSeconds,
                 outputPath,
                 overWrite=True,
                 removeOld=False):
     lengthOfVideo = self.getDuration()
     lengthOfVideo -= lastSeconds
     lengthOfVideo = Timer().convertToString(lengthOfVideo)
     if overWrite:
         if os.path.isfile(outputPath):
             os.remove(outputPath)
     command = self.commands['reduceVideo'].format(self.program,
                                                   self.videoPath,
                                                   lengthOfVideo,
                                                   outputPath)
     _, exitCode = executor.runCommand(command)
     success = (exitCode == 0)
     if success and removeOld:
         os.remove(self.videoPath)
     return success
Exemple #15
0
class Coin(Item):
    def __init__(self, settings, surface, position, floating=False):
        super().__init__(settings, surface, position,
                         "resources/images/coin_1.png")
        self.item_type = 1
        self.y_limit = 30
        self.floating = floating
        images = [
            pygame.image.load("resources/images/coin_" + str(x) +
                              ".png").convert_alpha() for x in range(1, 5)
        ]
        self.spin_animation = Timer(images)

    def update(self, level, scrolling, vel_x=None):
        """Pops out and disappears."""
        if scrolling:
            if vel_x:
                self.rect.x += vel_x
            else:
                self.rect.x += self.scroll_rate
            if self.out_of_bounds():
                self.kill()
        if not self.floating:
            self.rect.y += self.velocity.y
            if self.rect.bottom >= self.position[1]:
                self.rect.bottom = self.position[1]
            self.fall()

    def draw(self):
        super().set_image(self.spin_animation.get_image())
        if not self.floating:
            self.y_limit -= 2
            if self.y_limit < 0:
                self.kill()
            else:
                self.rect.y -= 4
        super().draw()
Exemple #16
0
 def load_walk_animation(self, animation_speed):
     animation = []
     for x in range(self.data[self.state]["walking"]["sequence_sz"]):
         animation.append(pygame.image.load(self.data[self.state]["walking"]["sequence"][x]).convert_alpha())
     return Timer(animation, wait=animation_speed)