Add fly animations
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
|
||||
#include "Collision.h"
|
||||
#include "colors.h"
|
||||
#include "GameManager.h"
|
||||
#include "../../GridSystem/GroundTileTypeManager.h"
|
||||
#include "utils.h"
|
||||
#include "GridSystem/WorldTile.h"
|
||||
@@ -35,44 +36,56 @@ 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);
|
||||
}
|
||||
m_Buildings.emplace_back(Building { "buildings/fuelStation.png", Vector2f { -700, -52 }, TextureManager::GetInstance() });
|
||||
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);
|
||||
});
|
||||
m_Buildings.push_back(fuelBuilding);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f { -750, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f { -700, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f { -700, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f { -650, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f { -600, -50 })->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
|
||||
|
||||
m_Buildings.emplace_back(Building { "buildings/mineralStation.png", Vector2f { -350, -52 }, TextureManager::GetInstance() });
|
||||
|
||||
m_Buildings.emplace_back(new Building { "buildings/mineralStation.png", Vector2f { -350, -52 }, Rectf{0 ,0, 100, 100}, TextureManager::GetInstance() });
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {-400, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {-350, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {-300, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {-250, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {-200, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {-150, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
|
||||
|
||||
m_Buildings.emplace_back(Building { "buildings/junkStation.png", Vector2f { 250, -52 }, TextureManager::GetInstance() });
|
||||
|
||||
m_Buildings.emplace_back(new Building { "buildings/junkStation.png", Vector2f { 250, -52 }, Rectf{0 ,0, 100, 100}, TextureManager::GetInstance() });
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {200, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {250, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {300, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {350, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {400, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {450, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
|
||||
|
||||
m_Buildings.emplace_back(Building { "buildings/repairStation.png", Vector2f { 700, -52 }, TextureManager::GetInstance() });
|
||||
|
||||
m_Buildings.emplace_back(new Building { "buildings/repairStation.png", Vector2f { 700, -52 }, Rectf{0 ,0, 100, 100}, TextureManager::GetInstance() });
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {650, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_LEFT);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {700, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {750, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_MIDDLE);
|
||||
m_GridManager.GetTileAtWorldPos(Vector2f {800, -50})->SetTileType(GroundTileTypeManager::GetInstance()->HARD_RIGHT);
|
||||
// Texture* test = new Texture("gui/main/fuel_guage.png");
|
||||
|
||||
|
||||
m_topCover = TextureManager::GetInstance()->GetTexture("topBackground.png");
|
||||
|
||||
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);
|
||||
|
||||
|
||||
GameManager::GetInstance().SetFuel(100);
|
||||
GameManager::GetInstance().SetHullIntegrity(100);
|
||||
}
|
||||
WorldLevel::~WorldLevel() {
|
||||
delete m_MainScreen;
|
||||
|
||||
delete m_Sun;
|
||||
delete m_Moon;
|
||||
}
|
||||
void WorldLevel::Update(float elapsedSec) {
|
||||
m_Fps = 1 / elapsedSec;
|
||||
@@ -102,8 +115,9 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
}
|
||||
}
|
||||
|
||||
for (Building building : m_Buildings) {
|
||||
building.Update(elapsedSec);
|
||||
for (Building* building : m_Buildings) {
|
||||
building->Update(elapsedSec, m_Player.GetCollisionRect().getRectf());
|
||||
// building.IsPlayerInHitbox(Rectf{m_Player.GetCollisionRect().pos, m_Player.GetCollisionRect().size});
|
||||
}
|
||||
|
||||
|
||||
@@ -112,8 +126,9 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
m_pSelectedTile->SetTileType(GroundTileTypeManager::GetInstance()->AIR);
|
||||
}
|
||||
}
|
||||
|
||||
m_Player.Update(elapsedSec, *this);
|
||||
if(!m_ScreenManager->IsScreenOpen()) {
|
||||
m_Player.Update(elapsedSec, *this);
|
||||
}
|
||||
|
||||
//Move the camera when the player gets to the edge
|
||||
if(m_FollowPlayer) {
|
||||
@@ -139,8 +154,14 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
screen->Update(elapsedSec);
|
||||
}
|
||||
|
||||
m_MainScreen->Update(elapsedSec);
|
||||
GameManager::GetInstance().Update(elapsedSec);
|
||||
m_MainScreen->SetDepth(std::to_string((int)-m_Player.GetPosition().y - 50) + " ft.");
|
||||
m_MainScreen->SetScore("Score: " + std::to_string(GameManager::GetInstance().GetScore()));
|
||||
// m_MainScreen->SetFuelMeterValue(GameManager::GetInstance().GetFuel());
|
||||
// m_MainScreen->SetHullMeterValue(GameManager::GetInstance().GetHullIntegrity());
|
||||
m_MainScreen->Update(elapsedSec);
|
||||
|
||||
|
||||
|
||||
//Vector2f playerPos = m_player.GetPosition();
|
||||
//Vector2f newCameraPos = playerPos;
|
||||
@@ -152,6 +173,10 @@ void WorldLevel::Update(float elapsedSec) {
|
||||
void WorldLevel::Draw() const {
|
||||
|
||||
m_pCamera->BeginRendering();
|
||||
|
||||
m_Sun->Draw();
|
||||
m_Moon->Draw();
|
||||
|
||||
// m_topCover->Draw(Vector2f{-850,-70} );
|
||||
m_topCover->Draw(Rectf{-850, -70, 850, -70 + 32}, Rectf{0, 0, WORLD_WIDTH * 50, 32});
|
||||
|
||||
@@ -175,8 +200,8 @@ void WorldLevel::Draw() const {
|
||||
m_pSelectedTile->Draw();
|
||||
}
|
||||
|
||||
for(Building building : m_Buildings) {
|
||||
building.Draw();
|
||||
for(Building* building : m_Buildings) {
|
||||
building->Draw();
|
||||
}
|
||||
|
||||
m_Player.Draw();
|
||||
@@ -184,9 +209,6 @@ void WorldLevel::Draw() const {
|
||||
utils::SetColor(Colors::GREEN);
|
||||
utils::DrawArrow(Vector2f{0, 0}, m_MousePos);
|
||||
|
||||
m_Sun->Draw();
|
||||
m_Moon->Draw();
|
||||
|
||||
m_pCamera->EndRendering();
|
||||
|
||||
utils::FillRect(utils::GetMousePos(), 10, 10);
|
||||
@@ -209,7 +231,7 @@ void WorldLevel::ProcessImGui() {
|
||||
ImGui::Begin("Selected Tile");
|
||||
std::string tileType = "None";
|
||||
if (m_pSelectedTile != nullptr) {
|
||||
switch (m_pSelectedTile->GetTileType()->getType()) {
|
||||
switch (m_pSelectedTile->GetTileType()->GetType()) {
|
||||
case GroundTileTypes::Air:
|
||||
tileType = "Air";
|
||||
break;
|
||||
@@ -243,6 +265,9 @@ void WorldLevel::ProcessImGui() {
|
||||
if (ImGui::MenuItem("Player Info")) {
|
||||
m_ShowPlayerInfo = !m_ShowPlayerInfo;
|
||||
}
|
||||
if(ImGui::MenuItem("Game Manager Info")) {
|
||||
m_ShowGameManagerInfo = !m_ShowGameManagerInfo;
|
||||
}
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
if (ImGui::BeginMenu("Screens")) {
|
||||
@@ -302,6 +327,26 @@ void WorldLevel::ProcessImGui() {
|
||||
ImGui::End();
|
||||
m_Player.ProcessImGui();
|
||||
}
|
||||
|
||||
if(m_ShowGameManagerInfo) {
|
||||
ImGui::Begin("Game Manager", &m_ShowGameManagerInfo, ImGuiWindowFlags_AlwaysAutoResize);
|
||||
ImGui::Text("Fuel: %f", GameManager::GetInstance().GetFuel());
|
||||
ImGui::Text("Hull Integrity: %d", GameManager::GetInstance().GetHullIntegrity());
|
||||
ImGui::Text("Score: %d", GameManager::GetInstance().GetScore());
|
||||
ImGui::Text("Money: %d", GameManager::GetInstance().GetMoney());
|
||||
ImGui::Separator();
|
||||
if(ImGui::Button("Add 1$")) {
|
||||
GameManager::GetInstance().IncreaseMoney(1);
|
||||
}
|
||||
if(ImGui::Button("Add 10$")) {
|
||||
GameManager::GetInstance().IncreaseMoney(10);
|
||||
}
|
||||
ImGui::SameLine();
|
||||
if(ImGui::Button("Add 100$")) {
|
||||
GameManager::GetInstance().IncreaseMoney(100);
|
||||
}
|
||||
ImGui::End();
|
||||
}
|
||||
}
|
||||
WorldGridManager& WorldLevel::GetGridManager() {
|
||||
return m_GridManager;
|
||||
|
||||
Reference in New Issue
Block a user