Ejemplo n.º 1
0
void OnKeyS()
{
    int nRow = g_nCurBoxRow + 1;
    if (IsCanMove(nRow, g_nCurBoxCol))
    {
        ClearBox();
        g_nCurBoxRow++;
        CreateNewBox(g_nCurBoxType, g_nCurBoxSubType, g_nCurBoxRow, g_nCurBoxCol);
        ShowGame();
    }
    else
    {
        FixBox();

        ReleaseLine();

        g_nCurBoxType = rand() % (sizeof(g_szBox) / 64);
        g_nCurBoxSubType = rand() % 4;
        g_nCurBoxRow = 0;
        g_nCurBoxCol = 4;
        CreateNewBox(g_nCurBoxType, g_nCurBoxSubType, g_nCurBoxRow, g_nCurBoxCol);
        
        ShowGame();
    }
}
Ejemplo n.º 2
0
void Show(void)
{
	/* 初始化控制台 */
	ConSetBackgroundColor(ConBlack);
	ConSetTextColor(ConWhite);
	ConClear();

	switch(iGameStatus)
	{
		case GameMainMenu:
			ShowMenu();
			break;
		case GameRunning:
			ShowGame();
			break;
		case GameWon:
			ShowWon();
			break;
		case GameLostLife:
			ShowLostLife();
			break;
		case GameLost:
			ShowLost();
			break;
		case GameExit:
			ShowExit();
			break;
		case GameSplashScreen:
			ShowSplash();
			break;

		default:
			break;
	}/* switch */
}
void ribi::con3::WtConnectThreeGameDialog::RestartGame()
{
  m_state = state_playing;
  ShowGame();
  assert(m_board);
  m_board->Restart();
  UpdatePlayersPanel();
  StartTimer();
}
Ejemplo n.º 4
0
void OnKeyD()
{
    int nCol = g_nCurBoxCol + 1;
    if (IsCanMove(g_nCurBoxRow, nCol))
    {
        ClearBox();
        g_nCurBoxCol++;
        CreateNewBox(g_nCurBoxType, g_nCurBoxSubType, g_nCurBoxRow, g_nCurBoxCol);
        ShowGame();
    }
}
Ejemplo n.º 5
0
int main()
{
    srand(time(NULL));
    InitWall();

    g_nCurBoxType = rand() % (sizeof(g_szBox) / 64);
    g_nCurBoxSubType = rand() % 4;
    g_nCurBoxRow = 0;
    g_nCurBoxCol = 4;
    CreateNewBox(g_nCurBoxType, g_nCurBoxSubType, g_nCurBoxRow, g_nCurBoxCol);

    ShowGame();

    clock_t tLast = 0;
    clock_t tCur = 0;
    tLast = clock();
    char cKey = 0;
    while(g_nEndGame == 0)
    {
        if(_kbhit())
        {
            cKey = getch();
            switch(cKey)
            {
            case 'W':
            case 'w':
                pfnKey = OnKeyW;
                break;
            case 'A':
            case 'a':
                pfnKey = OnKeyA;
                break;
            case 'S':
            case 's':
                pfnKey = OnKeyS;
                break;
            case 'D':
            case 'd':
                pfnKey = OnKeyD;
                break;
            }               
            (*pfnKey)();
        }
        tCur = clock();
        if (tCur - tLast >= 600)
        {
            tLast = clock();
            OnKeyS();
        }
    }
    return 0;
}
Ejemplo n.º 6
0
void OnKeyW()
{
    int nSubType = (g_nCurBoxSubType + 1) % 4;
    if (IsCanRotate(nSubType))
    {
        ClearBox();

        g_nCurBoxSubType = (g_nCurBoxSubType + 1) % 4;
        CreateNewBox(g_nCurBoxType, g_nCurBoxSubType, g_nCurBoxRow, g_nCurBoxCol);

        ShowGame();
    }
}
Ejemplo n.º 7
0
void ShowLostLife(void)
{
	ShowGame();

	ConSetPosition(20,11);
	
	ConSetBackgroundColor(ConGreen);
	ConSetTextColor(ConRed);
	ConOutputString("#####################################");
	ConSetPosition(20,12);
	ConOutputString("# 你失去一条生命                    #");
	ConSetPosition(20,13);
	ConOutputString("#####################################");

}
Ejemplo n.º 8
0
void ShowLost(void)
{
	ShowGame();

	ConSetPosition(20,11);
	
	ConSetBackgroundColor(ConGreen);
	ConSetTextColor(ConRed);
	ConOutputString("#####################################");
	ConSetPosition(20,12);
	ConOutputString("# 胜败乃兵家常事,                  #");
	ConSetPosition(20,13);
	ConOutputString("# 英雄请重新来过。                  #");
	ConSetPosition(20,14);
	ConOutputString("#####################################");

}
Ejemplo n.º 9
0
void ShowWon(void)
{
	ShowGame();

	ConSetPosition(20, 11);
	ConSetBackgroundColor(ConGreen);
	ConSetTextColor(ConRed);

	ConOutputString("#####################################");
	ConSetPosition(20, 12);
	ConOutputString("# 恭喜!                            #");
	ConSetPosition(20, 13);
	ConOutputString("# 你已经杀死了所有的小怪兽。        #");
	ConSetPosition(20, 14);
	ConOutputString("#####################################");

}
ribi::con3::WtConnectThreeGameDialog::WtConnectThreeGameDialog(
  const boost::shared_ptr<const ConnectThreeResources> resources,
  const std::bitset<3>& is_player_human)
  : m_board{},
    m_is_player_human(is_player_human),
    m_players{},
    m_resources(resources),
    m_state(state_playing),
    m_timer(new Wt::WTimer(this))
{

  this->setContentAlignment(Wt::AlignCenter);

  m_timer->timeout().connect(
    this,
    &ribi::con3::WtConnectThreeGameDialog::DoComputerTurn);
  m_timer->setInterval(100);


  ShowGame();
  //OnValidMove(); //Draw screen
}