|
@@ -34,10 +34,10 @@ class RenderGUISystem : public System
|
|
|
public:
|
|
|
RenderGUISystem() = default;
|
|
|
|
|
|
- void update(const std::unique_ptr<Registry> ®istry)
|
|
|
+ void update(const std::unique_ptr<Registry> ®istry, SDL_Rect &camera)
|
|
|
{
|
|
|
ImGui::NewFrame();
|
|
|
-
|
|
|
+ ImGuiWindowFlags windowFlags;
|
|
|
if (ImGui::Begin("Spawn enemies"))
|
|
|
{
|
|
|
/* Main properties */
|
|
@@ -53,53 +53,66 @@ public:
|
|
|
static int projectileSpeed = 100;
|
|
|
double projectileXVelocity, projectileYVelocity;
|
|
|
|
|
|
- if (ImGui::CollapsingHeader("Main properties"))
|
|
|
+ // Sprite selection
|
|
|
+ if (ImGui::CollapsingHeader("Sprite"))
|
|
|
+ {
|
|
|
+ ImGui::Combo("combo", &spriteSelection, spriteList, IM_ARRAYSIZE(spriteList));
|
|
|
+ }
|
|
|
+ ImGui::Spacing();
|
|
|
+
|
|
|
+ if (ImGui::CollapsingHeader("Transform"))
|
|
|
{
|
|
|
ImGui::InputInt("X position", &enemyXPos);
|
|
|
ImGui::InputInt("Y position", &enemyYPos);
|
|
|
ImGui::SliderFloat("Scale", &enemyScale, 0.5, 10);
|
|
|
ImGui::SliderAngle("Rotation", &enemyRotation, 0, 360);
|
|
|
}
|
|
|
+ ImGui::Spacing();
|
|
|
|
|
|
- if (ImGui::CollapsingHeader("Velocity"))
|
|
|
+ if (ImGui::CollapsingHeader("Rigid Body"))
|
|
|
{
|
|
|
ImGui::InputInt("X Velocity", &enemyXVelocity);
|
|
|
ImGui::InputInt("Y Velocity", &enemyYVelocity);
|
|
|
}
|
|
|
+ ImGui::Spacing();
|
|
|
|
|
|
// default Health
|
|
|
- ImGui::SliderInt("Starting health", &enemyHealth, 1, 100);
|
|
|
-
|
|
|
- // Sprite selection
|
|
|
- ImGui::Combo("combo", &spriteSelection, spriteList, IM_ARRAYSIZE(spriteList));
|
|
|
+ if (ImGui::CollapsingHeader("Health"))
|
|
|
+ {
|
|
|
+ ImGui::SliderInt("Starting health", &enemyHealth, 1, 100);
|
|
|
+ }
|
|
|
+ ImGui::Spacing();
|
|
|
|
|
|
- if (ImGui::CollapsingHeader("Projectile"))
|
|
|
+ if (ImGui::CollapsingHeader("Projectile Emitter"))
|
|
|
{
|
|
|
// Angle/Speed of projectiles
|
|
|
ImGui::SliderAngle("Angle", &projectileAngle, 0, 360);
|
|
|
- ImGui::InputInt("Speed", &projectileSpeed);
|
|
|
+ ImGui::SliderInt("Speed", &projectileSpeed, 10, 500);
|
|
|
// Frequency / duration of projectives (seconds)
|
|
|
ImGui::InputFloat("Frequency (sec)", &projectileFrequency);
|
|
|
ImGui::InputFloat("Duration (sec)", &projectileDuration);
|
|
|
}
|
|
|
-
|
|
|
- projectileXVelocity = cos(projectileAngle) * (double)projectileSpeed;
|
|
|
- projectileYVelocity = sin(projectileAngle) * (double)projectileSpeed;
|
|
|
+ ImGui::Spacing();
|
|
|
+ ImGui::Separator();
|
|
|
+ ImGui::Spacing();
|
|
|
|
|
|
if (ImGui::Button("Spawn"))
|
|
|
{
|
|
|
+ projectileXVelocity = cos(projectileAngle) * (double)projectileSpeed;
|
|
|
+ projectileYVelocity = sin(projectileAngle) * (double)projectileSpeed;
|
|
|
+
|
|
|
Logger::Warning("proj X Vel ==> %f", projectileXVelocity);
|
|
|
Logger::Warning("proj Y Vel ==> %f", projectileYVelocity);
|
|
|
|
|
|
Entity newEnemy = registry->createEntity();
|
|
|
newEnemy.addComponent<TransformComponent>(glm::vec2(enemyXPos, enemyYPos),
|
|
|
glm::vec2(enemyScale, enemyScale),
|
|
|
- enemyRotation * 180 / M_PI);
|
|
|
+ glm::degrees(enemyRotation));
|
|
|
|
|
|
newEnemy.addComponent<RigidBodyComponent>(glm::vec2(enemyXVelocity, enemyYVelocity));
|
|
|
|
|
|
newEnemy.addComponent<SpriteComponent>(spriteList[spriteSelection], 2, 32, 32);
|
|
|
- newEnemy.addComponent<BoxColliderComponent>(18, 18, glm::vec2(5, 7));
|
|
|
+ newEnemy.addComponent<BoxColliderComponent>(25, 20, glm::vec2(5, 5));
|
|
|
|
|
|
newEnemy.addComponent<ProjectileEmitterComponent>(glm::vec2(projectileXVelocity, projectileYVelocity),
|
|
|
projectileFrequency * 1000,
|
|
@@ -112,6 +125,20 @@ public:
|
|
|
}
|
|
|
ImGui::End();
|
|
|
|
|
|
+ /* Mouse overlay */
|
|
|
+ windowFlags = ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove;
|
|
|
+ ImGui::SetNextWindowPos(ImVec2(10, 10), ImGuiCond_Always, ImVec2(0, 0));
|
|
|
+ ImGui::SetNextWindowBgAlpha(0.9f);
|
|
|
+ if (ImGui::Begin("Mouse coordinates", NULL, windowFlags))
|
|
|
+ {
|
|
|
+ ImGui::Text("Map Coordinates: x=%.1f, y=%.1f",
|
|
|
+ ImGui::GetIO().MousePos.x + camera.x,
|
|
|
+ ImGui::GetIO().MousePos.y + camera.y);
|
|
|
+ }
|
|
|
+ ImGui::End();
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
ImGui::Render();
|
|
|
ImGuiSDL::Render(ImGui::GetDrawData());
|
|
|
}
|