Esempio n. 1
0
 def __init__(self, caption=None, icon=None):
     super().__init__(caption, icon)
     self.snake = Snake()
     self.food = Food()
     self.food_consumed_sound = Sound("consumed.wav")
     self.death_sound = Sound("death.mp3")
     self.bg_sound = Sound("background.mp3")
     self.background = Background()
     self.play = False
     self.score = 0
     self.game_over = False
     self.delay = 3
     self.snake_die_time = None
Esempio n. 2
0
    def __init__(self):
        pygame.init()
        self.background_sound = Sound()

        pygame.key.set_repeat(50, 50)
        size = [SCREEN_WIDTH, SCREEN_HEIGHT]

        self.screen = pygame.display.set_mode(size)
        pygame.display.set_caption(TITLE)

        self.clock = pygame.time.Clock()
        self.font_name = pygame.font.match_font(FONT)

        self.running = True
        self.isover = False
        self.gameispaused = False
        self.levels = {
            1: Level_01,
            2: Level_02,
            3: Level_03,
            4: Level_04,
            5: Level_05,
            6: Level_06,
            7: Level_07,
            8: Level_08,
            9: Level_09,
            10: Level_10
        }

        self.show_start_screen()
Esempio n. 3
0
    def func(state, index, locus):
        term = state[index]
        term_value = term.get_at(locus)
        new_value = None
        add_part = False

        # 1.1.54 ādeḥ parasya
        if adi:
            try:
                new_value = sthani.value + term_value[1:]
            except AttributeError:
                new_value = sthani + term_value[1:]

        elif isinstance(sthani, basestring):
            # 1.1.52 alo 'ntyasya
            # 1.1.55 anekālśit sarvasya
            if len(sthani) <= 1:
                new_value = term_value[:-1] + sthani
            else:
                new_value = sthani

        elif not hasattr(sthani, 'value'):
            # 1.1.50 sthāne 'ntaratamaḥ
            last = Sound(term.antya).closest(sthani)
            new_value = term_value[:-1] + last

        # 1.1.47 mid aco 'ntyāt paraḥ
        elif 'mit' in sthani.samjna:
            ac = Sounds('ac')
            for i, L in enumerate(reversed(term_value)):
                if L in ac:
                    break
            new_value = term_value[:-i] + sthani.value + term_value[-i:]
            add_part = True

        # 1.1.46 ādyantau ṭakitau
        elif 'kit' in sthani.samjna:
            new_value = term_value + sthani.value
            add_part = True
        elif 'wit' in sthani.samjna:
            new_value = sthani.value + term_value
            add_part = True

        # 1.1.52 alo 'ntyasya
        # 1.1.53 ṅic ca
        elif len(sthani.value) == 1 or 'Nit' in sthani.samjna:
            new_value = term_value[:-1] + sthani.value

        # 1.1.55 anekālśit sarvasya
        elif 'S' in sthani.it or len(sthani.value) > 1:
            new_value = sthani.value

        if new_value is not None:
            new_term = term.set_at(locus, new_value)
            if add_part:
                new_term = new_term.add_part(sthani.raw)
            return state.swap(index, new_term)

        raise NotImplementedError(sthani)
Esempio n. 4
0
 def func(value):
     letters = list(value)
     for i, L in enumerate(letters):
         if L in target:
             letters[i] = Sound(L).closest(result)
             # 1.1.51 ur aṇ raparaḥ
             if L in 'fF' and letters[i] in Sounds('aR'):
                 letters[i] += 'r'
             break
     return ''.join(letters)
Esempio n. 5
0
 def on_create(self):
     """Called when an object is created"""
     self.sound_player = Sound("FOREST")
     self.set_background()
     self.set_hero()
     self.set_blocks()
     self.set_enemies()
     self.set_coins()
     self.set_healing()
     self.set_checkpoints()
     self.set_spritegroups()
