コード例 #1
0
ファイル: main.c プロジェクト: RotaruDan/DESgame
void Main() {
    // Initialize the system:
    sys_init();
    InitializeSystem();

    // Initialize the output:
    TurnOnLCD();
    Set8Led(0);

    // Initialize the data:
    InitializeGame();

    // Initialize the input:
    SetOnKeyboardDown(OnKeyboardDown);
    InitializeKeyboardInterrupts();
    SetOnButtonDown(OnButtonDown);
    SetOnButtonUp(OnButtonUp);
    InitializeButtonsInterrupts();

    // Initialize the timers:
    SimpleInitializeTimerInterrupts(TIMER_ID0, MAX_TIME_COUNT, (unsigned)UpdateOnTimer);

    // Initialize the UART1:
    InitializeUART(BAUDS_115200);
    //ActivateInterruptsUART1((unsigned)OnReceiveUART);

    // Call the main loop:
    MainLoopWithPolling();
}
コード例 #2
0
ファイル: gfir.c プロジェクト: RoomArchitect/fir
static void init_rs_cb(GtkWidget *widget,
                       gpointer   data)
{
    InitializeGame();
    int x = 0;
    int y = 0;
    NodeType t;
    for (int i = 0; i <= 2; ++i) {
        t = (i == 1) ? Black : White;
        x = (BoardSize - 9) / 2 + rand() % 9;
        y = (BoardSize - 9) / 2 + rand() % 9;
        if (game.board[x][y] == Empty) {
            game.board[x][y] = t;
            DrawPiece(x, y, t);
        }
    }

    if (game.blackAI.id != 10) {
        Point p;
        p = game.blackAI.func(game.board, Black);
        game.Move(p);
        DrawPiece(p.x, p.y, Black);
    }
    GtkWidget* draw_area = (GtkWidget*) data;
    gtk_widget_queue_draw_area(draw_area, 0, 0, CanvasWidth, CanvasWidth);

}
コード例 #3
0
ファイル: main.c プロジェクト: DhruvRelwani/GamesmanClassic
void Initialize()
{
		gGetVarStringPtr = &get_var_string;
        srand(time(NULL));

        /* set default solver */
        /* already done in globals.c */
        //    gSolver = NULL;

        /* set default go again */
        gGoAgain=DefaultGoAgain;

        sprintf(gPlayerName[kPlayerOneTurn],"Player");
        sprintf(gPlayerName[kPlayerTwoTurn],"Computer");

        /* generic hash */
        //generic_hash_context_init();

        /* get the DB function table with all pointers to default */
        CreateDatabases();

        /* game-specific variabless */
        InitializeGame();

        /* set the solver */
        SetSolver();
}
コード例 #4
0
	void CGameDoc::UpdateGrade(void){
		if(m_nMode == PRACTICE){
			switch (m_nGrade)
			{
			case LOW:
				m_nRow = 3;
				m_nCol = 4;
				break;	
			case MIDDLE:
				m_nRow = 4;
				m_nCol = 5;
				break;
			case TOP:
				m_nRow = 5;
				m_nCol = 6;
				break;
			}
		}else if(m_nMode == RANKING){
			m_nRow = 2;
			m_nCol = 3;
		}else{
			m_nRow = 5;
			m_nCol = 6;
		}

		InitializeGame();
	}
コード例 #5
0
ファイル: genworld.cpp プロジェクト: IchiroWang/OpenTTD
/**
 * Generate a world.
 * @param mode The mode of world generation (see GenWorldMode).
 * @param size_x The X-size of the map.
 * @param size_y The Y-size of the map.
 * @param reset_settings Whether to reset the game configuration (used for restart)
 */
