add drop test

This commit is contained in:
MihailRis
2024-06-24 15:39:40 +03:00
parent 69ddcb7595
commit 4b20487c58
6 changed files with 21 additions and 10 deletions
+12 -8
View File
@@ -18,14 +18,17 @@ void Transform::refresh() {
}
Entities::Entities(Level* level) : level(level) {
for (int i = 0; i < 1000; i++) {
auto entity = registry.create();
glm::vec3 pos(0.5f+rand()%50, 100+i, 0.5f+rand()%50);
glm::vec3 size(1);
registry.emplace<EntityId>(entity, 1);
registry.emplace<Transform>(entity, pos, size/4.0f, glm::mat3(1.0f));
registry.emplace<Hitbox>(entity, pos, size/2.0f);
}
}
void Entities::drop(glm::vec3 pos, glm::vec3 vel) {
auto entity = registry.create();
glm::vec3 size(1);
registry.emplace<EntityId>(entity, 1);
registry.emplace<Transform>(entity, pos, size/4.0f, glm::mat3(1.0f));
registry.emplace<Hitbox>(entity, pos, size/2.0f);
auto& hitbox = registry.get<Hitbox>(entity);
hitbox.velocity = vel;
}
void Entities::updatePhysics(float delta){
@@ -41,6 +44,7 @@ void Entities::updatePhysics(float delta){
1.0f,
true
);
hitbox.linear_damping = hitbox.grounded * 5;
transform.pos = hitbox.position;
transform.rot = glm::rotate(glm::mat4(transform.rot), delta, glm::vec3(0, 1, 0));
if (hitbox.grounded) {