diff options
| author | raysan5 <raysan5@gmail.com> | 2016-01-13 19:30:35 +0100 |
|---|---|---|
| committer | raysan5 <raysan5@gmail.com> | 2016-01-13 19:30:35 +0100 |
| commit | 3b4d8442e049f969c737722cb72f1c8ad66621a7 (patch) | |
| tree | d4edeedce48c0d8cf5edeb8b5c9f8152ef9b47fc /src/core.c | |
| parent | 4f0165f32dc3f04cd58c013743e51384b7b932ab (diff) | |
| download | raylib-3b4d8442e049f969c737722cb72f1c8ad66621a7.tar.gz raylib-3b4d8442e049f969c737722cb72f1c8ad66621a7.zip | |
Corrected some float values
Diffstat (limited to 'src/core.c')
| -rw-r--r-- | src/core.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -309,8 +309,8 @@ void InitWindow(int width, int height, const char *title) emscripten_set_touchcancel_callback("#canvas", NULL, 1, EmscriptenInputCallback); #endif - mousePosition.x = screenWidth/2; - mousePosition.y = screenHeight/2; + mousePosition.x = (float)screenWidth/2.0f; + mousePosition.y = (float)screenHeight/2.0f; // raylib logo appearing animation (if enabled) if (showLogo) @@ -577,7 +577,7 @@ void Begin3dMode(Camera camera) // Setup perspective projection float aspect = (float)screenWidth/(float)screenHeight; - double top = 0.1f*tan(45.0f*PI / 360.0f); + double top = 0.1f*tan(45.0f*PI/360.0f); double right = top*aspect; // NOTE: zNear and zFar values are important when computing depth buffer values @@ -608,7 +608,7 @@ void End3dMode(void) // Set target FPS for the game void SetTargetFPS(int fps) { - targetTime = 1 / (double)fps; + targetTime = 1.0/(double)fps; TraceLog(INFO, "Target time per frame: %02.03f milliseconds", (float)targetTime*1000); } @@ -625,7 +625,7 @@ float GetFrameTime(void) // As we are operate quite a lot with frameTime, // it could be no stable, so we round it before passing it around // NOTE: There are still problems with high framerates (>500fps) - double roundedFrameTime = round(frameTime*10000)/10000; + double roundedFrameTime = round(frameTime*10000)/10000.0; return (float)roundedFrameTime; // Time in seconds to run a frame } @@ -806,8 +806,8 @@ Ray GetMouseRay(Vector2 mousePosition, Camera camera) // Calculate normalized device coordinates // NOTE: y value is negative - float x = (2.0f * mousePosition.x) / GetScreenWidth() - 1.0f; - float y = 1.0f - (2.0f * mousePosition.y) / GetScreenHeight(); + float x = (2.0f*mousePosition.x)/(float)GetScreenWidth() - 1.0f; + float y = 1.0f - (2.0f*mousePosition.y)/(float)GetScreenHeight(); float z = 1.0f; // Store values in a vector @@ -880,7 +880,7 @@ Vector2 WorldToScreen(Vector3 position, Camera camera) Vector3 ndcPos = { worldPos.x / worldPos.w, -worldPos.y / worldPos.w, worldPos.z / worldPos.z }; // Calculate 2d screen position vector - Vector2 screenPosition = { (ndcPos.x + 1.0f) / 2.0f * GetScreenWidth(), (ndcPos.y + 1.0f) / 2.0f * GetScreenHeight() }; + Vector2 screenPosition = { (ndcPos.x + 1.0f)/2.0f*(float)GetScreenWidth(), (ndcPos.y + 1.0f)/2.0f*(float)GetScreenHeight() }; return screenPosition; } |
