当前位置: 首页>>代码示例>>C++>>正文


C++ NewGame函数代码示例

本文整理汇总了C++中NewGame函数的典型用法代码示例。如果您正苦于以下问题:C++ NewGame函数的具体用法?C++ NewGame怎么用?C++ NewGame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了NewGame函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HandleKeys

void HandleKeys()
{
	if(!_bGameOver && !_bDemo)
	{
		//Move the car based upon the left/right key presses
		POINT ptVelocity = _pCarSprite->GetVelocity();
		
		if (GetAsyncKeyState(VK_LEFT) < 0)
		{
			//Move left
			ptVelocity.x = max((int)ptVelocity.x -1, -4);
			_pCarSprite->SetVelocity(ptVelocity);
		}

		else if (GetAsyncKeyState(VK_RIGHT) < 0)
		{
			//Move right
			ptVelocity.x = min((int)ptVelocity.x + 2, 6);
			_pCarSprite->SetVelocity(ptVelocity);
		}

		//Fire missiles based upon spacebar presses
		if ((++_iFireInputDelay > 6) && GetAsyncKeyState(VK_SPACE) < 0)
		{
			//Create a new missile sprite
			RECT  rcBounds = { 0, 0, 600, 450 };
			RECT  rcPos = _pCarSprite->GetPosition();
			Sprite* pSprite = new Sprite(_pMissileBitmap, rcBounds, BA_DIE);
			pSprite->SetPosition(rcPos.left + 15, 400);
			pSprite->SetVelocity(0, -7);
			_pGame->AddSprite(pSprite);

			//Play the missile (fire) sounds
			PlaySound((LPCSTR)IDW_MISSILE, _hInstance, SND_ASYNC | 
				SND_RESOURCE | SND_NOSTOP);

			//reset the input delay
			_iFireInputDelay = 0;
		}
	}
	
	//Start a new game based upon an Enter (Return) key press
	if (GetAsyncKeyState(VK_RETURN) < 0)
		if (_bDemo)
		{
			//Start a new game without the splash screen
			_bDemo = FALSE;
			NewGame();
		}
		else if (_bGameOver)
		{	
			//Start a new game
			NewGame();
		}
}
开发者ID:DetectiveRice,项目名称:Win32-Game-Engine,代码行数:55,代码来源:SpaceOut.cpp

示例2: GetClientRect

void CChineseChessView::OnLButtonUp(UINT nFlags, CPoint point)
{
	// TODO: ÔÚ´ËÌí¼ÓÏûÏ¢´¦Àí³ÌÐò´úÂëºÍ/»òµ÷ÓÃĬÈÏÖµ
	if (isMouseDown){
		isMouseDown=false;		
		CRect rect;
		GetClientRect(&rect);

		CPoint logpoint=PhysicalToLogicPoint(point);
		if (logpoint.x>=0){	
			//human move
			Gen();
			newmove.from = LogicPointToNum(selectedPoint); 
			newmove.dest = LogicPointToNum(logpoint);
			for (int i=gen_begin[ply]; i<gen_end[ply]; i++){
				if (gen_dat[i].m.from==newmove.from && gen_dat[i].m.dest==newmove.dest){
					if(UpdateNewMove()){
						UpdateDisplay(rect);
						int ret;
						ret=MessageBox("you are really a lucky dog,dare to try again?","Game Over",MB_YESNO);
						if (ret==IDYES){
							NewGame(true);
							return;
						}else{
							exit(0);
						}
					}
					side = xside; xside = 1-xside;
					//computer move
					short best;			
					best = AlphaBeta(-INFINITY, INFINITY, MAX_PLY);
					if(UpdateNewMove()){
						UpdateDisplay(rect);
						int ret;
						ret=MessageBox("afraid?dare to try again?","Game Over",MB_YESNO);
						if (ret==IDYES){
							NewGame(true);
							return;
						}else{
							exit(0);
						}
					}
					side = xside; xside = 1-xside;
					break;
				}
			}
			
		}

		UpdateDisplay(rect);
		
	}
	CView::OnLButtonUp(nFlags, point);
}
开发者ID:Sirien,项目名称:ChineseChess-1,代码行数:54,代码来源:ChineseChessView.cpp

