예제 #1
0
파일: PlayState.cpp 프로젝트: ChadyG/LD19
bool PlayState::testPoint(int i)
{
	b2Transform tx;
	tx.position = m_AIs[i].pos;
	tx.R = b2Mat22(0);
	return m_Shape.TestPoint(tx, b2Vec2(m_PlayerPos.x + 2.0f, m_PlayerPos.y));
}
예제 #2
0
void Flamethrower::onFire(b2Vec2 direction, bool constantFire, bool isPlayer)
{
	direction.Normalize();
	b2Mat22 matrix1 = b2Mat22(degree2radian(float(rand() % 600) / 100.0f));
	b2Mat22 matrix2 = b2Mat22(degree2radian(float(rand() % 600) / 100.0f));
	b2Mat22 matrix3 = b2Mat22(degree2radian(float(rand() % 600 - 300) / 100.0f));
	direction = b2Mul(matrix1, direction);
	b2Vec2 direction2 = b2Mul(matrix2, direction);
	b2Vec2 direction3 = b2Mul(matrix3, direction);
	EntityFactory *entityFactory = new FlamethrowerBulletFactory();
	EntityProperties& properties = entityFactory->getDefaultProperties();
	properties.x = meter2pixel(this->getBody(0)->GetPosition().x);
	properties.y = meter2pixel(this->getBody(0)->GetPosition().y);
	properties.special = true;
	float speed = 0.7f;
	FlamethrowerBullet *flamethrowerBullet = (FlamethrowerBullet*)entityFactory->create(properties);
	flamethrowerBullet->getBody(0)->ApplyForce(speed * 0.75f * direction, this->getBody(0)->GetPosition());
	flamethrowerBullet = (FlamethrowerBullet*)entityFactory->create(properties);
	flamethrowerBullet->getBody(0)->ApplyForce(speed * 0.75f * direction2, this->getBody(0)->GetPosition());
	flamethrowerBullet = (FlamethrowerBullet*)entityFactory->create(properties);
	flamethrowerBullet->getBody(0)->ApplyForce(speed * 0.82f * direction3, this->getBody(0)->GetPosition());
}