From 43e31b6e124da754ef928d22fbb9a1d7640aab4b Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Thu, 20 Jul 2023 03:08:57 -0600 Subject: New bullet system --- src/entities/antifaShip.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'src/entities/antifaShip.c') diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c index 2d58510..1b90ea7 100644 --- a/src/entities/antifaShip.c +++ b/src/entities/antifaShip.c @@ -44,19 +44,15 @@ void controlAntifaShipJoystick(Game * game, Entity * entity) { // Shoot button. if (IsGamepadButtonPressed(gamePadNum, 8)) { - Vector3 dir = Vector3Normalize(Vector3Subtract( - getEntityFromWorld(game->world, 1)->position, - entity->position - )); - - Bullet bullet = createBullet( - *entity, - dir, - Vector3Zero(), - 0.1 - ); - - addBullet(&game->bullets, bullet); + Bullet bullet = createBulletFromEntity(*entity, 1.0); + BulletHitInfo info = shootBullet(&game->world, bullet); + + if (info.hit) { + Entity * hitEntity = getEntityFromWorld(game->world, info.hitId); + printVector3(hitEntity->position); + } else { + puts("no stink"); + } } Vector3 stick = (Vector3){ -- cgit v1.2.3