예제 #1
0
 def __init__(self,fail):
     super(VF_Layer, self).__init__()
     if fail:
         self.count = 0
         self.bg = BG(bg_name="img/fail_bg.jpg")
         self.fail_window=Sprite("img/f_window.png")
         self.fail_window.position=620,350
         self.lable1 = cocos.text.Label('就', font_name='Times New Roman', font_size=200)
         self.lable1.position = 10, 170
         self.lable2 = cocos.text.Label('这', font_name='Times New Roman', font_size=200)
         self.lable2.position = 900, 170
         self.add(self.bg)
         self.add(self.fail_window)
         mixer.init()
         music.load((address_2 + r"/sound/fail.mp3").encode())
         music.play()
         music.set_volume(1.5)
     else:
         self.count=0
         self.vic_bg=BG(bg_name="img/vic_bg.jpg")
         self.vic_word=Sprite("img/vic_word.png")
         self.vic_word.position=600,400
         self.A_word=Sprite("img/A_word.png")
         self.A_word.position=700,500
         self.add(self.vic_bg)
         self.add(self.vic_word)
         self.add(self.A_word)
         self.mr_cai = Mr_cai()
         self.add(self.mr_cai)
         mixer.init()
         music.load((address_2 + r"/sound/happy_bgm.mp3").encode())
         music.play()
         music.set_volume(0.5)
예제 #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)
 def mainloop(self, runtime):
     mixer.init()
     director.init(width=CocosView.WIDTH, height=CocosView.HEIGHT, caption=CocosView.TITLE)
     self._runtime = runtime
     self._init_interface()
     self._scene.schedule(self._update)
     self._scene.schedule_interval(self._render_dialogue, CocosView.DIALOGUE_DELAY)
     director.run(self._scene)
    def __init__(self):
        #INITILIZE ALL RESOURCES HERE
        mixer.init()
        gVariables.g_RESOURCES = gameResources.Resources()

        #INIT MUSIC
        global PLAYMUSIC
        PLAYMUSIC = PlayMusic(gVariables.g_RESOURCES)
예제 #5
0
파일: audio.py 프로젝트: zjingcong/metro
    def __init__(self):
        mixer.init()

        conf = ConfigParser.ConfigParser()
        conf.read("config.conf")
        self.music_path = "{current_dir}/{path}{name}".format(current_dir=CURRENT_DIR,
                                                              path=conf.get("music", "MUSIC"),
                                                              name="Kung Fu Fighting.wav")
        super(musicAudio, self).__init__(self.music_path)
예제 #6
0
파일: audio.py 프로젝트: zjingcong/metro
    def __init__(self):
        mixer.init()

        conf = ConfigParser.ConfigParser()
        conf.read("config.conf")
        self.metro_sound_file = "{current_dir}/{path}{name}".format(current_dir=CURRENT_DIR,
                                                                    path=conf.get("path", "SCENE_BLACK_AUDIO"),
                                                                    name="metro.wav")
        super(metroAudio, self).__init__(self.metro_sound_file)
예제 #7
0
파일: llama.py 프로젝트: mre/llama
def main():
    mixer.init()

    director.init(caption="Llama!!!", width=WIDTH, height=HEIGHT)
    scene = Scene()
    scene.add(AudioLayer())
    scene.add(Background(), z=0)
    scene.add(Game(), z=1)
    director.run(scene)
    director.show_FPS()
