Exemplo n.º 1
0
    def __init__(self):

        super(TBoard, self).__init__()
        self.schedule(self.step)
        self.DM = Donut_M()
        self.sprites_list = dict()
        self.points = 0
        self.running_sprites = []
        self.label = self.update_score()
        self.draw_initiation()
        self.good_song = Sound("sounds/good.wav")
        self.bad_song = Sound("sounds/bad.wav")
Exemplo n.º 2
0
 def __init__(self):
     mixer.init()
     super(Audiolayer, self).__init__()
     self.path = os.getcwd()
     os.chdir(self.path[0:-4])
     self.sound = Sound('audio/test.ogg')
     self.sound.play(-1)
Exemplo n.º 3
0
Arquivo: llama.py Projeto: mre/llama
    def __init__(self):
        super(Game, self).__init__(0, 80, 125, 0)

        self.block_pic = "assets/img/heart.png"
        for pos in [(100, 100), (540, 380), (540, 100), (100, 380)]:
            self.add(Block(pos[0], pos[1], self.block_pic))
        self.lama = Lama(WIDTH / 2, 100)
        self.add(self.lama)

        cell = self.lama.width * 1.25
        self.collman = cm.CollisionManagerGrid(0, 640, 0, 480, cell, cell)

        self.pressed = defaultdict(int)
        self.schedule(self.update)

        self.kiss_sound = Sound("assets/sound/kiss.ogg")
        self.jump_sound = Sound("assets/sound/jump.ogg")
Exemplo n.º 4
0
    def __init__(self, filename):
        """Initialize the effect

        :Parameters:
            `filename` : path of a WAV or Ogg audio file
        """
        if audio._working:
            self.sound = Sound(filename)
        else:
            self.sound = None
        self.action = actions.PlayAction(self.sound)
Exemplo n.º 5
0
    def __init__(self, state):
        super(FallingBoxesLayer, self).__init__()
        self.s = state
        self.__bps_granularity = 8.0 #beats per second
        self.boxes = []
        for range in g.keyBindings:
            self.boxes.append([])
        self.__barCounter = 0 #which "beat" of the current musical "bar" are we on

        self.sounds = []
        for s in g.hitboxSounds:
            self.sounds.append(Sound(s))
        self.missSounds = []
        for s in g.hitboxMissSounds:
            self.missSounds.append(Sound(s))
        
        ###"public api" stuff...
        self.maxBPS = 1
        self.ratioSkips = 0.0
        self.ratioInbetweeners = 0
        ###

        self.schedule_interval(self.generateBox, 1/self.__bps_granularity)
Exemplo n.º 6
0
    def __init__(self, file):
        super(StateMachine, self).__init__()
        data = json.load(open(file, "r", encoding="utf8"))
        self.storage = data.pop("storage")
        self.resouces = data.pop("resources")
        self.states = data
        self.current_state = "start"
        self.timer = 0  # timer for animations
        self.anim = 0  # counter for animations
        self.key_events = {}
        self.env = std_env

        if "image" in self.resouces:
            for k, v in self.resouces["image"].items():
                if isinstance(v, str):
                    self.resouces["image"][k] = pyglet.image.load(r_path(v))
                elif isinstance(v, list):
                    # format for animations - ["file.png", cols, rows, time for each frame]
                    t_spritesheet = pyglet.image.load(r_path(v[0]))
                    t_tex = pyglet.image.TextureGrid(
                        pyglet.image.ImageGrid(t_spritesheet, v[1], v[2]))
                    self.resouces["image"][
                        k] = pyglet.image.Animation.from_image_sequence(
                            t_tex, v[3])
        else:
            raise IndexError("No drawables detected!")

        if "sound" in self.resouces:
            for k, v in self.resouces["sound"].items():
                self.resouces["sound"][k] = Sound(r_path(v))
                self.resouces["sound"][k].set_volume(0.5)

        # initializing the images to the 'start' state
        s_state = self.states['start']['anim'][0]

        self.sprite = cocos.sprite.Sprite(
            self.resouces['image'][s_state['image']], (320, 180))
        eff = (s_state['effect'],
               s_state['time']) if 'effect' in s_state else None
        self.update_sprite(image=s_state['image'], effect=eff)
        self.label = cocos.text.Label(">", x=50, y=280)
        self.add(self.label)
        self.add(self.sprite)
        self.schedule(self.update)
Exemplo n.º 7
0
    def __init__(self):
        super(HelloWorld, self).__init__()

        label = cocos.text.Label('Hello, World!',
                                 font_name='Times New Roman',
                                 font_size=32,
                                 anchor_x='center',
                                 anchor_y='center')

        label.position = 320, 240
        self.add(label)
        # 只支持ogg格式
        audio = Sound("bounce.ogg")
        # audio.play(-1)
        scroll_layer = ScrollableLayer()
        map1 = cocos.tiles.load("110.tmx")['1']
        scroll_layer.add(map1)
        # colorLayer = ColorLayer(64, 200, 64, 255)
        # colorLayer.scale = 0.2
        # self.add(colorLayer)
        # colorLayer.do(Rotate(360, 3))
        # print(colorLayer.anchor)
        self.add(scroll_layer)
Exemplo n.º 8
0
 def get_sound(self, name: str) -> Sound:
     if name not in self._sounds:
         sound_file_name = self.sound_file_paths[name]
         sound_file_path = self._path_manager.path(sound_file_name)
         self._sounds[name] = Sound(sound_file_path)
     return self._sounds[name]