示例3: RecordDemo

void RecordDemo (void)
{
	int level,esc;

	CenterWindow(26,3);
	PrintY+=6;
	CA_CacheGrChunk(STARTFONT);
	fontnumber=0;
	US_Print("  Demo which level(1-10):");
	VW_UpdateScreen();
	VW_FadeIn ();
	esc = !US_LineInput (px,py,str,NULL,true,2,0);
	if (esc)
		return;

	level = atoi (str);
	level--;

	SETFONTCOLOR(0,15);
	VW_FadeOut ();

#ifndef SPEAR
	NewGame (gd_hard,level/10);
	gamestate.mapon = level%10;
#else
	NewGame (gd_hard,0);
	gamestate.mapon = level;
#endif

	StartDemoRecord (level);

	DrawPlayScreen ();
	VW_FadeIn ();

	startgame = false;
	demorecord = true;

	SetupGameLevel ();
	StartMusic ();
	PM_CheckMainMem ();
	fizzlein = true;

	PlayLoop ();

	demoplayback = false;

	StopMusic ();
	VW_FadeOut ();
	ClearMemory ();

	FinishDemoRecord ();
}
开发者ID:AlbertoAngel,项目名称:Wolfenstein-Port,代码行数:52,代码来源:WL_GAME.C

示例4: Run

void Run(UI* ui)
{   if(ui == NULL) return;
    NewGame(ui->game);
    NextTurn(ui->game);
    int c, running = 1;
    while(running && ui->game->status != GAME_STATUS_ERROR)
    {   DisplayGame(ui);
        c = getch();
        switch(c)
        {
        case KEY_LEFT:
            if(ui->game->status != GAME_STATUS_LOST)
            {	if(PushLeft(ui->game)) NextTurn(ui->game);
                else CheckTurn(ui->game);
            }
            break;
        case KEY_RIGHT:
            if(ui->game->status != GAME_STATUS_LOST)
            {	if(PushRight(ui->game)) NextTurn(ui->game);
                else CheckTurn(ui->game);
            }
            break;
        case KEY_UP:
            if(ui->game->status != GAME_STATUS_LOST)
            {	if(PushUp(ui->game)) NextTurn(ui->game);
                else CheckTurn(ui->game);
            }
            break;
        case KEY_DOWN:
            if(ui->game->status != GAME_STATUS_LOST)
            {	if(PushDown(ui->game)) NextTurn(ui->game);
                else CheckTurn(ui->game);
            }
            break;
        case 'q':
            running = 0;
            break;
        case 'n':
            NewGame(ui->game);
            NextTurn(ui->game);
            break;
        case 'r':
            StartGame(ui->game);
            NextTurn(ui->game);
            break;
        default:
            break;
        }
    }
}
开发者ID:larso0,项目名称:2048,代码行数:50,代码来源:game_ui.c

示例5: JumpDialogProc

BOOL CALLBACK JumpDialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	int n;

	switch (msg) {
	case WM_INITDIALOG:
		EnableLinkText(hwnd);
		SetDlgItemInt(hwnd, IDD_NUMBER, nMap + 1, FALSE);
		SendDlgItemMessage(hwnd, IDD_NUMBER + 1, UDM_SETBUDDY, (WPARAM)GetDlgItem(hwnd, IDD_NUMBER), 0);
		SendDlgItemMessage(hwnd, IDD_NUMBER + 1, UDM_SETRANGE, 0, MAKELONG(nMapMax + 1, 1));
		return TRUE;
	case WM_COMMAND:
		switch (wParam) {
		case IDOK:
			n = GetDlgItemInt(hwnd, IDD_NUMBER, NULL, FALSE);
			if (n >= 1 && n <= nMapMax + 1) {
				nMap = n - 1;
				NewGame(hwndMain, nMap);
			}
			;	// no break;
		case IDCANCEL:
			EndDialog(hwnd, 0);
			return TRUE;
		}
		break;
	case WM_CLOSE:
		EndDialog(hwnd,0);
		return 1;
	}
	return FALSE;
}
开发者ID:larryli,项目名称:BoxWorld,代码行数:31,代码来源:boxworld.c

