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


C++ HGE::Random_Int方法代码示例

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


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

示例1: move

void BOSSbase::move(float dt)
{
	HGE *hge = hgeCreate(HGE_VERSION);
	if (move_delay == 0)
	{
		target_y = hge->Random_Int(70, SCREEN_HEIGHT - 20);
		target_x = hge->Random_Int(12, SCREEN_WIDTH - 15);
		move_delay = hge->Random_Int(100, 500);//1s~5s切换移动方向
	}
	else
	{
		move_delay--;
		BALLbase::move(target_x, target_y, dt);
	}
	if (HP >= max)
	{
		HP = max;
		masure = true;
	}
	if(HP<max)masure = false;

	float add = HP / (float)max;
	if (alive && HP>0)
	{
		scale = 0.1 + 0.9*add;
		damage = 5 + 0.01*HP;
	}
}
开发者ID:Hiseen,项目名称:Old-Escope,代码行数:28,代码来源:BOSSbase.cpp

示例2: absorb

void BOSSbase::absorb(BLUEBALL &ball)
{
	if (masure == false)
	{
		HGE *hge = hgeCreate(HGE_VERSION);
		ball.dehealth = hge->Random_Int(min_sorb, max_sorb);
		ball.font = true;
		int copy = ball.HP;
		ball.HP -= ball.dehealth;
		if (ball.HP < 0)HP += copy;
		else HP += ball.dehealth;
	}
}
开发者ID:Hiseen,项目名称:Old-Escope,代码行数:13,代码来源:BOSSbase.cpp

示例3: MazeCollision

bool ObjectPool::MazeCollision(int x, int y,int &eventname,int &direction)
{
	float hx = Hero::GetHero().GetX();
	float hy = Hero::GetHero().GetY();
	float x1 = (x - startx) * MAZEPARTSIZE + SCREEN_WIDTH / 2 + movex;
	float y1 = (y - starty) * MAZEPARTSIZE + SCREEN_HEIGHT / 2 + movey;
	if (!map[x][y])
	{
		if (abs(hy - y1) < 37 && abs(hx - x1) < 37)
		{
			GameObject *a = GameObject::MakePosObject(x1, y1);
			float angle = a->GetAngle(&Hero::GetHero(), true);
			if (angle>=-0.785 && angle < 0.785)
			{
				//if (dy <= -5)
					//ReverseDy();
				//else
					//dy = 5;

			}
			if (angle >= 0.785 && angle < 2.355)
			{

				if (dx >= 5)
					ReverseDx();
				else
					dx = -5;
			}
			if (angle >= 2.355 && angle < 3.925)
			{

				if (dy >= 5)
					ReverseDy();
				else
					dy = -5;
			}
			if (angle >= 3.925 || angle < -0.785)
			{
				if (dx <= -5)
					ReverseDx();
				else
					dx = 5;
			}
			delete a;
			a = NULL;
		}
	}
	else if (map[x][y]!=1)
	{
		if (abs(hy - y1) < 37 && abs(hx - x1) < 37)
		{
			GameObject *a = GameObject::MakePosObject(x1, y1);
			float angle =a->GetAngle(&Hero::GetHero(), true);
			delete a;
			a = NULL;
			if (angle >= -0.785 && angle < 0.785)
				direction = DIRECTION_UP;
			if (angle >= 0.785 && angle < 2.355)
				direction = DIRECTION_RIGHT;
			if (angle >= 2.355 && angle < 3.925)
				direction = DIRECTION_DOWN;
			if (angle >= 3.925 || angle < -0.785)
				direction = DIRECTION_LEFT;
			HGE *hge = hgeCreate(HGE_VERSION);
			switch (map[x][y])
			{
			case MAZEPLUS:
				Hero::GetHero().varyHP(Hero::GetHero().GetMaxHP());
				break;
			case MAZEMINUS:
			    eventname = 2;
				break;
			case MAZESPICK:
				if (!Hero::GetHero().IsGod())
					Hero::GetHero().varyHP(-hge->Random_Int(10, 20));
				break;
			case MAZEITEM:
				eventname = 3;
				break;
			case MAZESKILL:
				eventname = 4;
				break;
			case MAZEMPHEAL:
				Hero::GetHero().varyMP(Hero::GetHero().GetMaxMP());
				break;
			case MAZEMINES:
				eventname = 5;
				break;
			case MAZESMALLBOSS:
				eventname = 6;
				break;
			case MAZEBOSS:
				eventname = 2;
				break;
			}
			return true;
		}
	}
	return false;
}
开发者ID:Hiseen,项目名称:HGE1,代码行数:100,代码来源:ObjectPool.cpp