예제 #8
0
def loadSound(filename, volume=1):
    if not Settings().sound:
        #        print 'ignoring ', filename
        return
    if len(sounds) == 0:
        mixer.init()
        mixer.set_num_channels(32)
    if not filename in sounds.keys():
        sounds[filename] = mixer.Sound(filename)
    sounds[filename].set_volume(volume)
    return sounds[filename]
    def __init__(self):
        super(Player_1, self).__init__()
        self.skin = skeleton.BitmapSkin(animation.model2_skeleton.skeleton,
                                        animation.model2_skin.skin)
        self.add(self.skin, 1)
        # self.width,self.height = 0,0        #可能有bug
        self.position = 100, 100
        self.skin.position = 100, 100
        self.life = 100
        self.protect = False

        img = pyglet.image.load(address + "\dot.png")
        self.spr = cocos.sprite.Sprite(img, opacity=0)
        self.spr.position = 100, 100
        self.spr.velocity = (0, 0)
        self.mover = Mover_1()
        self.spr.do(self.mover)
        self.add(self.spr)
        self.life_bar = cocos.sprite.Sprite("img/yellow_bar.png")
        self.add(self.life_bar)
        self.fi = Fire()  # ParticleSystem
        self.fi.auto_remove_on_finish = True
        self.fi.position = (100, 50)

        self.status = 1  # 1:stop 2:walk 3:保持态 4:attack 5:leg_attack 6 :跳跃
        self.change = False
        self.bullet_move = False
        self.count = 0
        self.beheat = False
        self.up = False
        self.down = False

        fp_1 = open((address_2 + "/animation/MOOOOVE1.anim"), "rb+")
        self.walk = cPickle.load(fp_1)
        fp_2 = open((address_2 + "/animation/gun_shot.anim"), "rb+")
        self.attack = cPickle.load(fp_2)
        fp_3 = open((address_2 + "/animation/my_frozen.anim"), "rb+")
        self.frozen = cPickle.load(fp_3)
        fp_4 = open((address_2 + "/animation/leg_attack.anim"), "rb+")
        self.leg_attack = cPickle.load(fp_4)
        fp_5 = open((address_2 + "/animation/jump.anim"), "rb+")
        self.jump = cPickle.load(fp_5)

        mixer.init()
        music.load((address_2 + r"/sound/bgm.mp3").encode())
        music.play()
        music.set_volume(0.4)

        self.cshape = cm.AARectShape(eu.Vector2(*self.skin.position), 80, 136)
        self.fire()
        self.bullet.cshape = cm.AARectShape(eu.Vector2(*self.bullet.position),
                                            self.bullet.width / 2,
                                            self.bullet.height / 2)
예제 #10
0
    def __init__(
        self,
        config: Config,
        terminal: Terminal,
        physics: Physics,
        read_queue_interval: float = 1 / 60.0,
    ):
        self.config = config
        self.logger = get_logger('Gui', config)
        self.physics = physics
        self._read_queue_interval = read_queue_interval
        self.terminal = terminal
        self.cycle_duration = self.config.resolve('core.cycle_duration')

        # Manager cache directory
        cache_dir_path = self.config.resolve('global.cache_dir_path')
        if not cache_dir_path:
            raise SynergineException(
                'This code require the "global.cache_dir_path" config', )

        ensure_dir_exist(cache_dir_path)

        cocos.director.director.init(width=640,
                                     height=480,
                                     vsync=True,
                                     resizable=False)
        mixer.init()

        self.interaction_manager = InteractionManager(
            config=self.config,
            terminal=self.terminal,
        )
        self.layer_manager = self.layer_manager_class(
            self.config,
            middleware=self.get_layer_middleware(),
            interaction_manager=self.interaction_manager,
            gui=self,
        )
        self.layer_manager.init()
        self.layer_manager.connect_layers()
        self.layer_manager.center()

        # Enable blending
        pyglet.gl.glEnable(pyglet.gl.GL_BLEND)
        pyglet.gl.glBlendFunc(pyglet.gl.GL_SRC_ALPHA,
                              pyglet.gl.GL_ONE_MINUS_SRC_ALPHA)

        # Enable transparency
        pyglet.gl.glEnable(pyglet.gl.GL_ALPHA_TEST)
        pyglet.gl.glAlphaFunc(pyglet.gl.GL_GREATER, .1)

        self.subject_mapper_factory = SubjectMapperFactory()
예제 #11
0
 def __init__(self):
     super(Main_menu, self).__init__()
     self.items = []
     self.items.append(cocos.menu.ImageMenuItem('img/start.png', self.on_start))
     self.items.append(cocos.menu.ImageMenuItem('img/setting.png', self.on_setting))
     self.items.append(cocos.menu.ImageMenuItem('img/help.png', self.on_help))
     self.items.append(cocos.menu.MenuItem("读取武器存档", self.read_weapen))
     self.items.append(cocos.menu.MenuItem("读取人物存档", self.read_char))
     self.create_menu(self.items, cocos.menu.shake(), cocos.menu.shake_back())
     mixer.init()
     music.load((address_2 + r"/sound/happy_bgm.mp3").encode())
     music.play()
     music.set_volume(0.5)
예제 #12
0
    def run(self):
        cocos.director.director.init(width=1300, height=700)
        mixer.init()

        # We create a new layer, an instance of HelloWorld

        hello_layer = TBoard()
        #menu_layer = My_Menu()

        # A scene that contains the layer hello_layer
        main_scene = cocos.scene.Scene(hello_layer)  #, menu_layer)

        # And now, start the application, starting with main_scene
        cocos.director.director.run(main_scene)