void GenerateWorld(GenWorldMode mode, uint size_x, uint size_y, bool reset_settings)
{
	if (HasModalProgress()) return;
	_gw.mode   = mode;
	_gw.size_x = size_x;
	_gw.size_y = size_y;
	SetModalProgress(true);
	_gw.abort  = false;
	_gw.abortp = NULL;
	_gw.lc     = _local_company;
	_gw.quit_thread   = false;
	_gw.threaded      = true;

	/* This disables some commands and stuff */
	SetLocalCompany(COMPANY_SPECTATOR);

	InitializeGame(_gw.size_x, _gw.size_y, true, reset_settings);
	PrepareGenerateWorldProgress();

	/* Load the right landscape stuff, and the NewGRFs! */
	GfxLoadSprites();
	LoadStringWidthTable();

	/* Re-init the windowing system */
	ResetWindowSystem();

	/* Create toolbars */
	SetupColoursAndInitialWindow();
	SetObjectToPlace(SPR_CURSOR_ZZZ, PAL_NONE, HT_NONE, WC_MAIN_WINDOW, 0);

	if (_gw.thread != NULL) {
		_gw.thread->Join();
		delete _gw.thread;
		_gw.thread = NULL;
	}

	if (!VideoDriver::GetInstance()->HasGUI() || !ThreadObject::New(&_GenerateWorld, NULL, &_gw.thread, "ottd:genworld")) {
		DEBUG(misc, 1, "Cannot create genworld thread, reverting to single-threaded mode");
		_gw.threaded = false;
		_modal_progress_work_mutex->EndCritical();
		_GenerateWorld(NULL);
		_modal_progress_work_mutex->BeginCritical();
		return;
	}

	UnshowCriticalError();
	/* Remove any open window */
	DeleteAllNonVitalWindows();
	/* Hide vital windows, because we don't allow to use them */
	HideVitalWindows();

	/* Don't show the dialog if we don't have a thread */
	ShowGenerateWorldProgress();

	/* Centre the view on the map */
	if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) {
		ScrollMainWindowToTile(TileXY(MapSizeX() / 2, MapSizeY() / 2), true);
	}
}
コード例 #6
0
ファイル: main.c プロジェクト: RotaruDan/DESgame
void OnButtonDown(unsigned value) {
    if (value & BUTTON_LEFT) {
        TurnOnLeftLed();
        ResetScores();
        InitializeGame();
    } else if (value & BUTTON_RIGHT) {
        TurnOnRightLed();
        game_data.pause = !game_data.pause;
    }
}
コード例 #7
0
ファイル: Game.cpp プロジェクト: VagabondOfHell/ProBending
	::FreeConsole();
}

void Game::Run()
{
	InitializeGame();
	ConnectToPVD();
	InitializeKinect();

	kinectController = BodyController();

	InputManager* inputManager = InputManager::GetInstance();

	inputManager->RegisterSensorListener(&kinectController);

	inputManager->BeginAllCapture();

	sceneManager = new SceneManager();
	sceneManager->Initialize(mWindow, mRoot);

	AllocConsole();
	freopen("conin$","r",stdin);
	freopen("conout$","w",stdout);
	freopen("conout$","w",stderr);
	printf("Debugging Window:\n");

	/*std::shared_ptr<GameScene> gameScene(new GameScene(sceneManager, mRoot, "Probending Arena", contestantData));
	sceneManager->FlagSceneSwitch(gameScene, true);
	gameScene.reset();*/

	std::shared_ptr<MenusScene> menuScene = std::make_shared<MenusScene>(sceneManager, mRoot, MenusScene::Screens::MainMenu);
	sceneManager->FlagSceneSwitch(menuScene, true);
	menuScene.reset();

	bool rendering = true;

	Ogre::Timer gameTimer = Ogre::Timer();
	float currentTime = 0;
	float previousTime = 0;

	while (rendering)
	{
		gameTimer.reset();
		
		if(!Update(currentTime / 1000.0f))
			rendering = false;

		//Ogre::WindowEventUtilities::messagePump();
#if(!MEMORY_LEAK_DETECT)
		mRoot->renderOneFrame();
#endif
		currentTime = (float)gameTimer.getMilliseconds();
		
コード例 #8
0
ファイル: HANGMAN_GAME.C プロジェクト: jgambox/DCRabbit_9
main(){
   int correct, i;

   brdInit();

   //  sock_init initializes the TCP/IP stack.
   //  http_init initializes the web server.
   sock_init();
   http_init();

   tcp_reserveport(80);

   mode = -1;  // -1 = uninitialized

   while(1){

      if(mode== -1){
         InitializeGame();
         mode = 0;
      }

      http_handler();

      if(numUsedGuesses == 6){   // guesses used up
         mode = 1;
         numUsedGuesses = 0;
         strcpy(hint,wrd->answer);
      }

      if(character)  {  // new character entered
         correct = 0;   // assume incorrect guess

         // see if character is in word
         for(i = 0 ; i < strlen(wrd->answer) ; i++)  {
            if(wrd->answer[i] == (char)character) {
               guess[i] = newGuess[2*i] = (char)character;
               correct = 1;
            }
         }
         // see if word is guessed correctly
         if( !strcmpi(guess, wrd->answer) ){
            prompt[0] = 0;
            numUsedGuesses = 7; // 7 signals win
         }
         else if(correct == 0) {
            numUsedGuesses++;
            currentGIF++;       // use next GIF
            sprintf(prompt,"You have %d guesses left!", 6-numUsedGuesses);
         }
         character = 0;
      }
   }
}
コード例 #9
0
	CGameDoc::CGameDoc(){
		srand((unsigned int)(time(NULL)));//시간을 Seed로 잡아 똑같은 난수 발생을 방지
		
		m_strName = _T("");
		m_bmCell = CSize(79, 81);
		m_nMode = PRACTICE;
		m_nGrade = TOP;
		m_nType = POCKETMON;

		UpdateGrade();
		InitializeGame();
	}
コード例 #10
0
ファイル: gfir.c プロジェクト: RoomArchitect/fir
static void init_cb(GtkWidget *widget,
                    gpointer   data)
{
    InitializeGame();
    if (game.blackAI.id != 10) {
        Point p;
        p = game.blackAI.func(game.board, Black);
        game.Move(p);
        DrawPiece(p.x, p.y, Black);
    }
    GtkWidget* draw_area = (GtkWidget*) data;
    gtk_widget_queue_draw_area(draw_area, 0, 0, CanvasWidth, CanvasWidth);
}
コード例 #11
0
ファイル: mswans.c プロジェクト: DhruvRelwani/GamesmanClassic
void GameSpecificMenu()
{
	do {
		printf("\n\t----- Game-specific options for %s -----\n\n", kGameName);

		printf("\tCurrent Initial Position:\n");
		PrintPosition(gInitialPosition, gPlayerName[kPlayerOneTurn], kHumansTurn);

		printf("\tI)\tChoose the (I)nitial position\n");
		printf("\tT)\t(T)rapping opponent toggle from %s to %s\n",
		       gToTrapIsToWin ? "GOOD (WINNING)" : "BAD (LOSING)",
		       !gToTrapIsToWin ? "GOOD (WINNING)" : "BAD (LOSING)");
		printf("\tD)\tChange the number of (D)ragons (Currently %d)\n",
		       gNumDragons);

		printf("\n\n\tb)\t(B)ack = Return to previous activity.\n");
		printf("\n\nSelect an option: ");

		switch(GetMyChar()) {
		case 'Q': case 'q':
			ExitStageRight();
		case 'H': case 'h':
			HelpMenus();
			break;
		case 'I': case 'i':
			gInitialPosition = GetInitialPosition();
			break;
		case 'T': case 't':
			gToTrapIsToWin = !gToTrapIsToWin;
			break;
		case 'D': case 'd':
			printf("How many dragons [%d-%d]? ", MIN_DRAGONS, MAX_DRAGONS);
			/*scanf("%d", &gNumDragons);*/
			gNumDragons = GetMyInt();
			while (gNumDragons > MAX_DRAGONS || gNumDragons < MIN_DRAGONS) {
				printf("Invalid entry. Please try again\n");
				printf("How many dragons [%d-%d]? ", MIN_DRAGONS, MAX_DRAGONS);
				/*scanf("%d", &gNumDragons);*/
				gNumDragons = GetMyInt();
			}
			InitializeGame();
			break;
		case 'b': case 'B':
			return;
		default:
			printf("\nSorry, I don't know that option. Try another.\n");
			HitAnyKeyToContinue();
			break;
		}
	} while(TRUE);
}
コード例 #12
0
ファイル: gfir.c プロジェクト: RoomArchitect/fir
static void activate(GtkApplication* app, 
                     gpointer        user_data)
{
    GtkWidget *window;
    GtkWidget *button;
    GtkWidget *button_rs;
    GtkWidget *button_box;
    GtkWidget *draw_area;
    GtkWidget *fixed_container;

    window = gtk_application_window_new(app);
    gtk_window_set_title(GTK_WINDOW(window), "Five Son Chess");
    gtk_window_set_default_size(GTK_WINDOW(window), 900, 900);
    gtk_window_set_resizable(GTK_WINDOW(window), FALSE);
   
    fixed_container = gtk_fixed_new();
    
    // Draw Area
    draw_area = gtk_drawing_area_new();
    gtk_widget_set_size_request(draw_area, CanvasWidth, CanvasWidth);
    g_signal_connect(draw_area, "draw", G_CALLBACK(draw_cb), NULL);
    g_signal_connect(draw_area, "configure-event", G_CALLBACK(configure_event_cb), NULL);
    gtk_widget_add_events(draw_area, GDK_BUTTON_PRESS_MASK);

    g_signal_connect(draw_area, "button_press_event", G_CALLBACK(PutPiece), draw_area);
    
    gtk_fixed_put(GTK_FIXED(fixed_container), draw_area, 0, 0);

    // Buttons
    button_box = gtk_button_box_new(GTK_ORIENTATION_VERTICAL);
    gtk_fixed_put(GTK_FIXED(fixed_container), button_box, CanvasWidth, 0);


    button = gtk_button_new_with_label("从头再来");
    g_signal_connect(button, "clicked", G_CALLBACK(init_cb), draw_area);
    button_rs = gtk_button_new_with_label("随机开局");
    g_signal_connect(button_rs, "clicked", G_CALLBACK(init_rs_cb), draw_area);
    gtk_container_add(GTK_CONTAINER(button_box), button);
    gtk_container_add(GTK_CONTAINER(button_box), button_rs);
    gtk_container_add(GTK_CONTAINER(window), fixed_container);

    gtk_widget_show_all(window);

    // Game starts here!
    InitializeGame();
}
コード例 #13
0
ファイル: main.c プロジェクト: rezanour/randomoldstuff
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR commandLine, int showCommand)
{
    WNDCLASS wndClass = {0};
    MSG msg;

    /* Register window class */
    wndClass.hInstance = instance;
    wndClass.hbrBackground = CreateSolidBrush(RGB(0, 0, 0));
    wndClass.lpszClassName = ClassName;
    wndClass.lpfnWndProc = WndProc;
    if (!RegisterClass(&wndClass))
        exit(1);

    /* Create window */
    g_hwnd = CreateWindow(ClassName, Title, WS_POPUP, 0, 0, 160 * ViewScale, 100 * ViewScale, 0, 0, instance, 0);
    if (!g_hwnd)
        exit(2);

    ShowWindow(g_hwnd, showCommand);
    UpdateWindow(g_hwnd);

    /* Initialize Graphics */
    InitializeGraphics(g_hwnd);
    InitializeGame();

    for (;;)
    {
        if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
        {
            if (msg.message == WM_QUIT)
                break;

            TranslateMessage(&msg);
            DispatchMessage(&msg);
        }
        else
        {
            TickGame();
            Present();
        }
    }

    DestroyGraphics();

    return 0;
}
コード例 #14
0
ファイル: GameManager.cpp プロジェクト: WooJaeWoo/Smith_CPP
bool GameManager::LastMenuDecision(int lastMenu)
{
	if (lastMenu == 0)
	{
		InitializeGame();
		m_Player1->InitializePlayer();
		m_Player2->InitializePlayer();
		return false;
	}
	else if (lastMenu == 1)
	{
		ResetGame();
		return false;
	}
	else
	{
		return true;
	}
}
コード例 #15
0
BOOL Init(int argc, char* argv[])
{
  _bDedicatedServer = TRUE;

  if (argc!=1+1 && argc!=2+1) {
    // NOTE: this cannot be translated - translations are not loaded yet
    printf("Usage: DedicatedServer <configname> [<modname>]\n"
      "This starts a server reading configs from directory 'Scripts\\Dedicated\\<configname>\\'\n");
    getch();
    exit(0);
  }

  SetConsoleTitleA(argv[1]);

  ded_strConfig = CTString("Scripts\\Dedicated\\")+argv[1]+"\\";

  if (argc==2+1) {
    _fnmMod = CTString("Mods\\")+argv[2]+"\\";
  }


  _strLogFile = CTString("Dedicated_")+argv[1];

  // initialize engine
  SE_InitEngine(sam_strGameName);

//  ParseCommandLine(strCmdLine);

  // load all translation tables
  InitTranslation();
  CTFileName fnmTransTable;
  try {
    fnmTransTable = CTFILENAME("Data\\Translations\\Engine.txt");
    AddTranslationTable_t(fnmTransTable);
    fnmTransTable = CTFILENAME("Data\\Translations\\Game.txt");
    AddTranslationTable_t(fnmTransTable);
    fnmTransTable = CTFILENAME("Data\\Translations\\Entities.txt");
    AddTranslationTable_t(fnmTransTable);
    fnmTransTable = CTFILENAME("Data\\Translations\\SeriousSam.txt");
    AddTranslationTable_t(fnmTransTable);
    fnmTransTable = CTFILENAME("Data\\Translations\\Levels.txt");
    AddTranslationTable_t(fnmTransTable);

    FinishTranslationTable();
  } catch (char *strError) {
    FatalError("%s %s", CTString(fnmTransTable), strError);
  }

  // always disable all warnings when in serious sam
  _pShell->Execute( "con_bNoWarnings=1;");

  // declare shell symbols
  _pShell->DeclareSymbol("persistent user INDEX ded_iMaxFPS;", &ded_iMaxFPS);
  _pShell->DeclareSymbol("user void Quit(void);", &QuitGame);
  _pShell->DeclareSymbol("user CTString ded_strLevel;", &ded_strLevel);
  _pShell->DeclareSymbol("user FLOAT ded_tmTimeout;", &ded_tmTimeout);
  _pShell->DeclareSymbol("user INDEX ded_bRestartWhenEmpty;", &ded_bRestartWhenEmpty);
  _pShell->DeclareSymbol("user void Restart(void);", &RestartGame);
  _pShell->DeclareSymbol("user void NextMap(void);", &NextMap);
  _pShell->DeclareSymbol("persistent user CTString sam_strIntroLevel;",      &sam_strIntroLevel);
  _pShell->DeclareSymbol("persistent user CTString sam_strGameName;",      &sam_strGameName);
  _pShell->DeclareSymbol("user CTString sam_strFirstLevel;", &sam_strFirstLevel);

  // init game - this will load persistent symbols
  InitializeGame();
  _pNetwork->md_strGameID = sam_strGameName;

  LoadStringVar(CTString("Data\\Var\\Sam_Version.var"), _strSamVersion);
  CPrintF(TRANS("Serious Sam version: %s\n"), _strSamVersion);

  SetConsoleCtrlHandler(HandlerRoutine, TRUE);

  // if there is a mod
  if (_fnmMod!="") {
    // execute the mod startup script
    _pShell->Execute(CTString("include \"Scripts\\Mod_startup.ini\";"));
  }

  return TRUE;
}
コード例 #16
0
ファイル: Main.cpp プロジェクト: m1h4/Xetrix
bool InitializeWindow(ULONG width,ULONG height)
{
	PIXELFORMATDESCRIPTOR pfd =
	{
		sizeof(PIXELFORMATDESCRIPTOR),
		1,
		PFD_DRAW_TO_WINDOW|PFD_SUPPORT_OPENGL|PFD_DOUBLEBUFFER,
		PFD_TYPE_RGBA,
		32,	// Color Buffer Size
		0,0,0,0,0,0,
		0,
		0,
		0,
		0,0,0,0,
		24,	// Depth Buffer Size
		0,
		0,
		PFD_MAIN_PLANE,
		0,
		0,0,0
	};

	UINT		pixelFormat;
	WNDCLASS	wc = {0};
	DWORD		dwExStyle = 0;
	DWORD		dwStyle = WS_POPUP|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX|WS_SIZEBOX|WS_MAXIMIZEBOX;
	RECT		windowRect = {0,0,width,height};

	wc.style			= CS_CLASSDC;
	wc.lpfnWndProc		= WinProcedure;
	wc.hInstance		= GetModuleHandle(NULL);
	wc.hIcon			= LoadIcon(NULL,IDI_WINLOGO);
	wc.hCursor			= LoadCursor(NULL,IDC_ARROW);
	wc.lpszClassName	= mainClassName;

	if(!RegisterClass(&wc))
	{
		MessageBox(NULL,TEXT("Could not register the window class."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);

		return false;
	}

	AdjustWindowRectEx(&windowRect,dwStyle,FALSE,dwExStyle);

	mainWnd = CreateWindowEx(dwExStyle,
								mainClassName,
								mainWindowName,
								dwStyle,
								CW_USEDEFAULT,CW_USEDEFAULT,
								windowRect.right-windowRect.left,
								windowRect.bottom-windowRect.top,
								NULL,
								NULL,
								GetModuleHandle(NULL),
								NULL);
	if(!mainWnd)
	{
		KillWindow();
		MessageBox(NULL,TEXT("Window creation error."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}
	
	mainDC = GetDC(mainWnd);
	if(!mainDC)
	{
		KillWindow();
		MessageBox(NULL,TEXT("Could not create a device context."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	pixelFormat = ChoosePixelFormat(mainDC,&pfd);
	if(!pixelFormat)
	{
		KillWindow();
		MessageBox(NULL,TEXT("Could not find a suitable pixel format."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	if(!SetPixelFormat(mainDC,pixelFormat,&pfd))
	{
		KillWindow();
		MessageBox(NULL,TEXT("Could not set the pixel format."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	mainRC = wglCreateContext(mainDC);
	if(!mainRC)
	{
		KillWindow();
		MessageBox(NULL,TEXT("Could not create a rendering context."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	if(!wglMakeCurrent(mainDC,mainRC))
	{
		KillWindow();
		MessageBox(NULL,TEXT("Could not activate the rendering context."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	ShowWindow(mainWnd,SW_SHOW);
	SetForegroundWindow(mainWnd);
	SetFocus(mainWnd);
	ReSizeScene(width,height);

	if(!InitializeGraphics())
	{
		KillWindow();
		MessageBox(NULL,TEXT("Graphics initialization failed."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	if(!InitializeGame())
	{
		KillWindow();
		MessageBox(NULL,TEXT("Game initialization failed."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	if(!InitializeTimer())
	{
		KillWindow();
		MessageBox(NULL,TEXT("Timer initialization failed."),TEXT("Error"),MB_OK|MB_ICONEXCLAMATION);
		return false;
	}

	TRACE(TEXT("OpenGL %S\n"), glGetString(GL_VERSION));

	return true;
}
コード例 #17
0
ファイル: GameBoard.cpp プロジェクト: syvjohan/cppFun
GameBoard::GameBoard() {
    InitializeGame();
    p1Score = 0;
    p2Score = 0;
}
コード例 #18
0
ファイル: GameManager.cpp プロジェクト: WooJaeWoo/Smith_CPP
void GameManager::GameRun()
{
	int	winner = -1;
	int lastMenu = -1;
	bool okToExit = false;
	m_GameRenderer->SetWindowTitle();
	while (true)
	{
		//DataControl
		switch (m_GameStatus)
		{
		case GAMESTART: //Dummy Case
			m_GameStatus = TITLE;
			break;
		case TITLE:
			InitializeGame();
			m_GameStatus = SELECT_PLAYER;
			break;
		case SELECT_PLAYER:
			m_GameType = m_GameInterface->GetGameType();
			SetPlayerType();
			if (m_GameType == PVP_PLAY || m_GameType == AI_PLAY)
				m_GameStatus = SELECT_MAP_SHIP;
			else if (m_GameType == NET_PLAY)
			{
				DefaultGameSetting();
				m_GameStatus = GAMEPLAY;
			}
			break;
		case SELECT_MAP_SHIP:
			m_MapSize = m_GameInterface->GetMapSize();
			m_GameRenderer->SetSizeOfMap(m_MapSize);
			m_NumShip = m_GameInterface->GetNumShip();
			MakeMapAndShip();
			m_GameStatus = SET_SHIP;
			break;
		case SET_SHIP:
		{
			if (m_GameType == PVP_PLAY)
			{
				PVP_PlaySetShip();
			}
			else if (m_GameType == AI_PLAY)
			{
				AI_PlaySetShip();
			}
			m_GameStatus = GAMEPLAY;
			break;
		}
		case GAMEPLAY: 
		{
			if (m_GameType == PVP_PLAY)
			{
				winner = PVP_PlayGameFlow();
				m_GameStatus = WIN;
			}
			else if (m_GameType == AI_PLAY)
			{
				winner = AI_PlayGameFlow();
				if (winner == 0)
					m_GameStatus = WIN;
				else
					m_GameStatus = LOSE;
			}
			else if (m_GameType == NET_PLAY)
			{
				NET_PlayGameFlow();
			}
			lastMenu = -1;
			break;
		}
		case WIN:
			lastMenu = m_GameInterface->GetLastMenu();
			okToExit = LastMenuDecision(lastMenu);
			break;
		case LOSE:
			lastMenu = m_GameInterface->GetLastMenu();
			okToExit = LastMenuDecision(lastMenu);
			break;
		}
		if (lastMenu != -1)
		{
			if (okToExit) break;
		}
		m_GameRenderer->RenderPages(m_GameStatus, m_GameType);
		if (m_GameStatus == WIN || m_GameStatus == LOSE)
			WriteGameResult(winner);
		m_GameInterface->AttachInterface(m_GameStatus);
	}
}
コード例 #19
0
int main (void)
{
   XGpio dip;
   int dip_check;


   static XPs2 Ps2Inst;
   XPs2_Config *ConfigPtr;
   u32 StatusReg;
   u32 BytesReceived;
   u8 RxBuffer;
   int key_count=0;
   int i;

   status=PVP;
   int x_cur=7, y_cur=7, x_pos=0, y_pos=0;

   XGpio_Initialize(&dip, XPAR_DIP_SWITCHES_8BITS_DEVICE_ID);
   XGpio_SetDataDirection(&dip, 1, 0xffffffff);

   ConfigPtr = XPs2_LookupConfig(XPAR_XPS_PS2_0_0_DEVICE_ID);
   XPs2_CfgInitialize(&Ps2Inst, ConfigPtr, ConfigPtr->BaseAddress);

   XIntc_RegisterHandler(XPAR_XPS_INTC_0_BASEADDR,
   		                 XPAR_XPS_INTC_0_XPS_TIMER_0_INTERRUPT_INTR,
                         (XInterruptHandler) timer_int_handler,
                         (void *)XPAR_XPS_TIMER_0_BASEADDR);

   XIntc_MasterEnable(XPAR_XPS_INTC_0_BASEADDR);
   XIntc_EnableIntr(XPAR_XPS_INTC_0_BASEADDR, 0x1);

   XTmrCtr_SetLoadReg(XPAR_XPS_TIMER_0_BASEADDR, 0, 333333);

   XTmrCtr_SetControlStatusReg(XPAR_XPS_TIMER_0_BASEADDR, 0, XTC_CSR_INT_OCCURED_MASK | XTC_CSR_LOAD_MASK );

   XIntc_EnableIntr(XPAR_XPS_TIMER_0_BASEADDR, XPAR_XPS_TIMER_0_INTERRUPT_MASK);

   XTmrCtr_SetControlStatusReg(XPAR_XPS_TIMER_0_BASEADDR, 0, XTC_CSR_ENABLE_TMR_MASK | XTC_CSR_ENABLE_INT_MASK |
     						XTC_CSR_AUTO_RELOAD_MASK | XTC_CSR_DOWN_COUNT_MASK);

   microblaze_enable_interrupts();

   InitializeGame(x_cur, y_cur);status=PVP;

   xil_printf("-- Game Starts! --\r\n");
   xil_printf("\r\nHuman Player's turn!\r\n");

   int vga_input;
   vga_input=(0<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(1<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(2<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(3<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(4<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(5<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(6<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(7<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(8<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(0<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

   vga_input=(0<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(1<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(2<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(3<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(4<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(5<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(6<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(7<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(8<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

     vga_input=(0<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(1<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(2<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(3<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(4<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(5<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(6<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(7<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(8<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
     vga_input=(9<<24)+(29<<16)+(1<<8)+3;
     VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

   vga_input=(0<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(1<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(2<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(3<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(4<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(5<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(6<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(7<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(8<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

   vga_input=(9<<24)+(1<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(2<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(3<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(4<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(5<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(6<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(7<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(8<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(9<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(10<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

   vga_input=(9<<24)+(11<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(12<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(13<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(14<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(15<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(16<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(17<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(18<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(19<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(20<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);

   vga_input=(9<<24)+(21<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(22<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(23<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(24<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(25<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(26<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(27<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(28<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(29<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);
   vga_input=(9<<24)+(30<<16)+(1<<8)+3;
   VGA_IP_mWriteReg(XPAR_VGA_IP_0_BASEADDR, 0, vga_input);


   while (1)
   {
	  if (turn==HUMAN_PLAYER || (turn==COMPUTER_PLAYER && status==PVP)) {
		  do {
			  if (turn==COMPUTER_PLAYER && status==PVC)
			  	  break;
		      dip_check=XGpio_DiscreteRead(&dip, 1);
	          StatusReg = XPs2_GetStatus(&Ps2Inst);
	      }while((StatusReg & XPS2_STATUS_RX_FULL) == 0);
	      BytesReceived = XPs2_Recv(&Ps2Inst, &RxBuffer, 1);
	      key_count=(key_count+1)%3;
	      if (key_count==0) {
	    	  if (RxBuffer==0x21&& win_flag==0) {
	    		  DrawNumber(level,3,2,EMPTY);

	    		  if(level==1)
	    			  level=2;
	    		  else
	    			  level=1;

	    		  if(status==PVC )
	    		  DrawNumber(level,3,2,0);
	    		  else if(status==CVP)
			      DrawNumber(level,3,2,1);
	    		  else
	    		  DrawNumber(level,3,2,EMPTY);

	    	  }
		      if (RxBuffer==0x1D && win_flag==0) {
			      EraseCursor(x_cur, y_cur);
		          if (y_cur<=0)
		    	      y_cur=14;
		          else
		    	      y_cur--;
		          DrawChess(x_cur, y_cur, CURSOR);
		      }
		      if (RxBuffer==0x1B && win_flag==0) {
		  	      EraseCursor(x_cur, y_cur);
		  	      if (y_cur>=14)
		  	          y_cur=0;
		  	      else
		  	          y_cur++;
		  	      DrawChess(x_cur, y_cur, CURSOR);
		      }
		      if (RxBuffer==0x1C && win_flag==0) {
		  	      EraseCursor(x_cur, y_cur);
		  	      if (x_cur<=0)
		  	          x_cur=14;
		  	      else
		  		      x_cur--;
		  	      DrawChess(x_cur, y_cur, CURSOR);
		      }
		      if (RxBuffer==0x23 && win_flag==0) {
		  	      EraseCursor(x_cur, y_cur);
		  	      if (x_cur>=14)
		  	          x_cur=0;
		  	      else
		  		      x_cur++;
		  	      DrawChess(x_cur, y_cur, CURSOR);
		      }
		      if (RxBuffer==0x5A && win_flag==0) {
		    	  DrawBack(3,1119,EMPTY);
			      if (board_state[x_cur][y_cur]==EMPTY) {

			  	      if(status==CVP)
				      DrawChess(x_cur, y_cur, 1-turn);
			  	      else
			  	      DrawChess(x_cur, y_cur, turn);

				      board_state[x_cur][y_cur]=turn;
				      board_record[BackTimes].x=x_cur;
				      board_record[BackTimes].y=y_cur;
				      BackTimes++;
				      count=0;
				      time0=0;
				      if (turn==COMPUTER_PLAYER)
				    	  step_flag=1;
				      if (CheckWin(x_cur,y_cur,turn)==1) {
					      xil_printf("\r\nHuman Player wins!\r\n");
					      win_flag=1;
					      DrawWinning(0, 1, EMPTY);
					      if(status==CVP)
						      DrawWinning(0, 1, 1-turn);
					      else
					          DrawWinning(0, 1, turn);
				      }
				      if (CheckBan(x_cur,y_cur,turn)==1){
				    	  xil_printf("\r\nComputer Player wins!\r\n");
				    	  win_flag=1;
				    	  DrawWinning(0, 1, EMPTY);
					      if(status==CVP)
						      DrawWinning(0, 1, turn);
					      else
					          DrawWinning(0, 1, 1-turn);
				      }
				      else {
				    	  if (turn==HUMAN_PLAYER)
				    		  turn=COMPUTER_PLAYER;
				    	  else
				    		  turn=HUMAN_PLAYER;
				          xil_printf("\r\nComputer Player's turn!\r\n");
				      }
			      }
			  }
		      if (RxBuffer==0x29 && turn==HUMAN_PLAYER && win_flag==0) {
		    	  count=0;time0=0;

		    	  if (status==PVP) {
			    	  x_cur=7;
			    	  y_cur=7;
			    	  for (i=0; i<256; i++) {
			    	  		board_record[i].x=0;
			    	  	    board_record[i].y=0;
			    	  			  }
				      InitializeGame(x_cur, y_cur);status=PVP;
		    		  DrawStatus(1, 21, EMPTY,status);
		    		  status=PVC;
		    		  DrawNumber(level,3,2,0);
		    		  DrawStatus(1, 21, COMPUTER_PLAYER,status);
		    	  }
		    	  else if(status==PVC) {
			    	  x_cur=7;
			    	  y_cur=7;
			    	  for (i=0; i<256; i++) {
			    	  		board_record[i].x=0;
			    	  	    board_record[i].y=0;
			    	  			  }
				      InitializeGame(x_cur, y_cur);status=PVP;
		    		  DrawStatus(1, 21, EMPTY,status);
		    		  status=CVP;
		    		  DrawNumber(level,3,2,1);
		    		  DrawStatus(1, 21, COMPUTER_PLAYER,status);
		    		  turn=COMPUTER_PLAYER;
		    	  }
		    	  else if(status==CVP) {
			    	  x_cur=7;
			    	  y_cur=7;
			    	  for (i=0; i<256; i++) {
			    	  		board_record[i].x=0;
			    	  	    board_record[i].y=0;
			    	  			  }
				      InitializeGame(x_cur, y_cur);status=PVP;
		    		  DrawStatus(1, 21, EMPTY,status);
		    		  status=PVP;
		    		  DrawStatus(1, 21, COMPUTER_PLAYER,status);
		    	  }
		      }
		      if (RxBuffer==0x76) {
		    	  x_cur=7;
		    	  y_cur=7;
		    	  for (i=0; i<256; i++) {
		    	  		board_record[i].x=0;
		    	  	    board_record[i].y=0;
		    	  			  }
			      InitializeGame(x_cur, y_cur);status=PVP;
		      }
		      if (RxBuffer==0x2D) {
		      	  if(BackTimes>0){
		      		BackTimes--;
		      	  	x_cur=board_record[BackTimes].x;
		      	  	y_cur=board_record[BackTimes].y;
		      	  	board_state[x_cur][y_cur]=EMPTY;
		      	  	DrawChess(x_cur,y_cur,EMPTY);
		      	  	turn=1-turn;
		      	  	if(status==PVC)
		      	  	{
		      	  	BackTimes--;
		      	  	x_cur=board_record[BackTimes].x;
		      	  	y_cur=board_record[BackTimes].y;
		      	  	board_state[x_cur][y_cur]=EMPTY;
		      	  	DrawChess(x_cur,y_cur,EMPTY);
		      	  	turn=HUMAN_PLAYER;
		      	  	}
		      	    DrawBack(3,1119,turn);
		      	  					      }
		      	  				  		  }
	      }
	  }

	  if (turn==COMPUTER_PLAYER && (status==PVC ||status==CVP )&& win_flag==0) {
	      if (step_flag==0) {
	  		  if (x_cur-1<0)
	  			  x_pos=x_cur+1;
	  		  else
	  			  x_pos=x_cur-1;
	  		      y_pos=y_cur;
	  		      step_flag=1;
	      }
	  	  else {
	  		  if(level==2||level==3){
	  		  EvaluateComputerMove(board_state, 0, MIN_INFINITY, MAX_INFINITY, 0, 0);
	  		  x_pos=maxMoveX;
	  		  y_pos=maxMoveY;
	  		  xil_printf("\r\n computer \r\n");}
	  		  else
	  		  {
		  	  everyScore(Computer);
		  	  current_pos=best(Computer);
	  		  x_pos=current_pos.y;
	  		  y_pos=current_pos.x;
	  		  xil_printf("\r\n computer \r\n");
	  		  }

	  	  }
  	      xil_printf("\r\n%x, %x\r\n", x_pos, y_pos);

  	      if(status==CVP)
	      DrawChess(x_pos, y_pos, 1-turn);
  	      else
  	      DrawChess(x_pos, y_pos, turn);


	  	  board_state[x_pos][y_pos]=COMPUTER_PLAYER;
	  	  board_record[BackTimes].x=x_pos;
  		  board_record[BackTimes].y=y_pos;
  		  BackTimes++;

	  	  count=0;
	  	  time0=0;
	      if (CheckWin(x_pos, y_pos, turn)) {
	  	      xil_printf("\r\nComputer Player wins!\r\n");
	  	      win_flag=1;
	  	      DrawWinning(0,1, EMPTY);
	  	      if(status==CVP)
	  	    	  DrawWinning(0,1, 1-turn);
	  	      else
	  	    	  DrawWinning(0,1, turn);
	  	      turn=HUMAN_PLAYER;
	  	  }
	      else {
	    	  turn=HUMAN_PLAYER;
	    	  xil_printf("\r\nHuman Player's turn!\r\n");
	      }
	  }
   }
   return 0;
}
コード例 #20
0
ファイル: GameBoard.cpp プロジェクト: syvjohan/cppFun
//Reset GameBoard.
void GameBoard::Reset() {
    InitializeGame();
}