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


C++ Enemy::Init方法代码示例

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


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

示例1: setup

void BasicApp::setup()
{
	this->setFullScreen(false);


	// start the sound engine with default parameters
	engine = createIrrKlangDevice();

	if (!engine)
	{
	 	return; 
	}

	mFont		    = Font( "Times New Roman", 32 );
	mParams		    = params::InterfaceGl( "App parameters", Vec2i( 200, 400 ) );
	game_state		= Game_Demo;
	firingTime		= 0;
	score			= 0;
	numberAsteriods = 0;
	delay			= 20;
	currentShip.Init(Vec2f((float)getWindowWidth()/2,(float)getWindowHeight()/2)); 
	particleManager.Init_Particles();
	enemy.Init();

	for (int i=0; i<5;i++)
	{
		Ship ship;
		ship.Init(Vec2f(10+20*i,70));
		ships.push_back(ship);
	}
	for (int i=0; i<8; i++)
	{
		Asteroid asteroid;
		int shape = rand()%2+1;
		asteroid.Init(1, 0.5);
		asteroids.push_back(asteroid);

	}
}
开发者ID:AndreAhmed,项目名称:asteroids-atari-clone,代码行数:39,代码来源:basicApp.cpp

示例2: main

int main()
{
	// Init GLFW
	glfwInit();
	
	// Create a GLFWwindow object that we can use for GLFW's functions
	Window window = Window(WIDTH, HEIGHT, TITLE);
	window.DefineViewport();

	//glfwSetInputMode(window.getWindowPtr(), GLFW_CURSOR, GLFW_CURSOR_DISABLED);			
	/// ^(Maybe use this later)

	// Callback functions
	glfwSetKeyCallback(window.getWindowPtr() , key_callback);

	// Init GLEW
	glewExperimental = GL_TRUE;
	glewInit();

	// Enable alpha channel transparency
	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	// Load and compile shaders to a program
	Shader ShaderProgram = Shader("../deps/shaders/shadervert.vs", "../deps/shaders/shaderfrag.fs");

	// Load explosion graphics
	extern_Explosion.Init(ShaderProgram.GetProgramID());

	// Load texture/Game objects
	Texture2D texture_background1 = Texture2D("../deps/textures/backgroundSpace_01.1.png", PNG_RGB);
	SpriteMap Background = SpriteMap(texture_background1, 1.0f, 1.0f, glm::vec3(0.0f, 0.0f, 0.0f), 1.0f, BACKGROUND);

	Player PlayerShip;
	PlayerShip.Init(moveSpeed);

	Enemy Enemies;
	Enemies.Init();

	// Projection matrix: ortho for 2D
	glm::mat4 proj = glm::ortho(0, window.getWidth(), 0, window.getHeight());


	// Game loop
	while (!window.ShouldClose())
	{
		double startFrame = glfwGetTime();  ///< for FPS limiting

		// Check if any events have been activiated and call callback function (via GLFW)
		glfwPollEvents();

		// Clear the colorbuffer
		glClearColor(0.6f, 0.8f, 0.8f, 1.0f);
		glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

		/*	   Drawing	    */

		ShaderProgram.Use();

		// Background position and drawing calculations - just identity matrix
		glm::mat4 model;
		GLint modelLoc = glGetUniformLocation(ShaderProgram.GetProgramID(), "model");
		glUniformMatrix4fv(modelLoc, 1, GL_FALSE, glm::value_ptr(model));

		Background.BackgroundScroll(scrollSpeed);
		Background.Draw();

		Collision::EnemyHit(&PlayerShip, &Enemies);
		Collision::PlayerHit(&PlayerShip, &Enemies);
		Collision::ShipsCollide(&PlayerShip, &Enemies);

		PlayerShip.Move(keys);
		PlayerShip.AddShots(keys);
		PlayerShip.Draw(ShaderProgram.GetProgramID());
		
		Enemies.Move();
		Enemies.Shoot(PlayerShip.GetPosition());
		Enemies.Draw(ShaderProgram.GetProgramID());

		extern_Explosion.Draw();

		// FPS Calculation/Limiting
		float fps = CalculateFPS();
		static int printFPS = 0;
		if (printFPS == 100) {
			Enemies.Add(EN_0, PlayerShip.GetPosition());
			Enemies.Add(EN_1, PlayerShip.GetPosition());
			std::cout << fps << std::endl;
			printFPS = 0;
		} else {
			printFPS++;
		}
		
		
		LimitFPS(FPS, startFrame);
		
		if (PlayerShip.GetLives() <= 0)
		{
			window.Close();
		}
//.........这里部分代码省略.........
开发者ID:CurtisBuckoll,项目名称:SpaceGame,代码行数:101,代码来源:main.cpp

示例3: Update


//.........这里部分代码省略.........

	// Update boom
	for (vector<Boom*>::iterator it = boomList.begin(); it != boomList.end(); ++it)
	{
		Boom* b = *it;
		if (b->isActive())
		{
			b->Update(timedelta);
		}
	}

	// Packet receive
	if (Packet* packet = rakpeer_->Receive())
	{
		RakNet::BitStream bs(packet->data, packet->length, false);
		
		unsigned char msgid = 0;
		RakNetTime timestamp = 0;

		bs.Read(msgid);

		if (msgid == ID_TIMESTAMP)
		{
			bs.Read(timestamp);
			bs.Read(msgid);
		}

		switch(msgid)
		{
		case ID_CONNECTION_REQUEST_ACCEPTED:
			{
				std::cout << "Connected to Server" << std::endl;
				SendScreenSize();
				InitEnemyList();
				InitExplosionList();
				InitBoomList();
				InitProjectileList();
				InitBackground();
				InitBase();
				InitScore();
				chatMsg = new hgeFont("font1.fnt");
				chatMsg->SetScale(1);
				
			}
			break;

		case ID_NO_FREE_INCOMING_CONNECTIONS:
		case ID_CONNECTION_LOST:
		case ID_DISCONNECTION_NOTIFICATION:
			std::cout << "Lost Connection to Server" << std::endl;
			rakpeer_->DeallocatePacket(packet);
			return true;

		case ID_WELCOME:
			{
				unsigned int shipcount, id;
				float x_, y_;
				int type_;
				std::string temp;
				char chartemp[5];

				bs.Read(id);
				ships_.at(0)->setID( id );
				bs.Read(shipcount);

				for (unsigned int i = 0; i < shipcount; ++ i)
开发者ID:NothingMuch123,项目名称:Multiplayer-Assignment-2,代码行数:67,代码来源:Application.cpp


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