From 0387c05d7d4b784b91ea35b88caa12c4fc9fd6d3 Mon Sep 17 00:00:00 2001 From: nathansmithsmith Date: Mon, 18 Sep 2023 22:00:27 -0600 Subject: Added crossy thingy to gyro --- src/gameScreen.c | 31 ++++++++++++++++++++++++------- src/gameScreen.h | 2 +- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/gameScreen.c b/src/gameScreen.c index 86b6a51..7849af3 100644 --- a/src/gameScreen.c +++ b/src/gameScreen.c @@ -25,7 +25,7 @@ void initGameScreen(GameScreen * gameScreen) { gameScreen->gyroscopeCamaera = (Camera3D){ .fovy = 45, .projection = CAMERA_PERSPECTIVE, - .position = (Vector3){0.0, 0.0, -5.0}, + .position = (Vector3){0.0, 0.0, -3.0}, .target = Vector3Zero(), .up = (Vector3){0.0, 1.0, 0.0} }; @@ -68,27 +68,44 @@ void drawCrossHair(float size, float thick, Color color) { void drawGyroscope(Game * game) { GameScreen * gameScreen = &game->gameScreen; Entity * player = getEntityFromWorld(game->world, 0); + Vector2 gyroscopePosition = gameScreen->gyroscopePosition; // Draw this mother fucker. BeginTextureMode(gameScreen->gyroscopeTexture); ClearBackground(BLACK); BeginMode3D(gameScreen->gyroscopeCamaera); - //DrawSphereWires(Vector3Zero(), 1.0, 8, 8, GREEN); - + // Set transform and draw. gameScreen->gyroscopeModel.transform = QuaternionToMatrix(QuaternionInvert(player->rotation)); - - DrawModelWires(gameScreen->gyroscopeModel, Vector3Zero(), 1, GREEN); + DrawModelWires(gameScreen->gyroscopeModel, Vector3Zero(), 1, BLUE); EndMode3D(); EndTextureMode(); + // Draw render texture. DrawTexture( gameScreen->gyroscopeTexture.texture, - gameScreen->gyroscopePosition.x, - gameScreen->gyroscopePosition.y, + gyroscopePosition.x, + gyroscopePosition.y, WHITE ); + + // Top to bottom. + DrawLine( + gyroscopePosition.x + (GYROSCOPE_TEXTURE_SIZE / 2.0), + gyroscopePosition.y, + gyroscopePosition.x + (GYROSCOPE_TEXTURE_SIZE / 2.0), + gyroscopePosition.y + GYROSCOPE_TEXTURE_SIZE, + RED + ); + + DrawLine( + gyroscopePosition.x, + gyroscopePosition.y + (GYROSCOPE_TEXTURE_SIZE / 2.0), + gyroscopePosition.x + GYROSCOPE_TEXTURE_SIZE, + gyroscopePosition.y + (GYROSCOPE_TEXTURE_SIZE / 2.0), + RED + ); } void drawGameScreenGui(Game * game) { diff --git a/src/gameScreen.h b/src/gameScreen.h index 84d589b..c0169c6 100644 --- a/src/gameScreen.h +++ b/src/gameScreen.h @@ -4,7 +4,7 @@ #define GAME_SCREEN_H #define GAME_SCREEN_TEXT_SIZE 20.0 -#define GYROSCOPE_TEXTURE_SIZE 100 +#define GYROSCOPE_TEXTURE_SIZE 80 // Gui stuff and shit. typedef struct GameScreen { -- cgit v1.2.3