[Examples] Fix typecast warnings in examples. (#1601)
* Fixing typecast warnings generated by visual studio 2019 in examples. * Changes to fixes based on feedback Co-authored-by: Jeffery Myers <JefMyers@blizzard.com>
This commit is contained in:
parent
82cdd88ffe
commit
48a7cd3c87
@ -43,9 +43,9 @@ int main(void)
|
||||
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
||||
{
|
||||
circles[i].alpha = 0.0f;
|
||||
circles[i].radius = GetRandomValue(10, 40);
|
||||
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
||||
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
||||
circles[i].radius = (float)GetRandomValue(10, 40);
|
||||
circles[i].position.x = (float)GetRandomValue((int)circles[i].radius, (int)(screenWidth - circles[i].radius));
|
||||
circles[i].position.y = (float)GetRandomValue((int)circles[i].radius, (int)(screenHeight - circles[i].radius));
|
||||
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
||||
}
|
||||
@ -104,9 +104,9 @@ int main(void)
|
||||
if (circles[i].alpha <= 0.0f)
|
||||
{
|
||||
circles[i].alpha = 0.0f;
|
||||
circles[i].radius = GetRandomValue(10, 40);
|
||||
circles[i].position.x = GetRandomValue(circles[i].radius, screenWidth - circles[i].radius);
|
||||
circles[i].position.y = GetRandomValue(circles[i].radius, screenHeight - circles[i].radius);
|
||||
circles[i].radius = (float)GetRandomValue(10, 40);
|
||||
circles[i].position.x = (float)GetRandomValue((int)circles[i].radius, (int)(screenWidth - circles[i].radius));
|
||||
circles[i].position.y = (float)GetRandomValue((int)circles[i].radius, (int)(screenHeight - circles[i].radius));
|
||||
circles[i].color = colors[GetRandomValue(0, 13)];
|
||||
circles[i].speed = (float)GetRandomValue(1, 100)/2000.0f;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ int main(void)
|
||||
Sound fxWav = LoadSound("resources/sound.wav"); // Load WAV audio file
|
||||
Sound fxOgg = LoadSound("resources/target.ogg"); // Load OGG audio file
|
||||
|
||||
SetSoundVolume(fxWav, 0.2);
|
||||
SetSoundVolume(fxWav, 0.2f);
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
@ -140,8 +140,8 @@ int main(void)
|
||||
// Draw the current buffer state proportionate to the screen
|
||||
for (int i = 0; i < screenWidth; i++)
|
||||
{
|
||||
position.x = i;
|
||||
position.y = 250 + 50*data[i*MAX_SAMPLES/screenWidth]/32000;
|
||||
position.x = (float)i;
|
||||
position.y = 250 + 50*data[i*MAX_SAMPLES/screenWidth]/32000.0f;
|
||||
|
||||
DrawPixelV(position, RED);
|
||||
}
|
||||
|
@ -30,19 +30,19 @@ int main(void)
|
||||
|
||||
for (int i = 0; i < MAX_BUILDINGS; i++)
|
||||
{
|
||||
buildings[i].width = GetRandomValue(50, 200);
|
||||
buildings[i].height = GetRandomValue(100, 800);
|
||||
buildings[i].y = screenHeight - 130 - buildings[i].height;
|
||||
buildings[i].x = -6000 + spacing;
|
||||
buildings[i].width = (float)GetRandomValue(50, 200);
|
||||
buildings[i].height = (float)GetRandomValue(100, 800);
|
||||
buildings[i].y = screenHeight - 130.0f - buildings[i].height;
|
||||
buildings[i].x = -6000.0f + spacing;
|
||||
|
||||
spacing += buildings[i].width;
|
||||
spacing += (int)buildings[i].width;
|
||||
|
||||
buildColors[i] = (Color){ GetRandomValue(200, 240), GetRandomValue(200, 240), GetRandomValue(200, 250), 255 };
|
||||
}
|
||||
|
||||
Camera2D camera = { 0 };
|
||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||
camera.offset = (Vector2){ screenWidth/2, screenHeight/2 };
|
||||
camera.target = (Vector2){ player.x + 20.0f, player.y + 20.0f };
|
||||
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
||||
camera.rotation = 0.0f;
|
||||
camera.zoom = 1.0f;
|
||||
|
||||
@ -98,8 +98,8 @@ int main(void)
|
||||
|
||||
DrawRectangleRec(player, RED);
|
||||
|
||||
DrawLine(camera.target.x, -screenHeight*10, camera.target.x, screenHeight*10, GREEN);
|
||||
DrawLine(-screenWidth*10, camera.target.y, screenWidth*10, camera.target.y, GREEN);
|
||||
DrawLine((int)camera.target.x, -screenHeight*10, (int)camera.target.x, screenHeight*10, GREEN);
|
||||
DrawLine(-screenWidth*10, (int)camera.target.y, screenWidth*10, (int)camera.target.y, GREEN);
|
||||
|
||||
EndMode2D();
|
||||
|
||||
|
@ -65,7 +65,7 @@ int main(void)
|
||||
|
||||
Camera2D camera = { 0 };
|
||||
camera.target = player.position;
|
||||
camera.offset = (Vector2){ screenWidth/2, screenHeight/2 };
|
||||
camera.offset = (Vector2){ screenWidth/2.0f, screenHeight/2.0f };
|
||||
camera.rotation = 0.0f;
|
||||
camera.zoom = 1.0f;
|
||||
|
||||
@ -191,14 +191,14 @@ void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float d
|
||||
|
||||
void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
||||
{
|
||||
camera->offset = (Vector2){ width/2, height/2 };
|
||||
camera->offset = (Vector2){ width/2.0f, height/2.0f };
|
||||
camera->target = player->position;
|
||||
}
|
||||
|
||||
void UpdateCameraCenterInsideMap(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height)
|
||||
{
|
||||
camera->target = player->position;
|
||||
camera->offset = (Vector2){ width/2, height/2 };
|
||||
camera->offset = (Vector2){ width/2.0f, height/2.0f };
|
||||
float minX = 1000, minY = 1000, maxX = -1000, maxY = -1000;
|
||||
|
||||
for (int i = 0; i < envItemsLength; i++)
|
||||
@ -225,7 +225,7 @@ void UpdateCameraCenterSmoothFollow(Camera2D *camera, Player *player, EnvItem *e
|
||||
static float minEffectLength = 10;
|
||||
static float fractionSpeed = 0.8f;
|
||||
|
||||
camera->offset = (Vector2){ width/2, height/2 };
|
||||
camera->offset = (Vector2){ width/2.0f, height/2.0f };
|
||||
Vector2 diff = Vector2Subtract(player->position, camera->target);
|
||||
float length = Vector2Length(diff);
|
||||
|
||||
@ -242,7 +242,7 @@ void UpdateCameraEvenOutOnLanding(Camera2D *camera, Player *player, EnvItem *env
|
||||
static int eveningOut = false;
|
||||
static float evenOutTarget;
|
||||
|
||||
camera->offset = (Vector2){ width/2, height/2 };
|
||||
camera->offset = (Vector2){ width/2.0f, height/2.0f };
|
||||
camera->target.x = player->position.x;
|
||||
|
||||
if (eveningOut)
|
||||
|
@ -38,7 +38,7 @@ int main(void)
|
||||
for (int i = 0; i < MAX_COLUMNS; i++)
|
||||
{
|
||||
heights[i] = (float)GetRandomValue(1, 12);
|
||||
positions[i] = (Vector3){ GetRandomValue(-15, 15), heights[i]/2, GetRandomValue(-15, 15) };
|
||||
positions[i] = (Vector3){ (float)GetRandomValue(-15, 15), heights[i]/2.0f, (float)GetRandomValue(-15, 15) };
|
||||
colors[i] = (Color){ GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255 };
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ int main(void)
|
||||
|
||||
DrawText("Try selecting the box with mouse!", 240, 10, 20, DARKGRAY);
|
||||
|
||||
if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, screenHeight * 0.1f, 30, GREEN);
|
||||
if(collision) DrawText("BOX SELECTED", (screenWidth - MeasureText("BOX SELECTED", 30)) / 2, (int)(screenHeight * 0.1f), 30, GREEN);
|
||||
|
||||
DrawFPS(10, 10);
|
||||
|
||||
|
@ -112,12 +112,12 @@ EASEDEF float EaseSineOut(float t, float b, float c, float d) { return (c*sinf(t
|
||||
EASEDEF float EaseSineInOut(float t, float b, float c, float d) { return (-c/2.0f*(cosf(PI*t/d) - 1.0f) + b); }
|
||||
|
||||
// Circular Easing functions
|
||||
EASEDEF float EaseCircIn(float t, float b, float c, float d) { t /= d; return (-c*(sqrt(1.0f - t*t) - 1.0f) + b); }
|
||||
EASEDEF float EaseCircOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*sqrt(1.0f - t*t) + b); }
|
||||
EASEDEF float EaseCircIn(float t, float b, float c, float d) { t /= d; return (-c*(sqrtf(1.0f - t*t) - 1.0f) + b); }
|
||||
EASEDEF float EaseCircOut(float t, float b, float c, float d) { t = t/d - 1.0f; return (c*sqrtf(1.0f - t*t) + b); }
|
||||
EASEDEF float EaseCircInOut(float t, float b, float c, float d)
|
||||
{
|
||||
if ((t/=d/2.0f) < 1.0f) return (-c/2.0f*(sqrt(1.0f - t*t) - 1.0f) + b);
|
||||
t -= 2.0f; return (c/2.0f*(sqrt(1.0f - t*t) + 1.0f) + b);
|
||||
if ((t/=d/2.0f) < 1.0f) return (-c/2.0f*(sqrtf(1.0f - t*t) - 1.0f) + b);
|
||||
t -= 2.0f; return (c/2.0f*(sqrtf(1.0f - t*t) + 1.0f) + b);
|
||||
}
|
||||
|
||||
// Cubic Easing functions
|
||||
@ -139,15 +139,15 @@ EASEDEF float EaseQuadInOut(float t, float b, float c, float d)
|
||||
}
|
||||
|
||||
// Exponential Easing functions
|
||||
EASEDEF float EaseExpoIn(float t, float b, float c, float d) { return (t == 0.0f) ? b : (c*pow(2.0f, 10.0f*(t/d - 1.0f)) + b); }
|
||||
EASEDEF float EaseExpoOut(float t, float b, float c, float d) { return (t == d) ? (b + c) : (c*(-pow(2.0f, -10.0f*t/d) + 1.0f) + b); }
|
||||
EASEDEF float EaseExpoIn(float t, float b, float c, float d) { return (t == 0.0f) ? b : (c * powf(2.0f, 10.0f*(t/d - 1.0f)) + b); }
|
||||
EASEDEF float EaseExpoOut(float t, float b, float c, float d) { return (t == d) ? (b + c) : (c * (-powf(2.0f, -10.0f*t/d) + 1.0f) + b); }
|
||||
EASEDEF float EaseExpoInOut(float t, float b, float c, float d)
|
||||
{
|
||||
if (t == 0.0f) return b;
|
||||
if (t == d) return (b + c);
|
||||
if ((t/=d/2.0f) < 1.0f) return (c/2.0f*pow(2.0f, 10.0f*(t - 1.0f)) + b);
|
||||
if ((t/=d/2.0f) < 1.0f) return (c/2.0f* powf(2.0f, 10.0f*(t - 1.0f)) + b);
|
||||
|
||||
return (c/2.0f*(-pow(2.0f, -10.0f*(t - 1.0f)) + 2.0f) + b);
|
||||
return (c/2.0f*(-powf(2.0f, -10.0f*(t - 1.0f)) + 2.0f) + b);
|
||||
}
|
||||
|
||||
// Back Easing functions
|
||||
@ -219,7 +219,7 @@ EASEDEF float EaseElasticIn(float t, float b, float c, float d)
|
||||
float p = d*0.3f;
|
||||
float a = c;
|
||||
float s = p/4.0f;
|
||||
float postFix = a*pow(2.0f, 10.0f*(t-=1.0f));
|
||||
float postFix = a*powf(2.0f, 10.0f*(t-=1.0f));
|
||||
|
||||
return (-(postFix*sinf((t*d-s)*(2.0f*PI)/p )) + b);
|
||||
}
|
||||
@ -233,7 +233,7 @@ EASEDEF float EaseElasticOut(float t, float b, float c, float d)
|
||||
float a = c;
|
||||
float s = p/4.0f;
|
||||
|
||||
return (a*pow(2.0f,-10.0f*t)*sinf((t*d-s)*(2.0f*PI)/p) + c + b);
|
||||
return (a*powf(2.0f,-10.0f*t)*sinf((t*d-s)*(2.0f*PI)/p) + c + b);
|
||||
}
|
||||
|
||||
EASEDEF float EaseElasticInOut(float t, float b, float c, float d)
|
||||
@ -247,11 +247,11 @@ EASEDEF float EaseElasticInOut(float t, float b, float c, float d)
|
||||
|
||||
if (t < 1.0f)
|
||||
{
|
||||
float postFix = a*pow(2.0f, 10.0f*(t-=1.0f));
|
||||
float postFix = a*powf(2.0f, 10.0f*(t-=1.0f));
|
||||
return -0.5f*(postFix*sinf((t*d-s)*(2.0f*PI)/p)) + b;
|
||||
}
|
||||
|
||||
float postFix = a*pow(2.0f, -10.0f*(t-=1.0f));
|
||||
float postFix = a*powf(2.0f, -10.0f*(t-=1.0f));
|
||||
|
||||
return (postFix*sinf((t*d-s)*(2.0f*PI)/p)*0.5f + c + b);
|
||||
}
|
||||
|
@ -61,9 +61,12 @@
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
//----------------------------------------------------------------------------------
|
||||
#if !defined(_WIN32)
|
||||
#if !defined(_MSC_VER)
|
||||
static int kbhit(void); // Check if a key has been pressed
|
||||
static char getch(); // Get pressed character
|
||||
#else
|
||||
#define kbhit _kbhit
|
||||
#define getch _getch
|
||||
#endif
|
||||
|
||||
//------------------------------------------------------------------------------------
|
||||
|
@ -57,7 +57,7 @@
|
||||
#define GLFW_INCLUDE_ES2
|
||||
#endif
|
||||
|
||||
#include <GLFW/glfw3.h> // Windows/Context and inputs management
|
||||
#include "GLFW/glfw3.h" // Windows/Context and inputs management
|
||||
|
||||
#include <stdio.h> // Required for: printf()
|
||||
|
||||
@ -246,13 +246,13 @@ static void DrawRectangleV(Vector2 position, Vector2 size, Color color)
|
||||
rlBegin(RL_TRIANGLES);
|
||||
rlColor4ub(color.r, color.g, color.b, color.a);
|
||||
|
||||
rlVertex2i(position.x, position.y);
|
||||
rlVertex2i(position.x, position.y + size.y);
|
||||
rlVertex2i(position.x + size.x, position.y + size.y);
|
||||
rlVertex2f(position.x, position.y);
|
||||
rlVertex2f(position.x, position.y + size.y);
|
||||
rlVertex2f(position.x + size.x, position.y + size.y);
|
||||
|
||||
rlVertex2i(position.x, position.y);
|
||||
rlVertex2i(position.x + size.x, position.y + size.y);
|
||||
rlVertex2i(position.x + size.x, position.y);
|
||||
rlVertex2f(position.x, position.y);
|
||||
rlVertex2f(position.x + size.x, position.y + size.y);
|
||||
rlVertex2f(position.x + size.x, position.y);
|
||||
rlEnd();
|
||||
}
|
||||
|
||||
|
@ -32,8 +32,8 @@ int main(void)
|
||||
Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
|
||||
|
||||
// Draw one image over the other with a scaling of 1.5f
|
||||
ImageDraw(&parrots, cat, (Rectangle){ 0, 0, cat.width, cat.height }, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f }, WHITE);
|
||||
ImageCrop(&parrots, (Rectangle){ 0, 50, parrots.width, parrots.height - 100 }); // Crop resulting image
|
||||
ImageDraw(&parrots, cat, (Rectangle){ 0, 0, (float)cat.width, (float)cat.height }, (Rectangle){ 30, 40, cat.width*1.5f, cat.height*1.5f }, WHITE);
|
||||
ImageCrop(&parrots, (Rectangle){ 0, 50, (float)parrots.width, (float)parrots.height - 100 }); // Crop resulting image
|
||||
|
||||
// Draw on the image with a few image draw methods
|
||||
ImageDrawPixel(&parrots, 10, 10, RAYWHITE);
|
||||
@ -46,7 +46,7 @@ int main(void)
|
||||
Font font = LoadFont("resources/custom_jupiter_crash.png");
|
||||
|
||||
// Draw over image using custom font
|
||||
ImageDrawTextEx(&parrots, font, "PARROTS & CAT", (Vector2){ 300, 230 }, font.baseSize, -2, WHITE);
|
||||
ImageDrawTextEx(&parrots, font, "PARROTS & CAT", (Vector2){ 300, 230 }, (float)font.baseSize, -2, WHITE);
|
||||
|
||||
UnloadFont(font); // Unload custom spritefont (already drawn used on image)
|
||||
|
||||
|
@ -68,7 +68,7 @@ int main(void)
|
||||
|
||||
DrawTexture(scarfy, 15, 40, WHITE);
|
||||
DrawRectangleLines(15, 40, scarfy.width, scarfy.height, LIME);
|
||||
DrawRectangleLines(15 + frameRec.x, 40 + frameRec.y, frameRec.width, frameRec.height, RED);
|
||||
DrawRectangleLines(15 + (int)frameRec.x, 40 + (int)frameRec.y, (int)frameRec.width, (int)frameRec.height, RED);
|
||||
|
||||
DrawText("FRAME SPEED: ", 165, 210, 10, DARKGRAY);
|
||||
DrawText(TextFormat("%02i FPS", framesSpeed), 575, 210, 10, DARKGRAY);
|
||||
|
@ -28,13 +28,13 @@ int main(void)
|
||||
int frameHeight = scarfy.height;
|
||||
|
||||
// Source rectangle (part of the texture to use for drawing)
|
||||
Rectangle sourceRec = { 0.0f, 0.0f, frameWidth, frameHeight };
|
||||
Rectangle sourceRec = { 0.0f, 0.0f, (float)frameWidth, (float)frameHeight };
|
||||
|
||||
// Destination rectangle (screen rectangle where drawing part of texture)
|
||||
Rectangle destRec = { screenWidth/2, screenHeight/2, frameWidth*2, frameHeight*2 };
|
||||
Rectangle destRec = { screenWidth/2.0f, screenHeight/2.0f, frameWidth*2.0f, frameHeight*2.0f };
|
||||
|
||||
// Origin of the texture (rotation/scale point), it's relative to destination rectangle size
|
||||
Vector2 origin = { frameWidth, frameHeight };
|
||||
Vector2 origin = { (float)frameWidth, (float)frameHeight };
|
||||
|
||||
int rotation = 0;
|
||||
|
||||
|
@ -75,7 +75,7 @@
|
||||
// Defines and Macros
|
||||
//----------------------------------------------------------------------------------
|
||||
#ifndef PI
|
||||
#define PI 3.14159265358979323846
|
||||
#define PI 3.14159265358979323846f
|
||||
#endif
|
||||
|
||||
#ifndef DEG2RAD
|
||||
|
@ -4922,7 +4922,7 @@ char *LoadFileText(const char *fileName)
|
||||
if (size > 0)
|
||||
{
|
||||
text = (char *)RL_MALLOC((size + 1)*sizeof(char));
|
||||
int count = fread(text, sizeof(char), size, textFile);
|
||||
int count = (int)fread(text, sizeof(char), size, textFile);
|
||||
|
||||
// WARNING: \r\n is converted to \n on reading, so,
|
||||
// read bytes count gets reduced by the number of lines
|
||||
|
Loading…
Reference in New Issue
Block a user