diff options
| author | Thomas Guillermo Albers Raviola <thomas@thomaslabs.org> | 2026-01-16 19:38:33 +0100 |
|---|---|---|
| committer | Thomas Guillermo Albers Raviola <thomas@thomaslabs.org> | 2026-01-16 19:38:33 +0100 |
| commit | a90db3b7b6e87e24c789b5db222f1cef92809bde (patch) | |
| tree | 2096abcb1ac1ea970a51e598257186bc4e030b22 /progress/src/bulletCollision.c | |
Initial commit
Diffstat (limited to 'progress/src/bulletCollision.c')
| -rw-r--r-- | progress/src/bulletCollision.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/progress/src/bulletCollision.c b/progress/src/bulletCollision.c new file mode 100644 index 0000000..d6c52c5 --- /dev/null +++ b/progress/src/bulletCollision.c @@ -0,0 +1,31 @@ +#include "main.h" + +void bulletCollision(GameState *gameState) +{ + int p1_x = gameState->player1.x, p1_y = gameState->player1.y; + int p1_w = gameState->player1.w, p1_h = gameState->player1.h; + + int p2_x = gameState->player2.x, p2_y = gameState->player2.y; + int p2_w = gameState->player2.w, p2_h = gameState->player2.h; + + for(int i = 0; i < MAX_BULLETS; i++) if(gameState->bala_1[i]) + { + if(gameState->bala_1[i]->x > p1_x && gameState->bala_1[i]->x < p1_x + p1_w + && gameState->bala_1[i]->y > p1_y && gameState->bala_1[i]->y < p1_y + p1_h && gameState->bala_1[i]->owner == 2) + { + if(gameState->player1.muerto == 1){} + else + printf("player1 muerto\n"); + gameState->player1.muerto = 1; + } + else if(gameState->bala_1[i]->x > p2_x && gameState->bala_1[i]->x < p2_x + p2_w + && gameState->bala_1[i]->y > p2_y && gameState->bala_1[i]->y < p2_y + p2_h && gameState->bala_1[i]->owner == 1) + { + if(gameState->player2.muerto == 1){} + else + printf("player2 muerto\n"); + gameState->player2.muerto = 1; + + } + } +} |
