Deux Ex Machina
This commit is contained in:
@@ -16,11 +16,11 @@ Building::Building(const std::string& filePath, const Vector2f& position, const
|
||||
void Building::Draw() const {
|
||||
utils::SetColor(Colors::WHITE);
|
||||
m_Texture->Draw(m_Position);
|
||||
utils::SetColor(Colors::GREEN);
|
||||
Rectf temp = m_BoundingBox;
|
||||
temp.left += m_Position.x;
|
||||
temp.bottom += m_Position.y;
|
||||
utils::DrawRect(temp);
|
||||
// utils::SetColor(Colors::GREEN);
|
||||
// Rectf temp = m_BoundingBox;
|
||||
// temp.left += m_Position.x;
|
||||
// temp.bottom += m_Position.y;
|
||||
// utils::DrawRect(temp);
|
||||
}
|
||||
void Building::Update(float dt, const Rectf& objectBoundingBox) {
|
||||
if (IsObjectInHitbox(objectBoundingBox)) {
|
||||
|
||||
@@ -36,6 +36,13 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
m_GridManager.GetTileAtIndex(x, 0)->SetTileType(GroundTileTypeManager::GetInstance()->AIR);
|
||||
m_GridManager.GetTileAtIndex(x, 1)->SetTileType(GroundTileTypeManager::GetInstance()->GRASS);
|
||||
}
|
||||
|
||||
//Add to walls to the side of stone
|
||||
for (int y { 0 }; y < WORLD_HEIGHT - 1; ++y) {
|
||||
m_GridManager.GetTileAtIndex(0, y)->SetTileType(GroundTileTypeManager::GetInstance()->STONE);
|
||||
m_GridManager.GetTileAtIndex(WORLD_WIDTH - 1, y)->SetTileType(GroundTileTypeManager::GetInstance()->STONE);
|
||||
}
|
||||
|
||||
Building* fuelBuilding = new Building { "buildings/fuelStation.png", Vector2f { -700, -52 }, Rectf{0 ,0, 50, 50}, TextureManager::GetInstance() };
|
||||
fuelBuilding->SetOnEnterHitbox([]() {
|
||||
ScreenManager::GetInstance()->OpenScreen(ScreenManager::m_FuelScreen);
|
||||
@@ -78,8 +85,8 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
m_MainScreen = new MainScreen(TextureManager::GetInstance());
|
||||
GameManager::GetInstance().SetMainScreen(m_MainScreen);
|
||||
|
||||
m_Sun = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.5f, TextureManager::GetInstance()->GetTexture("sun.png"));
|
||||
m_Moon = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.5f, TextureManager::GetInstance()->GetTexture("moon.png"), M_PI);
|
||||
m_Sun = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.1f, TextureManager::GetInstance()->GetTexture("sun.png"));
|
||||
m_Moon = new OrbitingObject(Vector2f{0, -1000}, 1200, 0.1f, TextureManager::GetInstance()->GetTexture("moon.png"), M_PI);
|
||||
|
||||
GameManager::GetInstance().SetFuel(100);
|
||||
GameManager::GetInstance().SetHullIntegrity(100);
|
||||
@@ -87,7 +94,10 @@ WorldLevel::WorldLevel(Camera* camera, Rectf viewport): Level(camera),
|
||||
GameManager::GetInstance().SetPlayer(&m_Player);
|
||||
|
||||
m_BackgroundMusic = new SoundStream("sound/bgm.wav");
|
||||
m_BackgroundMusic->Play(0);
|
||||
m_BackgroundMusic->Play(-1);
|
||||
|
||||
GameManager::GetInstance().SetMoney(100);
|
||||
|
||||
}
|
||||
WorldLevel::~WorldLevel() {
|
||||
delete m_MainScreen;
|
||||
@@ -149,6 +159,7 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
}
|
||||
|
||||
//Move the camera when the player gets to the edge
|
||||
//Also lock the camera from going below -800 and above -100
|
||||
if(m_FollowPlayer) {
|
||||
Vector2f playerPos = m_Player.GetPosition();
|
||||
Vector2f newCameraPos = m_pCamera->GetPosition();
|
||||
@@ -158,12 +169,13 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
if (playerPos.x > newCameraPos.x + m_Viewport.width - 100) {
|
||||
newCameraPos.x = playerPos.x - m_Viewport.width + 100;
|
||||
}
|
||||
if (playerPos.y < newCameraPos.y + 50) {
|
||||
newCameraPos.y = playerPos.y - 50;
|
||||
if (playerPos.y < newCameraPos.y + 100) {
|
||||
newCameraPos.y = playerPos.y - 100;
|
||||
}
|
||||
if (playerPos.y > newCameraPos.y + m_Viewport.height - 100) {
|
||||
newCameraPos.y = playerPos.y - m_Viewport.height + 100;
|
||||
if (playerPos.y > newCameraPos.y + m_Viewport.height - 150) {
|
||||
newCameraPos.y = playerPos.y - m_Viewport.height + 150;
|
||||
}
|
||||
newCameraPos.x = utils::clamp(newCameraPos.x, -800, -100);
|
||||
m_pCamera->SetPosition(newCameraPos);
|
||||
}
|
||||
|
||||
@@ -199,11 +211,11 @@ void WorldLevel::Draw() const {
|
||||
m_TopCover->Draw(Rectf{-850, -70, 850, -70 + 32}, Rectf{0, 0, WORLD_WIDTH * 50, 32});
|
||||
|
||||
for (Collision::CollisionRect rect : m_Rects) {
|
||||
utils::DrawRect(rect.pos, rect.size.x, rect.size.y);
|
||||
// utils::DrawRect(rect.pos, rect.size.x, rect.size.y);
|
||||
}
|
||||
|
||||
utils::SetColor(Colors::WHITE);
|
||||
utils::FillEllipse(m_MousePos, 2, 2);
|
||||
// utils::SetColor(Colors::WHITE);
|
||||
// utils::FillEllipse(m_MousePos, 2, 2);
|
||||
|
||||
for (int x { 0 }; x < WORLD_WIDTH; ++x) {
|
||||
for (int y { 0 }; y < WORLD_HEIGHT; ++y) {
|
||||
@@ -211,12 +223,12 @@ void WorldLevel::Draw() const {
|
||||
}
|
||||
}
|
||||
|
||||
utils::SetColor(Colors::MAGENTA);
|
||||
utils::FillEllipse(-5, -5, 5, 5);
|
||||
// utils::SetColor(Colors::MAGENTA);
|
||||
// utils::FillEllipse(-5, -5, 5, 5);
|
||||
|
||||
if (m_pSelectedTile != nullptr) {
|
||||
m_pSelectedTile->Draw();
|
||||
}
|
||||
// if (m_pSelectedTile != nullptr) {
|
||||
// m_pSelectedTile->Draw();
|
||||
// }
|
||||
|
||||
for(Building* building : m_Buildings) {
|
||||
building->Draw();
|
||||
@@ -224,14 +236,14 @@ void WorldLevel::Draw() const {
|
||||
|
||||
m_Player.Draw();
|
||||
|
||||
utils::SetColor(Colors::GREEN);
|
||||
utils::DrawArrow(Vector2f{0, 0}, m_MousePos);
|
||||
// utils::SetColor(Colors::GREEN);
|
||||
// utils::DrawArrow(Vector2f{0, 0}, m_MousePos);
|
||||
|
||||
m_pCamera->EndRendering();
|
||||
|
||||
utils::FillRect(utils::GetMousePos(), 10, 10);
|
||||
// utils::FillRect(utils::GetMousePos(), 10, 10);
|
||||
|
||||
utils::DrawRect(50, 50, m_Viewport.width - 100, m_Viewport.height - 100);
|
||||
// utils::DrawRect(50, 50, m_Viewport.width - 100, m_Viewport.height - 100);
|
||||
|
||||
const Screen* screen = m_ScreenManager->GetCurrentScreen();
|
||||
if (screen != nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user