Example #1
0
void Camera::CenterOnSector(Sector* sector)
{
	Vec2i sectorOffsetFromRoomOrigin = Vec2i(sector->X(), sector->Y()); - sector->GetRoom()->OriginSector(); 

	Vec2f sectorOriginInRoomSpace = Vec2f((float)sectorOffsetFromRoomOrigin.X() * kSectorTileWidth, (float)sectorOffsetFromRoomOrigin.Y() * kSectorTileHeight);

	m_quad.SetLowerLeft(sectorOriginInRoomSpace);
}
Example #2
0
void Sprite::Draw()
{
	if (current.X() == -1) {return;} //this method has been called before the sprite was updated for the first time. Ignore the mistake
	int ax = sheets[animations[current.X()].first.X().X()]->getAdjust().X();
	int ay = sheets[animations[current.X()].first.X().X()]->getAdjust().Y();
	Vec2i apos;//the position adjusted by any offset this sheet might have.
	apos.setX( (int)pos.X() + ax);
	apos.setY( (int)pos.Y() + ay);
	sheets[animations[current.X()].first.X().X()]->Blit(currentCell, (int)apos.X(), (int)apos.Y());
}
Example #3
0
Room* WorldGenerator::GenerateOverworldRoomForSector(int sectorX, int sectorY)
{
	//all overworld rooms are 2x2, start on an even sector

	Vec2i sectorStartCoord = Vec2i(sectorX, sectorY);
	sectorStartCoord.X() -= sectorStartCoord.X() % 2;
	sectorStartCoord.Y() -= sectorStartCoord.X() % 2;

	Room* room = new Room(sectorStartCoord, Vec2i(2,2), kLevelsOverworld);

	//set biome
	room->SetBiome(GetOverworldBiomeTypeForRoom(room));
	room->SetBiomeID(GetOverworldBiomeValForSector(sectorStartCoord.X(), sectorStartCoord.Y()));

	Assert(room->GetBiomeID() == g_game->GetWorld()->GetWorldGenerator().GetOverworldBiomeValForSector(sectorStartCoord.X(), sectorStartCoord.Y()), "Should be same");

	for(int x = sectorStartCoord.X(); x <= sectorStartCoord.X() + 1; ++x)
	{
		for(int y = sectorStartCoord.Y(); y <= sectorStartCoord.Y() + 1; ++y)
		{
			Sector* roomSector = g_game->GetWorld()->GetSectorSystem()->GetSector(x,y,kLevelsOverworld);

			if(roomSector == nullptr)
			{
				roomSector = g_game->GetWorld()->GetSectorSystem()->CreateSector(x,y,kLevelsOverworld);
			}

			roomSector->SetRoom(room);
		}
	}

	Log("(WorldGenerator): Generating Overworld room at (%i,%i), Biome: %f,%s", 
		sectorStartCoord.X(),sectorStartCoord.Y(),
		room->GetBiomeID(),
		BiomeType::GetDisplayName(room->GetBiome()));

	return room;
}