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


C++ game类代码示例

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


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

示例1: minmax

void minmax(game & cur)
{
	if (cur.finished())
	{
		cout << "game is done" << endl;
		return;
	}
	forward_list<game> moves = cur.getMoves();
	int best = -10000;
	game best_move;
	int count = 0;
	while(!moves.empty())
	{
		debug(++count);
		game top = moves.front();
		moves.pop_front();
		int score = calcvalue(top, true);
		if (score > best)
		{
			best_move = top;
			best = score;
		}
	}
	cout << "best move is \n" << best_move;
}
开发者ID:EvanTheB,项目名称:CITS3001,代码行数:25,代码来源:mancala.cpp

示例2: add_animation

void classMap::move_npcs() /// @TODO - check out of screen
{
	int i = 0;
	std::list<classnpc*>::iterator npc_it;
	//std::cout << "*************** classMap::showMap - npc_list.size: " << npc_list.size() << std::endl;
	for (npc_it = npc_list.begin(); npc_it != npc_list.end(); npc_it++) {
		//std::cout << ">>>>>>>>>>>>>>>>>> classMap::showMap - executing npc[" << i << "] '" << (*npc_it)->getName() << "'" << std::endl;
		bool temp_is_boss = (*npc_it)->is_boss();

		if (freeze_weapon_effect == false) {
			(*npc_it)->execute(); // TODO: must pass scroll map to npcs somwhow...
		}
		//(*npc_it)->show();
		if ((*npc_it)->is_dead() == true) {
			std::string temp_name = (*npc_it)->getName();
			if (!temp_is_boss) {
				add_animation(ANIMATION_STATIC, std::string("explosion_32.png"), st_position((*npc_it)->getPosition().x, (*npc_it)->getPosition().y), st_position(-8, -8), 80, 2, (*npc_it)->get_direction(), st_size(32, 32));
			}
			//std::cout << "Stage[" << stage_number << "].map[" << number << "] - Killed npc[" << i << "] '" << (*npc_it)->getName() << "'" << ", is_boss: " << temp_is_boss << std::endl;
			st_position npc_pos = (*npc_it)->get_real_position();
			delete (*npc_it);
			npc_list.erase(npc_it);
			if (temp_is_boss) {
				//std::cout << "classMap::showMap - killed boss" << std::endl;
				gameControl.draw_explosion(npc_pos.x, npc_pos.y, true);
				gameControl.got_weapon(temp_name);
			}
			return;
		}
		i++;
	}
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:32,代码来源:classmap.cpp

示例3: go_to_winscreen

void menu::go_to_winscreen(game& g)
{
	//postup do dalsich levelu kampane
	for (int i = 0;i < campaign.size();++i)
		if (maplist_get_name(g.get_mapchosen()).compare(campaign[i]) 
			== 0) 
			if (i != campaign.size() - 1) 
				g.change_campaign_status(i + 1);
	set_menu(12);
}
开发者ID:noox,项目名称:Drex,代码行数:10,代码来源:menu.cpp

示例4: main

/* 
 * Main function
 */
int main(int argc, char* args[]) {
	try{
		// Initialize game
		gam.init_game();

		// Go to main loop
		gam.main();
	}
	catch (exception &e) {err_hndl_obj.inform_about_error("main()", e);};

	// Quit application
	return 0;
}
开发者ID:pod25,项目名称:ball_blaster,代码行数:16,代码来源:ball_blaster.cpp

示例5: GameInit

void GameInit() {
	g_game_rand = random(GetTickCount());

	g_game._player = spawn_entity(&g_game, new player(), vec2(10.0f, 9.5f));

	for(int j = 0; j < MAP_HEIGHT; j++) {
		for(int i = 0; i < MAP_WIDTH; i++) {
			if (tile* t = g_game.get(i, j)) {
				if (j < 10) {
					t->type =  ((i == 0) || (i == MAP_WIDTH - 1)) ? TT_VOID : TT_EMPTY;
				}
				else if (j < (MAP_HEIGHT - 2)) {
					t->type = ((i == 0) || (i == MAP_WIDTH - 1)) ? TT_WALL : TT_SOLID;

					if ((i > 0) && (i < MAP_WIDTH - 1)) {
						int wall_c = max(20 - ((j - 10) / 2), 5);

						if (g_game_rand.rand(0, 150) == 0) {
							if (j > 20)
								t->ore = -1;
						}
						else if (g_game_rand.rand(0, wall_c) == 0) {
							t->type = TT_WALL;
						}
					}
				}
				else
					t->type = TT_WALL;
			}
		}

		int ores = clamp(j / 15, 1, 10) + g_game_rand.rand(0, 2);
		
		for(int z = 0; z < ores; z++) {
			int i = g_game_rand.rand(1, MAP_WIDTH - 2);

			if (tile* t = g_game.get(i, j)) {
				if (t->type == TT_SOLID) {
					if (t->ore == 0) {
						t->ore = 1;

						for(int z = j / 15; z > 0; z--)
							t->ore += g_game_rand.rand(0, 4) == 0;
					}
				}
			}
		}
	}
}
开发者ID:quantumrain,项目名称:LD29,代码行数:49,代码来源:Game.cpp

示例6: main

int main(int argc, char *argv[])
{
	quick_load = false;
	UNUSED(argc);
	gameControl.currentStage = TECHNOBOT;
	game_config.selected_player = 1;

	//strncpy (FILEPATH, argv[0], strlen(argv[0])-11);

	string argvString = string(argv[0]);

	FILEPATH = argvString.substr(0, argvString.size()-EXEC_NAME.size());
	//std::cout << "main - FILEPATH: " << FILEPATH << std::endl;

	format_v_2_0_1::file_io fio;
	fio.read_game(game_data);

	// INIT GRAPHICS
	if (graphLib.initGraphics() != true) {
		exit(-1);
	}

	// INIT GAME
	if (quick_load == false) {
		if (gameControl.showIntro() == false) {
			return 0;
		}
	} else {
		gameControl.quick_load_game();
		//ending game_ending;
		//game_ending.start();
	}

	input.clean();
	input.p1_input[BTN_START] = 0;
	input.waitTime(200);
	input.clean();
	while (true) {
		input.readInput();
		if (input.p1_input[BTN_QUIT] == 1) {
			exit(-1);
		}
		gameControl.showGame();
		graphLib.updateScreen();
	}
	/// @TODO: sdl quit sub-systems
	SDL_Quit();
	return 1;
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:49,代码来源:main.cpp

示例7: post_display

void sub_uzo_display::post_display(game& gm) const
{
	if (gm.get_player()->get_target()) {
		projection_data pd = get_projection_data(gm);
		ui.show_target(pd.x, pd.y, pd.w, pd.h, get_viewpos(gm));
	}

	sys().prepare_2d_drawing();
	
	int tex_w = compass->get_width();
	int tex_h = compass->get_height();

	int bearing = int(tex_w*ui.get_relative_bearing().value()/360);

	if( bearing>dx && bearing<tex_w-dx){
		compass->draw_subimage(xi, yi, comp_size, tex_h, bearing-dx, 0, comp_size, tex_h);
	} else {
		int dx1=0,dx2=0;
		if( bearing<dx ){ dx1=dx-bearing; dx2=dx+bearing; } else if( bearing>tex_w-dx ){ dx1=dx+(tex_w-bearing); dx2=comp_size-dx; }
		compass->draw_subimage(xi, yi, dx1, tex_h, tex_w-(dx1), 0, dx1, tex_h);
		compass->draw_subimage(xi+dx1, yi, dx2, tex_h, 0, 0, dx2, tex_h );
	}
	
	uzotex->draw(0, 0, 1024, 768);
	ui.draw_infopanel(true);

	sys().unprepare_2d_drawing();
}
开发者ID:traviscross,项目名称:dangerdeep-svn,代码行数:28,代码来源:sub_uzo_display.cpp

示例8: set_modelview_matrix

void sub_uzo_display::set_modelview_matrix(game& gm, const vector3& viewpos) const
{
	glLoadIdentity();

	// set up rotation (player's view direction)
	// limit elevation to -20...20 degrees.
	float elev = -ui.get_elevation().value();
	const float LIMIT = 20.0f;
	if (elev < -LIMIT - 90.0f) elev = -LIMIT - 90.0f;
	if (elev > +LIMIT - 90.0f) elev = +LIMIT - 90.0f;
	glRotated(elev,1,0,0);

	// if we're aboard the player's vessel move the world instead of the ship
	if (aboard) {
		// This should be a negative angle, but nautical view dir is clockwise,
		// OpenGL uses ccw values, so this is a double negation
		glRotated(ui.get_relative_bearing().value(),0,0,1);
		gm.get_player()->get_orientation().conj().rotmat4().multiply_gl();
	} else {
		// This should be a negative angle, but nautical view dir is clockwise,
		// OpenGL uses ccw values, so this is a double negation
		glRotated(ui.get_absolute_bearing().value(),0,0,1);
	}

	// set up modelview matrix as if player is at position (0, 0, 0), so do NOT set a translational part.
	// This is done to avoid rounding errors caused by large x/y values (modelview matrix seems to store floats,
	// but coordinates are in real meters, so float is not precise enough).
}
开发者ID:traviscross,项目名称:dangerdeep-svn,代码行数:28,代码来源:sub_uzo_display.cpp

示例9: display

void display() {
    glClear(GL_COLOR_BUFFER_BIT);
    painter p;
    game_.draw(p);

    glutSwapBuffers();
}
开发者ID:GarryDvaraza,项目名称:snake,代码行数:7,代码来源:main.cpp

示例10: update

// update
void update(MASTERSCREEN screen)
{
	mxhwnd.SetTimeFlag();
	
	switch(screen)
	{
	case ID_KLOSED:
		klosed.update();
		break;
	case ID_INTRO:
		intro.intro_update();
		break;
	
	case ID_OPTIONS:
		//options_update();
		break;
	case ID_GAME:
		
		game.update();
	
		break;
	case ID_GAMEOVER:
		//gameover_update();
		break;
	}
	
}
开发者ID:lostjared,项目名称:Old.DirectX.Programs,代码行数:28,代码来源:mastermain.cpp

示例11: waitTime

// ********************************************************************************************** //
//                                                                                                //
// ********************************************************************************************** //
int inputLib::waitScapeTime(int wait_period) {
	int now_time = 0;

	waitTime(50);
	now_time = timer.getTimer();
	wait_period = now_time + wait_period;

	while (now_time < wait_period) {
		readInput();
		if (p1_input[BTN_START] == 1 || p2_input[BTN_START] == 1) {
			return 1;
        } else if (p1_input[BTN_QUIT] == 1 || p2_input[BTN_QUIT] == 1) {
#if !defined(PLAYSTATION2) && !defined(PSP) && !defined(WII) && !defined(DREAMCAST)
            std::cout << "LEAVE #2" << std::endl;
            std::fflush(stdout);
            gameControl.leave_game();
#endif
		}
		now_time = timer.getTimer();
		#ifdef PLAYSTATION
			RotateThreadReadyQueue(_MIXER_THREAD_PRIORITY);
		#endif
        SDL_Delay(5);
	}
	return 0;
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:29,代码来源:inputlib.cpp

示例12: isGameOver

/**
* Checks the game winning conditions to see if it has been won.
*/
bool isGameOver()
{
	//checks to see if the game is over after each turn if all player hands and deck are empty
	int gameOverCounter=0;
	int totalPlayerCount=currentGame.getPlayerCount();
	for(int i = 0; i < totalPlayerCount; i++)
	{
		if(currentGame.getPlayer(i).getHand().size()==0)
			gameOverCounter++;
	}
	if(gameOverCounter==totalPlayerCount && currentGame.getDeck().isEmpty()==true)
	{
		return true;
	}
	else 
		return false;
}
开发者ID:marcochiang,项目名称:RoyalCrowns,代码行数:20,代码来源:main.cpp

示例13: keyEvent

void keyEvent(int key, int, int)
{
    switch (key)
    {
    case GLUT_KEY_LEFT:
        game_.keyEvent(snake::LEFT);
        break;
    case GLUT_KEY_UP:
        game_.keyEvent(snake::UP);
        break;
    case GLUT_KEY_RIGHT:
        game_.keyEvent(snake::RIGHT);
        break;
    case GLUT_KEY_DOWN:
        game_.keyEvent(snake::DOWN);
        break;
    }
}
开发者ID:GarryDvaraza,项目名称:snake,代码行数:18,代码来源:main.cpp

示例14: perror

bool networking::gameOverCheck(gameData gd, game Game){
	bool gameOver = Game.gameOver();
	if(write(gd.player1, &gameOver, sizeof(bool)) == -1)
	{
		perror("[server]Eroare la scriere in socket");
	}
	if(write(gd.player2, &gameOver, sizeof(bool)) == -1)
	{
		perror("[server]Eroare la scriere in socket");
	}
	return gameOver;
}
开发者ID:AntohiRazvan,项目名称:Connect4Server,代码行数:12,代码来源:networking.cpp

示例15: winConditionCheck

bool networking::winConditionCheck(gameData gd, game Game){
	bool winCondition = Game.winCondition();
	if(write(gd.player1, &winCondition, sizeof(bool)) == -1)
	{
		perror("[server]Eroare la scriere in socket");
	}
	if(write(gd.player2, &winCondition, sizeof(bool)) == -1)
	{
		perror("[server]Eroare la scriere in socket");
	}
	return winCondition;
}
开发者ID:AntohiRazvan,项目名称:Connect4Server,代码行数:12,代码来源:networking.cpp


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