Esempio n. 6
0
    def __init__(self, parent, name='Anonymus'):
        Location.__init__(self, parent, background)
        pygame.key.set_repeat(10)
        pygame.mouse.set_visible(mouse_enabled)

        self.sound = Sound()

        self.doodle = Doodle(name)
        self.allsprites = pygame.sprite.Group()
        self.allsprites.add(self.doodle)

        for i in range(0, platform_count):
            self.allsprites.add(self.randomPlatform(False))
        for platform in self.allsprites:
            if isinstance(platform, Platform) and platform.spring != None:
                self.allsprites.add(platform.spring)

        self.score = Score(50, 25, self.doodle.name, 45, (0, 0, 0))
        self.allsprites.add(self.score)
        self.window.blit(self.background, (0, 0))
Esempio n. 7
0
def samprasarana(value):
    rev_letters = list(reversed(value))
    found = False
    for i, L in enumerate(rev_letters):
        # 1.1.45 ig yaNaH saMprasAraNAm
        # TODO: enforce short vowels automatically
        if L in Sounds('yaR'):
            rev_letters[i] = Sound(L).closest('ifxu')
            found = True
            break

    if not found:
        return value

    # 6.4.108 saMprasAraNAc ca
    try:
        L = rev_letters[i - 1]
        if L in Sounds('ac'):
            rev_letters[i - 1] = ''
    except IndexError:
        pass

    return ''.join(reversed(rev_letters))
Esempio n. 8
0
def ac_sandhi(x, y):
    """Apply the rules of ac sandhi to `x` as followed by `y`.

    These rules are from 6.1. A rule is part of ac sandhi iff the first
    letter is a vowel.

    :param x: the first letter.
    :param y: the second letter.
    """

    # 6.1.97 ato guNe
    if x == 'a' and y in Sounds('at eN'):
        x = ''

    # 6.1.101 akaH savarNe dIrghaH
    elif Sound(x).savarna(y):
        x = ''
        y = dirgha(y)

    # 6.1.77 iko yaN aci
    elif x in Sounds('ik') and y in Sounds('ac'):
        x = iko_yan_aci(x)

    # 6.1.78 eco 'yavAyAvaH
    elif x in Sounds('ec') and y in Sounds('ac'):
        converter = dict(zip('eEoO', 'ay Ay av Av'.split()))
        x = converter[x]

    elif x in 'aA' and y in Sounds('ic'):
        x = ''

        # 6.1.87 Ad guNaH
        # 6.1.88 vRddhir eci
        y = vrddhi(y) if y in Sounds('ec') else guna(y)

    return x, y
Esempio n. 9
0
    def load_sounds(self, score_cutoff=None, base_cost_cutoff=None):

        self.sounds = OrderedDict()

        sound_list = self.db.execute("SELECT * from sounds order by votes desc, name asc")

        for dbsound in sound_list:
            sound = Sound(
                name=dbsound["name"],
                file_name=dbsound["path"],
                votes=dbsound["votes"],
                cost=dbsound["cost"],
                base_cost=dbsound["base_cost"],
                downvotes=dbsound["downvotes"],
                date_added=dt.datetime.fromtimestamp(dbsound["date_added"]),
                sound_player=self.sound_player,
            )
            if score_cutoff and sound.get_score() < score_cutoff:
                continue
            if base_cost_cutoff and sound.base_cost > base_cost_cutoff:
                continue
            self.sounds[sound.name] = sound

        return self.sounds
