Ejemplo n.º 1
0
float WorldGenerator::GetOverworldBiomeValForSector(int sectorX, int sectorY)
{
	Vec2f roomCenter;
	roomCenter.X() = (float)(sectorX + ((abs(sectorX)+1) % 2));
	roomCenter.Y() = (float)(sectorY + ((abs(sectorY)+1) % 2));

	double val = m_biomeVoronoiModule.GetValue(roomCenter.X(), roomCenter.Y(), 0.0f);

	Assert(val >= -0.1f && val <= 1.1f, "Should be betweeon 0-1, with small libnoise related variance");

	return (float)val;
}
Ejemplo n.º 2
0
Vec2f Camera::ConvertRoomToScreen(const Vec2f& roomPosition)
{
	Vec2f offset = roomPosition - m_quad.LowerLeft();
	offset *= kTilePixelSize;

	//NOTE: System screen origin is upper-left, we want lower-left
	offset.Y() = kScreenSectorHeight - offset.Y();

	//TODO: Should this be here?  We don't want subpixel rendering
	offset.X() = floor(offset.X() + 0.5f);
	offset.Y() = floor(offset.Y() + 0.5f);

	return offset;
}
Ejemplo n.º 3
0
void ColliderOwner::OnRoomSwitch(Room* oldRoom, Room* newRoom)
{
	eastl::vector<uint> oldIndexes;
	oldIndexes.reserve(m_colliders.size());

	//TODO: Only Movers can switch rooms
	Assert(m_owner->GetMover() != nullptr, "Must be mover");
	Vec2f positionInNewRoom = newRoom->ConvertRoomPositionToThisRoom(m_owner->GetMover()->GetPosition().LowerLeft(), oldRoom);
	Vec2f roomOffset = positionInNewRoom - m_owner->GetMover()->GetPosition().LowerLeft();

	//copy colliders into new room
	for(uint x = 0; x < m_colliders.size(); ++x)
	{
		Collider* collider = oldRoom->GetCollisionSystem().ColliderAtIndex(m_colliders[x]);

		uint newIndex = newRoom->GetCollisionSystem().CopyCollider(collider);
		oldIndexes.push_back(m_colliders[x]);
		m_colliders[x] = newIndex;

		Collider* newCollider = newRoom->GetCollisionSystem().ColliderAtIndex(newIndex);

		//offset collider to be in new room
		OffsetCollider(newCollider, roomOffset.X(), roomOffset.Y());
	}

	//Sort indexes descending for reverse iteration removal
	std::sort(oldIndexes.begin(), oldIndexes.end(), std::greater<uint>());

	//remove colliders from old room
	for(uint x = 0; x < oldIndexes.size(); ++x)
	{
		oldRoom->GetCollisionSystem().ReturnCollider(oldIndexes[x]);
	}
}
Ejemplo n.º 4
0
void ColliderOwner::OffsetColliders(const Vec2f& offset)
{
	for(auto it = m_colliders.begin(); it != m_colliders.end(); ++it)
	{
		Collider* collider = m_owner->GetRoom()->GetCollisionSystem().ColliderAtIndex(*it);
		OffsetCollider(collider, offset.X(), offset.Y());
	}
}
Ejemplo n.º 5
0
void ColliderOwner::AddQuadCollider(const Quad& quad, CollisionType::Enum collisionType)
{
	uint colliderIndex = m_owner->GetRoom()->GetCollisionSystem().GetNewCollider();
	Collider* collider = m_owner->GetRoom()->GetCollisionSystem().ColliderAtIndex(colliderIndex);

	collider->shapeType = ColliderShapeType::Quad;
	collider->collisionType = collisionType;
	collider->ownerEntity = m_owner;

	Vec2f quadLowerLeft = quad.LowerLeft();
	Vec2f quadUpperRight = quad.UpperRight();

	collider->x1.m_quadLeft = quadLowerLeft.X();
	collider->x2.m_quadRight = quadUpperRight.X();
	collider->y1.m_quadDown = quadLowerLeft.Y();
	collider->y2.m_quadUp = quadUpperRight.Y();

	m_colliders.push_back(colliderIndex);
}
Ejemplo n.º 6
0
Vec3f operator^(const Vec2f& v_this, const Vec2f& other)
{
    Vec3f res(0,0,v_this.X()*other.Y()-v_this.Y()*other.X());
    return res;
}
Ejemplo n.º 7
0
Vec3f::Vec3f(const Vec2f &vector2, float z) : Vector<3, float>()
{
    m_tab[0]=vector2.X();
    m_tab[1]=vector2.Y();
    m_tab[2]=z;
}
Ejemplo n.º 8
0
OGLText::OGLText(Vec2f position, const Color& color, const std::string& text, const char* fontLoc, float size) :_position(position.X(), position.Y(), -1.f), m_text(text), _fontLoc(fontLoc), _color(color)
{
    m_font = new GLFont();
    m_font->Create(_fontLoc);
    //Create an approximation of how normal fontsizes work (Not 1:1, but close)
    _size = size * (1 - (1 / m_font->m_height));
    _width = _size * text.size();
    _rot = 0.f;
}
Ejemplo n.º 9
0
OGLText::OGLText(const Vec2f& position, const Color& color, const std::string& text, float size) :_position(position.X(), position.Y(), -1.f), m_text(text), _fontLoc("sansserif.glf"), _color(color)
{
    m_font = new GLFont();
    m_font->Create(_fontLoc);
    //Approximation of size based on 12px 24px 22px
    _size = size * (1 - (1 / m_font->m_height));
    _width = m_font->m_width * text.size();
    _rot = 0.f;
}