示例4: CreateMaze

void ObjectPool::CreateMaze()
{
	HGE *hge = hgeCreate(HGE_VERSION);
	int x = 30, y = 30, z1, z2; //x和y的值指定了这个要生成的迷宫的大小
	for (int i = 0; i < 502; i++)
	for (int j = 0; j < 502; j++)
		map[i][j] = 0;
	Make_Maze(x, y);
	startx = x;
	starty = y;
	movexx = 0;
	moveyy = 0;
	movex = 0;
	movey = 0;
	map[1][2] = 1;
	map[2 * x + 1][2 * y] = 1;
	map[1][2 * y] = 1;
	map[2 * x + 1][2] = 1;
	//map[x + 1][y + 1] = 1;
	//map[x - 1][y - 1] = 1;
	//map[x - 1][y + 1] = 1;
	//map[x + 1][y - 1] = 1;
	//map[x - 1][y] = 1;
	//map[x + 1][y] = 1;
	//map[x][y + 1] = 1;
	//map[x][y - 1] = 1;
	for (z2 = 1; z2 <= y * 2 + 1; z2++)
	{
		for (z1 = 1; z1 <= x * 2 + 1; z1++)
		{
			if (map[z1][z2])
			{
				int counta = 0;
				int countb = 0;
				int count = 0;
				if (!map[z1 + 1][z2])
					counta++;
				else
				if (map[z1 + 1][z2] != 1)
					count++;
				if (!map[z1 - 1][z2])
					counta++;
				else
				if (map[z1 - 1][z2] != 1)
					count++;
				if (!map[z1][z2 + 1])
					countb++;
				else
				if (map[z1][z2 + 1]!=1)
					count++;
				if (!map[z1][z2 - 1])
					countb++;
				else
				if (map[z1][z2 - 1] != 1)
					count++;
				if ((counta==2 &&countb==1)||(counta==1 &&countb==2))
					map[z1][z2] = hge->Random_Int(MAZEPLUS,MAZEMPHEAL);
				//下面的语句可以将封口路变成MAZEMINUS(MAZEPLUS->MAZEMINUS)
				if (!count && ((counta == 2&&countb==0)||( countb==2 && counta==0)) && hge->Random_Int(0,100)<20)
				{
				    map[z1][z2] = hge->Random_Int(MAZEMINUS,MAZEMINES);
				}
			}
		}
	}
	for (z2 = 1; z2 <= y * 2 + 1; z2++)
	{
		for (z1 = 1; z1 <= x * 2 + 1; z1++)
		{
			if (abs(z1-x)>x/2 && abs(z2-y)>x/2 && map[z1][z2])
			{
				int counta = 0;
				int countb = 0;
				int count = 0;
				if (!map[z1 + 1][z2])
					counta++;
				else
				if (map[z1 + 1][z2] != 1)
					count++;
				if (!map[z1 - 1][z2])
					counta++;
				else
				if (map[z1 - 1][z2] != 1)
					count++;
				if (!map[z1][z2 + 1])
					countb++;
				else
				if (map[z1][z2 + 1] != 1)
					count++;
				if (!map[z1][z2 - 1])
					countb++;
				else
				if (map[z1][z2 - 1] != 1)
					count++;
				if (!count && ((counta == 2 && countb == 0) || (countb == 2 && counta == 0)) && hge->Random_Int(0, 100)<5)
				{
					map[z1][z2] = MAZESMALLBOSS;
				}
			}
		}
//.........这里部分代码省略.........
开发者ID:Hiseen,项目名称:HGE1,代码行数:101,代码来源:ObjectPool.cpp


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