Esempio n. 10
0
def asiddha_helper(state):
    """Chapter 8.2 of the Ashtadhyayi starts the 'asiddha' section of
    the text:

        8.2.1 pUrvatrAsiddham

    The asiddha section lasts until the end of the text, and for that
    reason, it is often called the tripAdI ("having three pAdas").

    The rules in the tripAdI are treated as not having taken effect
    ('asiddha') as far as the prior rules are concerned. This is an
    abstract notion, but practically it means that these are the last
    rules we apply in a derivation.

    :param state:
    """

    had_rs = False

    editor = SoundEditor(state)
    for c in editor:
        p = c.prev
        n = c.next
        n2 = n.next

        w, x, y, z = (p.value, c.value, n.value, n2.value)

        # 8.2.29 skoH saMyogAdyor ante ca
        # TODO: pada end
        if x in 'sk' and y in Sounds('hal') and z in Sounds('Jal'):
            x = '_'

        if y in Sounds('Jal'):
            # 8.2.30 coH kuH
            cu = Sounds('cu')
            if x in cu and y in Sounds('Jal') and y not in cu:
                x = Sound(x).closest(Sounds('ku'))

            # 8.2.31 ho DhaH
            elif x == 'h':
                x = 'Q'

            # 8.2.36 vrazca-bhrasja-sRja-mRja-yaja-rAja-bhrAjacCazAM SaH
            roots = {'vraSc', 'Brasj', 'sfj', 'mfj', 'yaj', 'rAj', 'BrAj'}
            if c.last and (c.term.value in roots or c.term.antya in 'SC'):
                x = 'z'

        # 8.2.40 (TODO: not dhA)
        if w in Sounds('Jaz') and x in 'tT':
            x = 'D'
        elif x == 'D' and y in 'tT':
            continue

         # 8.2.41 SaDhoH kaH si
        elif x in 'zQ' and y == 's':
            x = 'k'

        # 8.2.41 SaDhoH kaH si
        if x in 'zQ' and y == 's':
            x = 'k'

        # 8.3.23 mo 'nusvAraH
        # elif x == 'm' and y in Sounds('hal'):
        #     x = 'M'

        # 8.3.24 naz cApadAntasya jhali
        elif x in 'mn' and y in Sounds('Jal'):
            x = 'M'

        # 8.3.59 AdezapratyayayoH
        if w in Sounds('iN ku'):
            if not c.last and x == 's' and (c.term.raw[0] == 'z'
                                            or 'pratyaya' in c.term.samjna):
                x = 'z'

        # 8.3.78 iNaH SIdhvaMluGliTAM dho 'GgAt
        # 8.3.79 vibhASeTaH
        # TODO: SIdhvam, luG
        if (x == 'D'
                and w in Pratyahara('iR', second_R=True)
                and c.first  # not triggered by iT
                and 'li~w' in c.term.lakshana):
            x = 'Q'

        # 8.4.1 raSAbhyAM no NaH samAnapade
        # 8.4.2 aTkupvAGnuMvyavAye 'pi
        # According to commentary, 8.4.1 also applies to 'f' and 'F'.
        # TODO: AG, num
        if x in 'rzfF':
            had_rs = True
        elif x == 'n' and had_rs and p.term.value != 'kzuB':
            x = 'R'
            had_rs = False
        elif x not in Sounds('aw ku pu'):
            had_rs = False

        stu = Sounds('s tu')
        if x in stu:

            # 8.4.40 stoH zcunA zcuH
            # 8.4.44 zAt (na)
            scu = Sounds('S cu')
            if w == 'S':
                pass
            elif w in scu or y in scu:
                x = Sound(x).closest(scu)

            # 8.4.41 STunA STuH
            zwu = Sounds('z wu')
            if w in zwu or y in zwu:
                x = Sound(x).closest(zwu)

        if x in Sounds('Jal'):
            x_ = x

            # 8.4.53 jhalAM jaz jhazi
            if y in Sounds('JaS'):
                x = Sound(x_).closest(Sounds('jaS'))

            # 8.4.54 abhyAse car ca
            if 'abhyasa' in c.term.samjna and c.first:
                x = Sound(x_).closest(Sounds('car jaS'))

            # 8.4.55 khari ca
            if y in Sounds('Kar'):
                x = Sound(x_).closest(Sounds('car'))

        # 8.4.58 anusvArasya yayi parasavarNaH
        if x == 'M' and y in Sounds('yay'):
            x = Sound(x).closest(Sound(y).savarna_set)

        c.value = x if x != '_' else ''

    yield editor.join()
Esempio n. 11
0
 def __init__(self):
     pygame.init()
     self.__GameModel = GameModel(self)
     self.__GameView = GameView(self, self.__GameModel)
     self.__sounds = Sound()