horizontal collision works
Some checks failed
Build Project / build (push) Failing after 10m39s

This commit is contained in:
swim67667
2026-06-24 11:46:32 -04:00
parent c29f652cdc
commit c079ca620f
2 changed files with 30 additions and 18 deletions

View File

@@ -12,6 +12,17 @@ void checkCollision(){
Entity *en2 = &entities[j]; Entity *en2 = &entities[j];
if (fabsf(en1->position.x - en2->position.x) < (en1->size * 0.5f + en2->size * 0.5f)) if (fabsf(en1->position.x - en2->position.x) < (en1->size * 0.5f + en2->size * 0.5f))
{ {
if(en1->position.x < en2->position.x){
ApplyForce(
en1,
(Vector2){-10000, 0}
);
ApplyForce(
en2,
(Vector2){10000, 0}
);
}
else{
ApplyForce( ApplyForce(
en1, en1,
(Vector2){10000, 0} (Vector2){10000, 0}
@@ -21,16 +32,17 @@ void checkCollision(){
(Vector2){-10000, 0} (Vector2){-10000, 0}
); );
} }
if(fabsf(en1->position.y - en2->position.y) < (en1->size * 0.5f + en2->size * 0.5f)){
ApplyForce(
en1,
(Vector2){0, 10000}
);
ApplyForce(
en2,
(Vector2){0, -10000}
);
} }
// if(fabsf(en1->position.y - en2->position.y) < (en1->size * 0.5f + en2->size * 0.5f)){
// ApplyForce(
// en1,
// (Vector2){0, 10000}
// );
// ApplyForce(
// en2,
// (Vector2){0, -10000}
// );
// }
} }
} }
} }

Binary file not shown.