Example #1
0
/**
 * @brief Plays a music.
 *
 * If the music is different from the current one,
 * the current one is stopped.
 * The music specified can also be Music::none_id (then the current music is just stopped)
 * or even Music::unchanged_id (nothing is done in this case).
 *
 * @param music_id id of the music to play (file name without extension)
 */
void Music::play(const std::string& music_id) {

  if (music_id != unchanged && music_id != get_current_music_id()) {
    // the music is changed

    if (music_id == none && current_music != NULL) {

      current_music->stop();
      current_music = NULL;
    }
    else {

      // play another music
      if (current_music != NULL) {
        current_music->stop();
      }

      if (all_musics.count(music_id) == 0) {
        all_musics[music_id] = Music(music_id);
      }

      Music& music = all_musics[music_id];
      if (music.start()) {
        current_music = &music;
      }
      else {
        current_music = NULL;
      }
    }
  }
}
Example #2
0
/*蜂鸣器*/
void Bell()
{

	unsigned int song[]=
	{
 		N6,12,N7,4,H1,8,H2,4,H3,4,/**/H2,32,/**/N7,12,N6,4,N5,8,N3,4,N5,4,/**/
 		N6,32,/**/H1,12,N6,4,N6,8,H3,8,/**/H2,32,/**/N5,22,N6,4,N7,8,H1,4,N7,4,/**/
 		N6,32, /**/H3,24,N6,8,/**/H2,24,H3,4,H2,4,/**/H1,16,H1,4,N6,4,H1,4,H2,4,/**/
 		N7,24,H1,4,H2,4,/**/H3,24,H2,4,H1,4,/**/H2,32,/**/
 		N5,4,N6,4,N7,16,N7,4,N5,4,/**/N6,32,/**/
 		N6,12,N7,4,H1,8,H2,4,H3,4,/**/H2,32,/**/N7,12,N6,4,N5,8,N3,4,N5,4,/**/
 		N6,32,/**/H1,12,N6,4,N6,8,H3,8,/**/H2,32,/**/N5,12,N6,4,N7,8,H1,4,N7,4,/**/
 		N6,32,/**/H3,24,N6,8,/**/H2,24,H3,4,H2,4,/**/H1,16,H1,4,N6,4,H1,4,H2,4,/**/
 		N7,24,H1,4,H2,4,/**/H3,24,H2,4,H1,4,/**/H2,32,/**/
 		N5,4,N6,4,N7,16,N6,4,N5,4,/**/N6,32,/**/H3,24,H2,4,H1,4,/**/H2,32,/**/
 		H1,24,N7,4,N6,4,/**/N7,24,H1,4,H2,4,/**/H3,24,H3,4,N6,4,/**/H2,24,H3,4,H2,4, /**/
 		H1,16,H1,4,N6,4,H1,4,H2,4,/**/N7,32,/**/H3,24,N6,8,/**/H2,24,H3,4,H2,4,/**/
 		H1,16,H1,4,N6,4,H1,4,H2,4,/**/N7,24,H1,4,H2,4,/**/H3,24,H2,4,H1,4,/**/
 		H2,24,H3,4,H2,4,/**/H1,24,N6,8,/**/N7,24,H1,8,/**/N6,32,/**/N6,32,/**/
 		0xFF //音乐结尾符
	};
						
	Bell_Init();			//初始化
	while(1)
	{
		Music(song);
	}
}
void GameEngine::Start()
{
  int ticksPerFrame = (int)(1000.0 / FPS_TARGET + 0.5);
  Uint32 nextSecond = SDL_GetTicks() + 1000;
  int frames = 0;

  Mix_Chunk *track = NULL;
  int channel = 0; 

  _isRunning = true;
  while (_isRunning)
  {
    _frameTimer.Mark();

    HandleEvents();
    Update();
    Draw();

    // If there is no music playing
    if(Mix_Playing(channel) == 0)
      // Play music
      channel = Music(track);

    if (_frameTimer.GetTicks() < ticksPerFrame)
      SDL_Delay(ticksPerFrame - _frameTimer.GetTicks());
    if (SDL_GetTicks() >= nextSecond)
    {
      nextSecond += 1000;
      _currentFps = frames;
      frames = 0;
    }
    ++frames;
  }
}
Example #4
0
void SoundPlayer::play(const char* filename)
{
	stop();

	file = FS().open(filename);

	music = Music(Mix_LoadMUS_RW(file.get()), Mix_FreeMusic);
	Mix_PlayMusic(music.get(), 1);
}
Example #5
0
who::who(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::who)
{
    ui->setupUi(this);

    player = new QMediaPlayer(this);

    displayPicture();
    facts();
    Music();
}
Example #6
0
func Initialize()
{
	// Always have some music
	Music("Frontend", 1);
	MusicLevel(30);
	// Create lens flare
	if (!ObjectCount(LENS)) CreateObject(LENS, 400, 100);
	// Fix vines (are not correctly saved in this Objects.txt)
	var pVine;
	for (pVine in FindObjects(Find_ID(VINE)))
		pVine->SetPosition(pVine->GetX(), pVine->GetY() - 35);
	// Create goal
	if (!ObjectCount(SCRG)) CreateObject(SCRG);
	// Evaluation dialog options
  SetNextMission("Tutorial.c4f\\Tutorial05.c4s", "$BtnRepeatRound$", "$BtnRepeatRoundDesc$");
}
Example #7
0
func Initialize()
{
	// Always have some music
	Music("Frontend", 1);
	MusicLevel(30);
	// Create lens flare
	CreateObject(LENS, 70, 50, NO_OWNER);
	// Place hut
	CreateConstruction(HUT2,580,180,NO_OWNER,100,1);
	// Create goal
	CreateObject(SCRG, 50,50, NO_OWNER);
	// Start script
	ScriptGo(true);
	// Evaluation dialog options
  SetNextMission("Tutorial.c4f\\Tutorial01.c4s", "$BtnRepeatRound$", "$BtnRepeatRoundDesc$");
	return true;
}
Example #8
0
func Initialize()
{
	// Always have some music
	Music("Frontend", 1);
	MusicLevel(30);
	// Create lens flare
	CreateObject(LENS, 100, 100, NO_OWNER);
	// Fix vines (wrong offset when saved in Objects.txt for the first time)
	var pVine;
	for (pVine in FindObjects(Find_ID(VINE)))
		pVine->SetPosition(pVine->GetX(), pVine->GetY() - 60);
	// Create flag-checker effect
	AddEffect("CheckForFlag", 0, 1, 10);
	// Create goal
	CreateObject(SCRG);
	// Start the script
	ScriptGo(true);
	// Evaluation dialog options
  SetNextMission("Tutorial.c4f\\Tutorial02.c4s", "$BtnRepeatRound$", "$BtnRepeatRoundDesc$");
}
Example #9
0
func Intro_Start()
{
	// Intro starts high up in the clouds
	Music("TheSkylands");
	LoadScenarioSection("Intro");
	SetWind(-100);
	this.intro_skyscroll_xdir = -10;
	SetSkyParallax(0, 20, 20, this.intro_skyscroll_xdir, 0);
	
	this.plane = CreateObjectAbove(Airplane, 500, 200);
	this.plane->SetColor(0xa04000);
	this.pilot = CreateObjectAbove(Clonk, 100, 100, NO_OWNER);
	this.pilot->MakeInvincible();
	this.pilot->SetSkin(2);
	this.pilot->Enter(this.plane);
	this.pilot->SetAction("Walk");

	this.pilot->SetName("Pyrit");
	this.pilot->SetColor(0xff0000);
	this.pilot->SetAlternativeSkin("MaleBrownHair");
	this.pilot->SetDir(DIR_Left);
	this.pilot->SetObjectLayer(this.pilot);
	this.pilot->AttachMesh(Hat, "skeleton_head", "main", Trans_Translate(5500, 0, 0)); // Hat is seen in the cockpit!

	this.plane->PlaneMount(this.pilot);
	this.plane.FxIntPlaneTimer = this.Intro_PlaneTimer;
	RemoveEffect("IntPlane", this.plane);
	AddEffect("IntPlane",this.plane,1,1,this.plane);
	this.plane->FaceRight();
	this.plane->StartInstantFlight(90, 0);
	g_intro_sky_moving = true;
	

	SetViewTarget(this.plane);

	return ScheduleNext(100, 1);
}
Example #10
0
void SoundCtrl::quit() {
    auto mMusic = Music(nullptr, Mix_FreeMusic);
    auto mEffect = Effect(nullptr, Mix_FreeChunk);
}
Example #11
0
int hogansnewalley(Sprite *Aim, Sprite *Health, Sprite *Background, int rumble, int maxtime, int diff, GameWindow *gwd){
  
  checkbadguys = false;
  
  gametime = 0;
  
  curalleytime = 200;

  Ghealth = 3;
  
  Grumble = rumble;
  
  Gscore = 0;
  
  switch(diff){
  
  case 1:
  resetalleytime = 90;
  grid = false;
  Alley1->SetPosition(70, 190);
  Alley2->SetPosition(260, 190);
  Alley3->SetPosition(450, 190);
  break;
  
  case 2:
  resetalleytime = 90;
  grid = true;
  //Alley1->SetPosition(70, 190);
  //Alley2->SetPosition(260, 190);
  //Alley3->SetPosition(450, 190);
  break;
  
  case 3:
  resetalleytime = 55;
  grid = false;
  Alley1->SetPosition(70, 190);
  Alley2->SetPosition(260, 190);
  Alley3->SetPosition(450, 190);
  break;
  
  case 4:
  resetalleytime = 55;
  grid = true;
  break;
  
  }
  
  alive[0] = false;
  alive[1] = false;
  alive[2] = false;

  good1->LoadImage("/apps/WiiShootingGallery/data/good1.png");
  good2->LoadImage("/apps/WiiShootingGallery/data/good2.png");
  good3->LoadImage("/apps/WiiShootingGallery/data/good3.png");
  bad1->LoadImage("/apps/WiiShootingGallery/data/bad1.png");
  bad2->LoadImage("/apps/WiiShootingGallery/data/bad2.png");
  bad3->LoadImage("/apps/WiiShootingGallery/data/bad3.png");
  
  quitcheck = false;

 while(true){//Game Loop
 
   WPAD_ScanPads();
   if(dontcheck)
   dontcheck = false;
   
   Music();

   if(curalleytime >= resetalleytime)
   resetalley();

   Background->Draw();
   
   if(alive[0] == true)
   Alley1->Draw();
   
   if(alive[1] == true)
   Alley2->Draw();
   
   if(alive[2] == true)
   Alley3->Draw();
   
    // Infrared calculation - The X and Y of the wiimote sprite
    ir_t ir; // The struct for infrared
	WPAD_IR(WPAD_CHAN_0, &ir); // Let's get our infrared data
	// Give our sprite the positions and the angle.
	Aim->SetPosition(ir.sx-WSP_POINTER_CORRECTION_X, ir.sy-WSP_POINTER_CORRECTION_Y); // We use these constants to translate the position correctly to the screen
	Aim->Move(-((f32)Aim->GetWidth()/2), -((f32)Aim->GetHeight()/2)); // And these to make our image appear at the center of this position.
	Aim->SetRotation(ir.angle/2); // Set angle/2 to translate correctly
   
   Aim->Draw();
   
   DrawHealth(Health, Ghealth);
   
   if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_PLUS){
	InMenu(gwd, false, Ghealth, Gscore);
	dontcheck = true;
	if(Ghealth > 3)
	Ghealth = 3;
	}
		
	if(quitcheck == true)
	break;
   
   if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_HOME)
   homemenu(gwd);
   
   if(WPAD_ButtonsDown(WPAD_CHAN_0)&WPAD_BUTTON_B){
   if(!dontcheck)
   HCheckForHit(Aim);
   }
   
   if(hrumblecounter == 7){
   WPAD_Rumble(WPAD_CHAN_0, 0);
   hrumblecounter = 0;
   }

   if(hrumblecounter != 0)
   hrumblecounter++;
   
   if(gametime > maxtime)
   break;
   
   if(maxtime > 0)
   gametime++;
   
   curalleytime++;
   
   if(Ghealth <= 0) 
   break;
   
   if(shutdown == true)
   SYS_ResetSystem(SYS_POWEROFF, 0, 0);
   
   gwd->Flush();



}//End Game Loop

