diff options
author | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-18 05:54:30 -0600 |
---|---|---|
committer | nathansmithsmith <thenathansmithsmith@gmail.com> | 2023-07-18 05:54:30 -0600 |
commit | f3f5fedbf591c10fa675a32103bab9480b42abe8 (patch) | |
tree | 54b46a23279cc45091393762c0d01b9c3637b729 /src/entities/antifaShip.c | |
parent | 77a06748f9f394486cad833e2ca351e8dbcc7361 (diff) |
Bullet system added
Diffstat (limited to 'src/entities/antifaShip.c')
-rw-r--r-- | src/entities/antifaShip.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/entities/antifaShip.c b/src/entities/antifaShip.c index c2e292a..2d58510 100644 --- a/src/entities/antifaShip.c +++ b/src/entities/antifaShip.c @@ -1,8 +1,7 @@ #include "antifaShip.h" #include "game.h" #include "settings.h" - -// TODO: Get rid of some magic numbers. +#include "bullets.h" void initAntifaShip(Entity * entity, Game * game) { entity->model = &game->assets.models[ANTIFA_SHIP_ASSET]; @@ -43,6 +42,23 @@ void controlAntifaShipJoystick(Game * game, Entity * entity) { float rollStick = GetGamepadAxisMovement(gamePadNum, settings.rollStick); float speedStick = GetGamepadAxisMovement(gamePadNum, settings.speedStick); + // 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); + } + Vector3 stick = (Vector3){ pitchStick, -yawStick, |