• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ game类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: create

user_interface* user_interface::create(game& gm)
{
	sea_object* p = gm.get_player();
	user_interface* ui = 0;
	// check for interfaces
	if (dynamic_cast<submarine*>(p)) ui = new submarine_interface(gm);
#if 0
	else if (dynamic_cast<ship*>(p)) ui = new ship_interface(gm);
	else if (dynamic_cast<airplane*>(p)) ui = new airplane_interface(gm);
#endif
	if (ui) ui->finish_construction();
	return ui;
}
开发者ID:salamanderrake,项目名称:dangerdeep,代码行数:13,代码来源:user_interface.cpp


示例17: calcvalue

int calcvalue(game& cur, bool isMax)
{
	if (cur.finished())
	{
		if (isMax) return cur.getValue();
		return -cur.getValue();
	}
	forward_list<game> moves = cur.getMoves();
	int best = isMax? -10000 : 10000;
	while(!moves.empty())
	{
		game top = moves.front();
		moves.pop_front();
		int score = calcvalue(top, !isMax);
		if (isMax)
		{
			best = max(best, score);
		}
		else
			best = min(best, score);
	}
	return best;
}
开发者ID:EvanTheB,项目名称:CITS3001,代码行数:23,代码来源:mancala.cpp


示例18: reset_charging_shot

void classPlayer::death()
{
    std::cout << "PLAYER::death" << std::endl;
    map->print_objects_number();
    reset_charging_shot();
	map->clear_animations();
    map->print_objects_number();
    map->reset_objects();
    map->print_objects_number();
	dead = true;
	state.jump_state = NO_JUMP;
    freeze_weapon_effect = FREEZE_EFFECT_NONE;
    clear_move_commands();
	input.clean();
	state.direction = ANIM_DIRECTION_RIGHT;
	gameControl.draw_explosion(realPosition.x, realPosition.y, false);
    if (game_save.items.lifes == 0) {
        game_save.items.lifes = 3;
        std::cout << "GAME OVER" << std::endl;
        gameControl.game_over();
        return;
    }
    game_save.items.lifes--;
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:24,代码来源:classplayer.cpp


示例19: boss_move

void classboss::boss_move() {
	if (state.move_timer > timer.getTimer()) {
		return;
	}

	if (_initialized == 0) { /// @TODO: move this logic to map (player should not move while boss is presenting)
		_initialized++;
		gameControl.boss_intro();
		return;
	} else if (_initialized == 1) {
		if (position.x > RES_H/2 && gravity(true) == false) {
			_initialized++;
		}
		state.move_timer = timer.getTimer()+100;
		return;
	}


	//std::cout << "classboss::move [" << name << "]" << std::endl;
	/*
	int mapScrollX = map->getMapScrolling().x;
	int lock_point = map->getMapPointLock(st_position(position.x/16, position.y/16));
	struct struct_player_dist dist_players = dist_npc_players();
	*/

	if (first_run == 0) {
		// show boss dialogs here
		first_run = 1;
		//boss_energy = temp_npc;
		//play_boss_music();
		//show_dialog(STAGE_N, 1);
	}
	if (name == "Daisie Bot") {
		exec_daisiebot();
		//npc_gravity(temp_npc);
		return;
	} else if (name == "Ape Bot") {
		//exec_IA_Apebot(temp_npc);
        //exec_daisiebot();
		return;
	} else {
		gravity(false);
		return;
	}
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:45,代码来源:classboss.cpp


示例20: preload

void draw::preload()
{
    std::string filename = FILEPATH + "data/images/tilesets/ready.png";
    graphLib.surfaceFromFile(filename, &ready_message);

    filename = FILEPATH + "data/images/sprites/teleport_small.png";
    graphLib.surfaceFromFile(filename, &_teleport_small_gfx);

    // DROPABLE OBJECT GRAPHICS
    for (int i=0; i<GAME_MAX_OBJS; i++) {
        for (int j=0; j<DROP_ITEM_COUNT; j++) {
            short obj_type_n = gameControl.get_drop_item_id(j);
            if (obj_type_n != -1) {
                get_object_graphic(obj_type_n);
            }
        }
    }
}
开发者ID:DavidKnight247,项目名称:Rockbot-GCW0-port,代码行数:18,代码来源:draw.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ game_display类代码示例发布时间:2022-05-31
下一篇:
C++ g_import_t类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap