|
@@ -10,6 +10,8 @@
|
|
|
#ifndef IMGUI_SOURCE_INCLUDE_SYSTEMS_RENDERGUI_H
|
|
|
#define IMGUI_SOURCE_INCLUDE_SYSTEMS_RENDERGUI_H
|
|
|
|
|
|
+#include <math.h>
|
|
|
+
|
|
|
#include <SDL.h>
|
|
|
#include <glm/glm.hpp>
|
|
|
|
|
@@ -38,20 +40,73 @@ public:
|
|
|
|
|
|
if (ImGui::Begin("Spawn enemies"))
|
|
|
{
|
|
|
- static int xPos = 0, yPos = 0;
|
|
|
+ /* Main properties */
|
|
|
+ static int enemyXPos = 0, enemyYPos = 0, enemyHealth = 100;
|
|
|
+ static int enemyXVelocity = 0, enemyYVelocity = 0;
|
|
|
+ static float enemyScale = 1, enemyRotation = 0;
|
|
|
+
|
|
|
+ const char* spriteList[] = { "truck-image", "tank-image" };
|
|
|
+ static int spriteSelection = 0;
|
|
|
+
|
|
|
+ /* Projectile */
|
|
|
+ static float projectileAngle = 0, projectileDuration = 5, projectileFrequency = 3;
|
|
|
+ static int projectileSpeed = 100;
|
|
|
+ double projectileXVelocity, projectileYVelocity;
|
|
|
+
|
|
|
+ if (ImGui::CollapsingHeader("Main properties"))
|
|
|
+ {
|
|
|
+ ImGui::InputInt("X position", &enemyXPos);
|
|
|
+ ImGui::InputInt("Y position", &enemyYPos);
|
|
|
+ ImGui::SliderFloat("Scale", &enemyScale, 0.5, 10);
|
|
|
+ ImGui::SliderAngle("Rotation", &enemyRotation, 0, 360);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ImGui::CollapsingHeader("Velocity"))
|
|
|
+ {
|
|
|
+ ImGui::InputInt("X Velocity", &enemyXVelocity);
|
|
|
+ ImGui::InputInt("Y Velocity", &enemyYVelocity);
|
|
|
+ }
|
|
|
|
|
|
- ImGui::InputInt("Enemy X position", &xPos);
|
|
|
- ImGui::InputInt("Enemy Y position", &yPos);
|
|
|
+ // default Health
|
|
|
+ ImGui::SliderInt("Starting health", &enemyHealth, 1, 100);
|
|
|
+
|
|
|
+ // Sprite selection
|
|
|
+ ImGui::Combo("combo", &spriteSelection, spriteList, IM_ARRAYSIZE(spriteList));
|
|
|
+
|
|
|
+ if (ImGui::CollapsingHeader("Projectile"))
|
|
|
+ {
|
|
|
+ // Angle/Speed of projectiles
|
|
|
+ ImGui::SliderAngle("Angle", &projectileAngle, 0, 360);
|
|
|
+ ImGui::InputInt("Speed", &projectileSpeed);
|
|
|
+ // 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;
|
|
|
|
|
|
if (ImGui::Button("Spawn"))
|
|
|
{
|
|
|
+ Logger::Warning("proj X Vel ==> %f", projectileXVelocity);
|
|
|
+ Logger::Warning("proj Y Vel ==> %f", projectileYVelocity);
|
|
|
+
|
|
|
Entity newEnemy = registry->createEntity();
|
|
|
- newEnemy.addComponent<TransformComponent>(glm::vec2(xPos, yPos), glm::vec2(1, 1), 0);
|
|
|
- newEnemy.addComponent<RigidBodyComponent>(glm::vec2(0, 0));
|
|
|
- newEnemy.addComponent<SpriteComponent>("tank-image", 2, 32, 32);
|
|
|
+ newEnemy.addComponent<TransformComponent>(glm::vec2(enemyXPos, enemyYPos),
|
|
|
+ glm::vec2(enemyScale, enemyScale),
|
|
|
+ enemyRotation * 180 / M_PI);
|
|
|
+
|
|
|
+ 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<ProjectileEmitterComponent>(glm::vec2(100, 0), 3000, 5000, 10, false);
|
|
|
- newEnemy.addComponent<HealthComponent>(100);
|
|
|
+
|
|
|
+ newEnemy.addComponent<ProjectileEmitterComponent>(glm::vec2(projectileXVelocity, projectileYVelocity),
|
|
|
+ projectileFrequency * 1000,
|
|
|
+ projectileDuration * 1000,
|
|
|
+ 10,
|
|
|
+ false);
|
|
|
+ newEnemy.addComponent<HealthComponent>(enemyHealth);
|
|
|
newEnemy.group("enemies");
|
|
|
}
|
|
|
}
|