Fixed spacing and added more consistency with sinf() and cosf()

This commit is contained in:
Gianni Alessandroni 2021-05-10 19:49:00 +02:00
parent 1a79ffd766
commit 58c1c88e51

View File

@ -25,7 +25,7 @@ int main(void)
const int virualScreenWidth = 160;
const int virtualScreenHeight = 90;
const float virtualRatio = (float)screenWidth / (float)virualScreenWidth;
const float virtualRatio = (float)screenWidth/(float)virualScreenWidth;
InitWindow(screenWidth, screenHeight, "raylib [core] example - smooth pixel-perfect camera");
@ -43,7 +43,7 @@ int main(void)
//The renderTexture's height is flipped (in the source Rectangle), due to OpenGL reasons.
Rectangle renderTextureSource = { 0.0f, 0.0f, (float)renderTexture.texture.width, (float)-renderTexture.texture.height };
Rectangle renderTextureDest = { -virtualRatio, -virtualRatio, screenWidth + (virtualRatio * 2), screenHeight + (virtualRatio * 2) };
Rectangle renderTextureDest = { -virtualRatio, -virtualRatio, screenWidth + (virtualRatio*2), screenHeight + (virtualRatio*2) };
Vector2 origin = { 0.0f, 0.0f };
@ -61,11 +61,11 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
rotation += degreesPerSecond * GetFrameTime(); // Rotate the rectangles.
rotation += degreesPerSecond*GetFrameTime(); // Rotate the rectangles.
// Make the camera move to demonstrate the effect.
cameraX = (sin(GetTime()) * 50.0f) - 10.0f;
cameraY = cos(GetTime()) * 30.0f;
cameraX = (sinf(GetTime())*50.0f) - 10.0f;
cameraY = cosf(GetTime())*30.0f;
// Set the camera's target to the values computed above.
screenSpaceCamera.target = (Vector2){ cameraX, cameraY };
@ -75,7 +75,7 @@ int main(void)
{
worldSpaceCamera.target.x = (int)screenSpaceCamera.target.x;
screenSpaceCamera.target.x -= worldSpaceCamera.target.x;
screenSpaceCamera.target.x *= virtualRatio;
screenSpaceCamera.target.x*=virtualRatio;
}
// Round worldCamera's Y, keep the decimals on screenSpaceCamera.
@ -83,7 +83,7 @@ int main(void)
{
worldSpaceCamera.target.y = (int)screenSpaceCamera.target.y;
screenSpaceCamera.target.y -= worldSpaceCamera.target.y;
screenSpaceCamera.target.y *= virtualRatio;
screenSpaceCamera.target.y*=virtualRatio;
}
//----------------------------------------------------------------------------------