示例6: main

int main(int argc, char** argv)
{
    char inbuf[256];
    char playerstring[1];
    int X,Y;

    turn = 0;
    fgets(inbuf, 256, stdin);
    if (sscanf(inbuf, "game %1s %d %d %d", playerstring, &depthlimit,
                &timelimit1, &timelimit2) != 4) error("Bad initial input");
    if (timelimit2 != 0) timelimit1 = timelimit2 / 64;
    if (timelimit1 == 0 && depthlimit == 0) depthlimit = 4;

    if (playerstring[0] == 'B') me = 1; else me = -1;
    NewGame();
    if (me == 1) MakeMove();
    while (fgets(inbuf, 256, stdin)!=NULL){
        if (strncmp(inbuf,"pass",4)!=0) {
            if (sscanf(inbuf, "%d %d", &X, &Y) != 2) return 0;
            Update(gamestate, -me, X, Y);
            if (debug) printboard(gamestate, -me, ++turn, X, Y);
        }
        MakeMove();
    }
    return 0;
}
开发者ID:jeremywrnr,项目名称:cxref.rb,代码行数:26,代码来源:windows.c

示例7: NewGame

void MainWindow::on_pushButton_4_clicked()
{
    NewGame();
    /*
    qsrand(qrand());
    int money = qrand() % ((2 + 1) - 0) + 0;

    qDebug() << "Money " << money;

    for(int i = 0; i < doorList.count(); i++)
        doorList[i].SetWinner(false);

    doorList[money].SetWinner(true);

    CurrentStatus = 0;
    Round++;
    Correct = 0;
    Wrong = 0;
    Result = 0;

    ui->labelRound->setText(QString::number(Round) + "/10");

    UpdateStatus();

    ui->pushButtonDoorOne->setChecked(false);
    ui->pushButtonDoorTwo->setChecked(false);
    ui->pushButtonDoorThree->setChecked(false);*/
}
开发者ID:updSI,项目名称:MontyHall,代码行数:28,代码来源:mainwindow.cpp

示例8: main

int main() {

  int choix = 0, nb = 0;

  aff_Bienvenue();

  system("PAUSE");
  system("cls");

  aff_menuPrincipal();
  choix_Menu(&choix);

  switch (choix) {
  case 1:
    NewGame();
    break;
  case 2:
    nb = continuGame();
    break;
  case 3:
    nb = Quitter();
    break;
  }

  // printf("Votre choix vaut : %d", nb);
  return EXIT_SUCCESS;
}
开发者ID:Psykoangel,项目名称:cpp_projects_repo,代码行数:27,代码来源:main.c

示例9: NewGame

