Esempio n. 1
0
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;
	}
}
Esempio n. 2
0
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;
	}
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
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;
				}
			}
		}
	}
	map[x][y] = 1;
	/*
	for (z2 = 1; z2 <= y * 2 + 1; z2++)
	{
		for (z1 = 1; z1 <= x * 2 + 1; z1++)
		{
			if (!map[z1][z2])
			{
				float x1 = (z1 - x) * MAZEPARTSIZE + SCREEN_WIDTH / 2;
				float y1 = (z2 - y) * MAZEPARTSIZE + SCREEN_HEIGHT / 2;
				Mine *wall = new Mine(x1, y1);
				wall->SetData(getw(z1, z2));
				InsertObject(wall);
			}
		}
	}
	*/
}