diff options
author | nathansmithsmith <nathansmith7@mailfence.com> | 2023-10-27 15:00:19 -0600 |
---|---|---|
committer | nathansmithsmith <nathansmith7@mailfence.com> | 2023-10-27 15:00:19 -0600 |
commit | 4a5bdb90ffdbd9974f86df14893e7287f2faa933 (patch) | |
tree | ecebe433777c400de51fbd7cb424cf0a37fad10f /src/gameScreen.c | |
parent | df05d6f688422930e8efc4a73df435e497f3776a (diff) |
Better targeting
Diffstat (limited to 'src/gameScreen.c')
-rw-r--r-- | src/gameScreen.c | 81 |
1 files changed, 69 insertions, 12 deletions
diff --git a/src/gameScreen.c b/src/gameScreen.c index b956059..70ea351 100644 --- a/src/gameScreen.c +++ b/src/gameScreen.c @@ -3,13 +3,19 @@ #include "world.h" #include "bullets.h" #include "assets.h" +#include "entitiesInclude.h" void initGameScreenGui(GameScreen * gameScreen) { float width = GetScreenWidth(); float height = GetScreenHeight(); // It is kind of terrible but works. - gameScreen->infoText = (Vector2){0.0, height / 1.5}; + gameScreen->infoTextPosition = (Vector2){0.0, height / 1.5}; + + gameScreen->targetInfoPosition = (Vector2){ + width - (GAME_SCREEN_TEXT_SIZE * (GAME_SCREEN_TARGET_INFO_MAX / 2.0)), + height / 3.0 + }; // Gyroscope indeed initGyroscope(&gameScreen->gyroscope); @@ -50,21 +56,16 @@ void drawCrossHair(float size, float thick, Color color) { ); } -void drawGameScreenGui(Game * game) { - GameScreen * gameScreen = &game->gameScreen; +void drawGameScreenInfoText(Game * game, GameScreen * gameScreen) { Entity * player = getEntityFromWorld(game->world, 0); + Vector3 position = player->position; + Vector3 velocity = player->velocity.velocity; + // Hello reader. I fucking hate you! size_t bufSize = 255; char buf[bufSize]; - // Draw cross hair. - if (gameScreen->mainCamera == FIRST_PERSON_CAMERA) - drawCrossHair(10.0, 2.0, BLUE); - - Vector3 position = player->position; - Vector3 velocity = player->velocity.velocity; - // Format text. snprintf( buf, @@ -80,12 +81,68 @@ void drawGameScreenGui(Game * game) { // Draw info text. DrawText( buf, - gameScreen->infoText.x, - gameScreen->infoText.y, + gameScreen->infoTextPosition.x, + gameScreen->infoTextPosition.y, + GAME_SCREEN_TEXT_SIZE, + GREEN + ); +} + +void drawGameScreenTargetInfo(Game * game, GameScreen * gameScreen) { + Entity * player = getEntityFromWorld(game->world, 0); + AntifaShip * data = (AntifaShip*)player->data; + + size_t bufSize = 255; + char buf[bufSize]; + + // Format. + snprintf( + buf, + bufSize, + "Auto: %s", + data->doAutoTarget ? "On" : "Off" + ); + + // Is auto targeting. + if (data->doAutoTarget) { + Entity * targetedEntity = getEntityFromWorld(game->world, data->targetedEntityId); + + if (targetedEntity != NULL) { + char bufCopy[bufSize]; + strncpy(bufCopy, buf, bufSize); + + // Add more formatted text. + snprintf( + buf, + bufSize, + "%s\nId: %d@%x\nDistance: %.2f\n", + bufCopy, + data->targetedEntityId, + data->targetedEntityFingerprint, + Vector3Distance(player->position, targetedEntity->position) + ); + } + } + + // Draw. + DrawText( + buf, + gameScreen->targetInfoPosition.x, + gameScreen->targetInfoPosition.y, GAME_SCREEN_TEXT_SIZE, GREEN ); +} + +void drawGameScreenGui(Game * game) { + GameScreen * gameScreen = &game->gameScreen; + + // Draw cross hair. + if (gameScreen->mainCamera == FIRST_PERSON_CAMERA) + drawCrossHair(10.0, 2.0, BLUE); + drawGameScreenInfoText(game, gameScreen); + drawGameScreenTargetInfo(game, gameScreen); drawGyroscope(game, &gameScreen->gyroscope); drawRadar(game, &gameScreen->radar); } |