DGLE_RESULT DGLE_API Game::Initialize()
{
	pEngineCore->GetSubSystem(ESS_INPUT, (IEngineSubSystem *&)pInput);

	IRender *p_render;
	pEngineCore->GetSubSystem(ESS_RENDER, (IEngineSubSystem *&)p_render);
	p_render->SetClearColor(ColorWhite());
	p_render->GetRender2D(pRender2D);

	IResourceManager *p_res_man;
	pEngineCore->GetSubSystem(ESS_RESOURCE_MANAGER, (IEngineSubSystem *&)p_res_man);

	IEngineBaseObject *p_tmp_obj;

	p_res_man->GetDefaultResource(EOT_BITMAP_FONT, (IEngineBaseObject *&)pFont); // getting default font
	//p_res_man->Load(RESOURCE_PATH"\\fonts\\Times_New_Roman_12_rus.dft", (IEngineBaseObject *&)pFont, RES_LOAD_DEFAULT);

	p_res_man->Load(RESOURCE_PATH"\\sounds\\SwallowScore.wav", p_tmp_obj, RES_LOAD_DEFAULT, "SndSwallowScore");
	p_res_man->Load(RESOURCE_PATH"\\sounds\\SwallowBlackScore.wav", p_tmp_obj, RES_LOAD_DEFAULT, "SndSwallowBlackScore");
	p_res_man->Load(RESOURCE_PATH"\\sounds\\SwallowBigScore.wav", p_tmp_obj, RES_LOAD_DEFAULT, "SndSwallowBigScore");
	p_res_man->Load(RESOURCE_PATH"\\sounds\\SwallowHelpScore.wav", p_tmp_obj, RES_LOAD_DEFAULT, "SndSwallowHelpScore");
	p_res_man->Load(RESOURCE_PATH"\\sounds\\SwallowExit.wav", p_tmp_obj, RES_LOAD_DEFAULT, "SndSwallowExit");
	p_res_man->Load(RESOURCE_PATH"\\sounds\\SwallowGhost.wav", p_tmp_obj, RES_LOAD_DEFAULT, "SndSwallowGhost");
	p_res_man->Load(RESOURCE_PATH"\\sounds\\LostScore.wav", p_tmp_obj, RES_LOAD_DEFAULT, "SndLostScore");
	p_res_man->Load(RESOURCE_PATH"\\sounds\\IncreaseLives.wav", p_tmp_obj, RES_LOAD_DEFAULT, "SndIncreaseLives");

	NewGame();

	return S_OK;
}
开发者ID:sig-vip,项目名称:Pacman,代码行数:30,代码来源:game.cpp

示例10: RunGame

void RunGame( int load) {
    game g = NULL;
    if(load) {
        g = LoadGame();
    } else {
        g = NewGame();
    }
    if(g==NULL) {
        return;
    }
    wrefresh(g->arena);
    wrefresh(g->status);
    if(g!=NULL) {
        if(g->pc) g->print(g->pc);
        creature G = CreateCreature(g);
        G = g->ZombieListHead;
        while(G) {
            g->print(G->Character);
            G = G->Next;
        }
        PrintAllBuildings(g->gameMap, g->pc->pos);
        PlayLoop(g);
        if(G) {
            PurgeCreatureNode(G);
            DESTROY(G);
        }
        PurgeGame(g);
        DESTROY(g);
    }
}
开发者ID:cryptarch,项目名称:zombies,代码行数:30,代码来源:Game.c

示例11: start_menu

void start_menu()
{
	printf("Menu:\n");
	printf("1. New Game\n");
	printf("2. Load Game\n");
	printf("Pilihan: ");
	int pilihan;
	read_with_limit(1, 2, &pilihan);
	if (pilihan == 1)
	{
		printf("Num of Player? ");
		read_with_limit(1, PLAYER_MAX, &pilihan);
		NewGame(pilihan);
		gamesystem_start();
	}
	else
	{
		Kata input;
		do
		{
			printf("Masukan kata kunci yang dipakai saat save game : "); BacaKata(&input);
			LoadGame(input);

		}while (FirstPetak(global.listOfPetak) == Nil);
		
		gamesystem_start();
	}
}
开发者ID:ParadiseCatz,项目名称:IF2110-Tubes-Alstruk--Monopoly,代码行数:28,代码来源:Main.c

示例12: if