WPAD_Rumble(WPAD_CHAN_0, 0);

return Gscore;

}
Example #12
0
//clear music object
int Music::clear()
{
	(*this) = Music();
	Music::active_ = Music::active_ - 1;
	return 0;
}
	//! create a music
	Music* AudioDriver::CreateMusic(const char* strOGG)
	{
		Music* pMusic = snew Music(strOGG);
		pMusic->GetSound()->setMixer(m_pMusicMixer);
		return pMusic;
	}
Example #14
0
Resource<Music>* Resource<Music>::load(const ResourceLoadInfo& info) {
	std::string s;
	if (!info.get_arg("source", s)) return nullptr;
	// TODO(bqq): Add flags
	return new Resource<Music>(Music(ResourceLoader::get()->load_file(s)));
}
Example #15
0
Creator::Creator(QApplication &app)
{
    //播放音乐文件
    media = new Phonon::MediaObject();
    audioOutput = new Phonon::AudioOutput(Phonon::VideoCategory);//声音
    Phonon::createPath(media, audioOutput);
    sourceList.append(QString("music/infinity.wma"));


    //建立pad
    pad = new RoundRectItem(QRectF(QPointF(0,0),QPointF(0,0)),QColor(0,0,255,0));
    pad->setZValue(0);

    //设置backwindow
    backWindow = new QGraphicsProxyWidget(pad);
    backWidget = new BackWidget();
    backWindow->setX(0);
    backWindow->setY(0);
 //   backWindow->widget()->setWindowOpacity(1);
    backWindow->setWidget(backWidget);
    backWindow->setZValue(0);


    //设置开始窗口按钮
    beginWindow = new QGraphicsProxyWidget(pad);
    beginWidget = new BeginBottum;
    beginWindow->setWidget(beginWidget);
    beginWindow->setX(backWindow->x()+400);
    beginWindow->setY(backWindow->y()+200);
    beginWindow->widget()->setWindowOpacity(1);
    beginWindow->setZValue(0.5);

    //设置音乐按键
    musicWindow = new QGraphicsProxyWidget(pad);
    musicWidget = new ClickBottum;
    musicWindow->setWidget(musicWidget);
    musicWindow->setX(backWindow->widget()->width()-120);
    musicWindow->setY(backWindow->y()+20);
    musicWindow->widget()->setWindowOpacity(1);
    musicWindow->setZValue(0.9);


    //设置AI对战窗口
    aiWindow = new QGraphicsProxyWidget(pad);
    aiWidget = new AIvsAI();
    aiWindow->setWidget(aiWidget);
    aiWindow->setX(backWindow->x());
    aiWindow->setY(backWindow->y());
    aiWindow->widget()->setWindowOpacity(0);
    aiWindow->setZValue(0.5);

    //按钮控件
    singleWindow = new QGraphicsProxyWidget(pad);
    singleWidget = new widgetssingle;
    singleWindow->setWidget(singleWidget);
    singleWindow->setX(backWindow->x()+400);
    singleWindow->setY(backWindow->y()+200);
    singleWindow->widget()->setWindowOpacity(0);
    singleWindow->setZValue(0.5);

    //回放器
    replayerWindow = new QGraphicsProxyWidget(pad);
    replayerWidget = new ReplayWindow();
    replayerWindow->setWidget(replayerWidget);
    replayerWindow->setX(backWindow->x());
    replayerWindow->setY(backWindow->y());
    replayerWindow->widget()->setWindowOpacity(0);
    replayerWindow->setZValue(0.5);

    //地图编辑器
    mapEditWindow = new QGraphicsProxyWidget(pad);
    mapWideget = new MapEditor();
    mapEditWindow->setWidget(mapWideget);
    mapEditWindow->setX(backWindow->x());
    mapEditWindow->setY(backWindow->y());
    mapEditWindow->widget()->setWindowOpacity(0);
    mapEditWindow->setZValue(0.5);

    //人机对战
    humanaiWindow = new QGraphicsProxyWidget(pad);
    humanaiWidget = new humanai();
    humanaiWindow->setX(backWindow->x());
    humanaiWindow->setY(backWindow->y());
    humanaiWindow->setWidget(humanaiWidget);
    humanaiWindow->widget()->setWindowOpacity(0);
    humanaiWindow->setZValue(0.5);

    //制作团队
    teamMeneWindow = new QGraphicsProxyWidget(pad);
    teamMeneWideget = new TeamMenu();
    teamMeneWindow->setWidget(teamMeneWideget);
    teamMeneWindow->setX(backWindow->x());
    teamMeneWindow->setY(backWindow->y());
    teamMeneWindow->widget()->setWindowOpacity(1);
    teamMeneWindow->setZValue(0.5);

    teamWindow = new QGraphicsProxyWidget(pad);
    teamWideget = new ProductionTeam();
    teamWindow->setWidget(teamWideget);
    teamWindow->widget()->setWindowOpacity(1);
    teamWindow->setZValue(0.5);
    teamWideget->setAutoFillBackground(true);
    QPalette Tpalette = teamWindow->palette();
    Tpalette.setBrush(QPalette::Window,
                      QBrush(Qt::black));
    teamWindow->setPalette(Tpalette);

//登陆
    LogInWindow = new QGraphicsProxyWidget(pad);
    logInwidget = new LogInWidget();
    LogInWindow->setWidget(logInwidget);
    LogInWindow->widget()->setWindowOpacity(0);
    LogInWindow->setZValue(0.5);
    LogInWindow->setX(0);
    LogInWindow->setY(0);

//测试赛
    TestWindow = new QGraphicsProxyWidget(pad);
    testwidget = new TestWidget();
    TestWindow->setWidget(testwidget);
    TestWindow->widget()->setWindowOpacity(0);
    TestWindow->setZValue(0.5);
    TestWindow->setX(0);
    TestWindow->setY(0);


//  beginWindow->close();
    aiWindow->close();
    singleWindow->close();
    replayerWindow->close();
    teamMeneWindow->close();
    teamWindow->close();
    mapEditWindow->close();
    humanaiWindow->close();
    LogInWindow->close();
    TestWindow->close();

    QObject::connect(beginWidget->returnUi()->exitmain,SIGNAL(clicked()),this,SLOT(close()));
    QObject::connect(beginWidget->returnUi()->startsingle,SIGNAL(clicked()),this,SLOT(BeginToSingle()));
    connect(this->singleWidget->ui->returnpre,SIGNAL(clicked()),this,SLOT(SingleToBegin()));
    connect(this->singleWidget->ui->aivsai,SIGNAL(clicked()),this,SLOT(SingleToAi()));
    connect(this->aiWidget->ui->ReturnPre,SIGNAL(clicked()),this,SLOT(AiToSingle()));
    connect(this->singleWidget->ui->replay,SIGNAL(clicked()),this,SLOT(SingleToReplayer()));
    connect(this->replayerWidget->returnUi()->pushButton,SIGNAL(clicked()),this,SLOT(ReplayerToSingle()));
    connect(this->beginWidget->returnUi()->team,SIGNAL(clicked()),this,SLOT(BeginToTeam()));
    connect(this->teamMeneWideget->returnUi()->pushButton,SIGNAL(clicked()),this,SLOT(TeamToBegin()));
    connect(this->musicWidget->ui->checkBox,SIGNAL(clicked()),this,SLOT(Music()));
    connect(this->replayerWidget->returnUi()->pushButton,SIGNAL(clicked()),this->replayerWidget,SLOT(GoInto()));
    connect(this->mapWideget->returnUi()->pushButton_5,SIGNAL(clicked()),this,SLOT(MapToSingle()));
    connect(this->singleWidget->ui->mapedit,SIGNAL(clicked()), this, SLOT(SingLeToMap()));
    connect(this->singleWidget->ui->playervsai,SIGNAL(clicked()),this,SLOT(SingleToHumanai()));
    connect(this->singleWidget->ui->playervsai, SIGNAL(clicked()), humanaiWidget, SLOT(initEmpty()));
    connect(this->humanaiWidget->returnUi()->Button_back, SIGNAL(clicked()), this, SLOT(HumanaiToSingle()));
    connect(this->media,SIGNAL(aboutToFinish()),this,SLOT(continueMusic()));
    connect(this->singleWidget->ui->levelmode,SIGNAL(clicked()),this,SLOT(SingleToLogIn()));
    connect(this->logInwidget->returnUi()->pushButton_2,SIGNAL(clicked()),this,SLOT(LogInToSingle()));
    connect(this->logInwidget,SIGNAL(login_success(QString)),this,SLOT(LogInToTest(QString)));
    connect(this->testwidget->returnUi()->pushButton,SIGNAL(clicked()),this,SLOT(TestToLogIn()));

//    connect(this->singleWidget->ui->replay,SIGNAL(clicked()),this->replayerWidget,SLOT(GoInto()));

    //设置界面背景
    QGraphicsScene *scene = new QGraphicsScene(this);
    scene->addItem(pad);
    scene->setBackgroundBrush(QBrush(QColor(0,0,0,255)));
    scene->setSceneRect(scene->itemsBoundingRect());

    setScene(scene);
    showFullScreen();

    //建立状态
    stateMachine = new QStateMachine(this);
    MainState = new QState(stateMachine);
    TeamState = new QState(stateMachine);
    BeginState = new QState(stateMachine);
    TestState = new QState(stateMachine);
    ReplayerState = new QState(stateMachine);
    WebState = new QState(stateMachine);
    MapState = new QState(stateMachine);
    HumanaiState = new QState(stateMachine);
    ChatState = new QState(stateMachine);
    WidState = new QState(stateMachine);

    BeginMenuState= new QState(stateMachine);
    SingleState= new QState(stateMachine);
    OldMenuState = new QState(stateMachine);
    CheckMenuState = new QState(stateMachine);
    TeamMenuState = new QState(stateMachine);
    LogState = new QState(stateMachine);

    MainState->assignProperty(MainState, "z", 0);
    MainState->assignProperty(beginWindow->widget(), "windowOpacity", 1);

    stateMachine->setInitialState(MainState);
    stateMachine->start();
}