diff --git a/examples/others/raymath_vector_angle.c b/examples/others/raymath_vector_angle.c index d0f81548c..8236c0190 100644 --- a/examples/others/raymath_vector_angle.c +++ b/examples/others/raymath_vector_angle.c @@ -10,10 +10,9 @@ * Copyright (c) 2023 Ramon Santamaria (@raysan5) * ********************************************************************************************/ - -#include "raylib.h" #include "raymath.h" +#include "raylib.h" //------------------------------------------------------------------------------------ // Program main entry point @@ -30,7 +29,7 @@ int main(void) Vector2 v0 = { screenWidth/2, screenHeight/2 }; Vector2 v1 = Vector2Add(v0, (Vector2){ 100.0f, 80.0f }); Vector2 v2 = { 0 }; // Updated with mouse position - + float angle = 0.0f; // Angle in degrees int angleMode = 0; // 0-Vector2Angle(), 1-Vector2LineAngle() @@ -45,12 +44,12 @@ int main(void) float startangle = 0.0f; if (angleMode == 0) startangle = -Vector2LineAngle(v0, v1)*RAD2DEG; - if (angleMode == 1) startangle = 0.0f; + if (angleMode == 1) startangle = 0.0f; v2 = GetMousePosition(); if (IsKeyPressed(KEY_SPACE)) angleMode = !angleMode; - + if(angleMode == 0 && IsMouseButtonDown(MOUSE_BUTTON_RIGHT)) v1 = GetMousePosition(); if (angleMode == 0) @@ -73,12 +72,12 @@ int main(void) BeginDrawing(); ClearBackground(RAYWHITE); - + if (angleMode == 0) { DrawText("MODE 0: Angle between V1 and V2", 10, 10, 20, BLACK); DrawText("Right Click to Move V2", 10, 30, 20, DARKGRAY); - + DrawLineEx(v0, v1, 2.0f, BLACK); DrawLineEx(v0, v2, 2.0f, RED); @@ -87,13 +86,13 @@ int main(void) else if (angleMode == 1) { DrawText("MODE 1: Angle formed by line V1 to V2", 10, 10, 20, BLACK); - + DrawLine(0, screenHeight/2, screenWidth, screenHeight/2, LIGHTGRAY); DrawLineEx(v0, v2, 2.0f, RED); DrawCircleSector(v0, 40.0f, startangle, startangle - angle, 32, Fade(GREEN, 0.6f)); } - + DrawText("v0", v0.x, v0.y, 10, DARKGRAY); // If the line from v0 to v1 would overlap the text, move it's position up 10 @@ -108,7 +107,7 @@ int main(void) DrawText("Press SPACE to change MODE", 460, 10, 20, DARKGRAY); DrawText(TextFormat("ANGLE: %2.2f", angle), 10, 70, 20, LIME); - + EndDrawing(); //---------------------------------------------------------------------------------- } diff --git a/src/raylib.h b/src/raylib.h index 035f6f2bf..87fa4e206 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -158,11 +158,13 @@ // this defines are very useful for internal check and avoid type (re)definitions #define RL_COLOR_TYPE #define RL_RECTANGLE_TYPE +#ifndef RAYMATH_H #define RL_VECTOR2_TYPE #define RL_VECTOR3_TYPE #define RL_VECTOR4_TYPE #define RL_QUATERNION_TYPE #define RL_MATRIX_TYPE +#endif // RAYMATH_H // Some Basic Colors // NOTE: Custom raylib color palette for amazing visuals on WHITE background @@ -205,6 +207,7 @@ #define RL_BOOL_TYPE #endif +#ifndef RAYMATH_H // Vector2, 2 components typedef struct Vector2 { float x; // Vector x component @@ -236,6 +239,7 @@ typedef struct Matrix { float m2, m6, m10, m14; // Matrix third row (4 components) float m3, m7, m11, m15; // Matrix fourth row (4 components) } Matrix; +#endif // RAYMATH_H // Color, 4 components, R8G8B8A8 (32bit) typedef struct Color {