// перемещает фишку из клетки, в которой сделан щелчок
// в свободную клетку
void __fastcall TForm1::Move(int cx, int cy)
{
    if  ( ( abs(cx - ex) == 1  &&  cy-ey == 0  ) ||
          ( abs(cy - ey) == 1  &&  cx-ex == 0  ) )
    {
        // переместить фишку из (cx,cy) в (ex,ey)
        pole[ey][ex] = pole[cy][cx];
        pole[cy][cx] = 16;
        ex = cx;
        ey = cy;
        // отрисовать поле
        ShowPole();
        if ( Finish () )
        {
            GameOver = true;
            ShowPole();
            int r = MessageDlg ("Цель достигнута! Еще раз (другая картинка)?",
                                mtInformation, TMsgDlgButtons() << mbYes << mbNo, 0);
            if ( r == mrNo )
                Form1->Close(); // завершить работу программы
            else
            {
                NewGame();
                ShowPole();
            }
        }
    }
}
开发者ID:teadrinker95,项目名称:khai,代码行数:30,代码来源:PuzMain.cpp

示例13: lk

	void BotGameSet::TimerCheck(uint tick)
	{
		Common::ScopedLock<Common::Mutex> lk(_locker);
		std::map<uint, BotGame::Pointer>::iterator it;
		for(it = _games.begin(); it != _games.end(); ++ it)
		{
			if(it->second.get())
				it->second->TimerCheck(tick);
		}
		if(botCfg.AutoGame() && MapCfgPool::GetSingleton().GetCount() > 0)
		{
			MapCfg::Pointer cfg = MapCfgPool::GetSingleton()[botCfg.AutoDefMap()];
			if(cfg.get() == NULL)
				cfg = MapCfgPool::GetSingleton()[0];
			while(_games.size() < botCfg.AutoMaxCount())
			{
				static int counter = 0;
				++ counter;
				char numstr[128];
				sprintf(numstr, "%d", counter);
				if(!NewGame(botCfg.AutoName() + " #" + numstr, botCfg.AutoName(), cfg, cfg->GetDefaultReferee()))
					break;
			}
		}
	}
开发者ID:KimimaroTsukimiya,项目名称:w3hostbot,代码行数:25,代码来源:BotGameSet.cpp

示例14: main

int main(int argc, char *argv[])
{
	if( SDL_Init(SDL_INIT_AUDIO|SDL_INIT_VIDEO) < 0 ){
		printf("Unable to initialize SDL: %s\n", SDL_GetError());
		exit(1);
	}
	atexit(SDL_Quit);

	screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 32, SDL_HWSURFACE|SDL_HWPALETTE|SDL_DOUBLEBUF);
//	screen = SDL_SetVideoMode(800, 600, 32, SDL_SWSURFACE|SDL_HWPALETTE); //Slow


	if(screen == NULL)
	{
		printf("Unable to set 0x0 video: %s\n", SDL_GetError());
		exit(1);
	}

	Initialize();
	NewGame();
	Scorpion.DrawStaticScene();

	SDL_Event event;
	int done = 0;

	while(done == 0)
	{
		while(SDL_PollEvent(&event))
		{
			switch(event.type)
			{
				case SDL_QUIT:
     				return 0;

				case SDL_KEYDOWN:
     				if(event.key.keysym.sym == SDLK_ESCAPE) { done = 1; }
					HandleKeyDownEvent(event);
         			break;

				case SDL_MOUSEBUTTONDOWN:
					HandleMouseDownEvent(event);
  					break;

				case SDL_MOUSEMOTION:
					HandleMouseMoveEvent(event);
					break;

				case SDL_MOUSEBUTTONUP:
					HandleMouseUpEvent(event);
 					break;
			}
		}
	}

// perform cleaning up in here

	freeFont(font1);
	freeFont(font2);
	return 0;
}
开发者ID:akrutsinger,项目名称:Cards,代码行数:60,代码来源:main.cpp

示例15: main

/***************************************************************
 Main function
***************************************************************/			
int main()
{
	srand(time(NULL));
	NewGame();
    InitGraphics();
	return 0;
}
开发者ID:huangjs,项目名称:cl,代码行数:10,代码来源:main.c


注:本文中的NewGame函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。