예제 #13
0
    scene.do(
        Delay(3) + ripple + Delay(2) + wavestiles + Delay(1) + twirl + liquid +
        Delay(2) + shakyt + Delay(2) + ReuseGrid() + shuffle + Delay(4) +
        ReuseGrid() + turnoff + Reverse(turnoff) + Delay(1) + shatter + flip +
        Delay(2) + Reverse(flip) + flipx + Delay(2) + ReuseGrid() + flipy +
        Delay(2) + ReuseGrid() + flipx + Delay(2) + ReuseGrid() + flipy +
        Delay(2) + lens + ReuseGrid() + ((orbit + Reverse(orbit)) | waves3d) +
        Delay(1) + corners + Delay(2) + Reverse(corners) + waves + Delay(2) +
        ReuseGrid() + shaky + jumptiles + Delay(1) + cornerup + Delay(1) +
        Reverse(cornerdown) + Delay(1) + fadeout + Reverse(fadeout) +
        Delay(2) + quadmove + Delay(1) + Reverse(quadmove) + StopGrid())

    scene.do(Delay(10) + OrbitCamera(delta_z=-360 * 3, duration=10 * 4))

    firelayer.do(Delay(4) + Repeat(RotateBy(360, 10)))

    return scene


mixer.init()


def run(scene):
    director.run(scene)


if __name__ == "__main__":
    init()
    s = start()
    run(s)
예제 #14
0
from cocos.audio.pygame import mixer


# Our first multi-class program! Nice
# First we need to create a wrapper around the SDL Sound class
# We do this by creating our own object that simply initializes the parent with a file name that we pass in
# You'll see this in action in a second
class Audio(Sound):
    def __init__(self, audio_file):
        # As stated above, we initialize the super class with the audio file we passed in
        super(Audio, self).__init__(audio_file)


# Here we create your standard layer
class AudioLayer(Layer):
    def __init__(self):
        super(AudioLayer, self).__init__()
        # Now, in the layer we create an Audio object from the class we described above
        song = Audio("assets/sound/LatinIndustries.wav")
        # And lastly we make the song play when the layer is initialized
        song.play(-1)  # Setting the parameter to -1 makes the song play indefinitely


# Now we have more things to initialize than just the director
director.init()
# The audio mixer also needs us to tell it to get ready!
mixer.init()

# And lastly we run the scene like usual
director.run(scene.Scene(AudioLayer()))
예제 #15
0
    def __init__(self):

        super().__init__()

        self.game = None

        self.keys_pressed = set()

        self._game_status = const.GAME_STATUS_MENU

        self.game_mode = 3

        self.StartTimer = 0
        self.schedule(self.Timer_Refresh)
        self.TimePassed = 0

        mixer.init()
        self.title_music = Audio(const.TITLE_MUSIC_FILE)
        self.main_music = None
        self.solved_music = None

        self.image = pyglet.resource.image(const.BG_IMAGE)

        self.Time_Label = cocos.text.Label('00:00',
                                           font_size=16,
                                           font_name='Verdana',
                                           bold=False,
                                           color=const.COLOR_BLACK,
                                           x=5,
                                           y=const.WINDOW_HEIGHT - 20)

        self.Version_Label = cocos.text.Label(const.VERSION,
                                              font_size=16,
                                              font_name='Verdana',
                                              bold=False,
                                              color=const.COLOR_BLACK,
                                              x=const.WINDOW_WIDTH - 50,
                                              y=const.WINDOW_HEIGHT - 20)

        self.add(self.Time_Label)
        self.add(self.Version_Label)

        # for gif files
        #_anime = pyglet.image.load_animation(const.GAME_SELECT_BOX_IMAGE)
        #_bin = pyglet.image.atlas.TextureBin()
        #_anime.add_to_texture_bin(_bin)
        self.game_select_sprite = cocos.sprite.Sprite(
            const.GAME_SELECT_BOX_IMAGE,
            position=(const.GAME_SELECT_BOX_START_POS[0] + self.game_mode *
                      int(const.WINDOW_WIDTH / len(const.GAME_MODE)),
                      const.GAME_SELECT_BOX_START_POS[1]),
            scale=0.8)
        self.add(self.game_select_sprite)
        self.game_select_sprite.do(actions.Blink(20, 10))

        self.exit_button = cocos.sprite.Sprite(
            const.EXIT_IMAGE,
            position=(const.WINDOW_WIDTH - 80, const.WINDOW_HEIGHT - 20))
        self.add(self.exit_button)

        self.mouse_x = None
        self.mouse_y = None

        self.game_status = const.GAME_STATUS_MENU
예제 #16
0
def startroutine():
    director.init()
    mixer.init()
    print("director started")
    director.run(Scene(MainMenuLayer(director, None)))