mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-25 10:22:33 -05:00
[examples] Fix examples to work in MSVC (#5267)
* Fix warnings in many examples Add examples to MSVC solution correctly * fix CI error --------- Co-authored-by: Ray <raysan5@gmail.com>
This commit is contained in:
@ -60,7 +60,7 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
UpdateCamera(&camera, CAMERA_FREE);
|
||||
|
||||
float th = GetTime();
|
||||
float th = (float)GetTime();
|
||||
|
||||
Vector3 spherePos = {
|
||||
.x = 5.0f*cosf(th),
|
||||
|
||||
@ -198,8 +198,8 @@ void UpdateBody(Body *body, float rot, char side, char forward, bool jumpPressed
|
||||
//PlaySound(fxJump);
|
||||
}
|
||||
|
||||
Vector3 front = (Vector3){ sin(rot), 0.f, cos(rot) };
|
||||
Vector3 right = (Vector3){ cos(-rot), 0.f, sin(-rot) };
|
||||
Vector3 front = (Vector3){ sinf(rot), 0.f, cosf(rot) };
|
||||
Vector3 right = (Vector3){ cosf(-rot), 0.f, sinf(-rot) };
|
||||
|
||||
Vector3 desiredDir = (Vector3){ input.x*right.x + input.y*front.x, 0.0f, input.x*right.z + input.y*front.z, };
|
||||
body->dir = Vector3Lerp(body->dir, desiredDir, CONTROL*delta);
|
||||
@ -267,8 +267,8 @@ static void UpdateCameraFPS(Camera *camera)
|
||||
|
||||
// Head animation
|
||||
// Rotate up direction around forward axis
|
||||
float headSin = sin(headTimer*PI);
|
||||
float headCos = cos(headTimer*PI);
|
||||
float headSin = sinf(headTimer*PI);
|
||||
float headCos = cosf(headTimer*PI);
|
||||
const float stepRotation = 0.01f;
|
||||
camera->up = Vector3RotateByAxisAngle(up, pitch, headSin*stepRotation + lean.x);
|
||||
|
||||
|
||||
@ -177,33 +177,33 @@ int main(void)
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// Draw common elements
|
||||
DrawText("*", messagePosition.x + 5, messagePosition.y + 5, 10, BLACK);
|
||||
DrawText("Example optimized for Web/HTML5\non Smartphones with Touch Screen.", messagePosition.x + 15, messagePosition.y + 5, 10, BLACK);
|
||||
DrawText("*", messagePosition.x + 5, messagePosition.y + 35, 10, BLACK);
|
||||
DrawText("While running on Desktop Web Browsers,\ninspect and turn on Touch Emulation.", messagePosition.x + 15, messagePosition.y + 35, 10, BLACK);
|
||||
DrawText("*", (int)messagePosition.x + 5, (int)messagePosition.y + 5, 10, BLACK);
|
||||
DrawText("Example optimized for Web/HTML5\non Smartphones with Touch Screen.", (int)messagePosition.x + 15, (int)messagePosition.y + 5, 10, BLACK);
|
||||
DrawText("*", (int)messagePosition.x + 5, (int)messagePosition.y + 35, 10, BLACK);
|
||||
DrawText("While running on Desktop Web Browsers,\ninspect and turn on Touch Emulation.", (int)messagePosition.x + 15, (int)messagePosition.y + 35, 10, BLACK);
|
||||
|
||||
// Draw last gesture
|
||||
DrawText("Last gesture", lastGesturePosition.x + 33, lastGesturePosition.y - 47, 20, BLACK);
|
||||
DrawText("Swipe Tap Pinch Touch", lastGesturePosition.x + 17, lastGesturePosition.y - 18, 10, BLACK);
|
||||
DrawRectangle(lastGesturePosition.x + 20, lastGesturePosition.y, 20, 20, lastGesture == GESTURE_SWIPE_UP ? RED : LIGHTGRAY);
|
||||
DrawRectangle(lastGesturePosition.x, lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_LEFT ? RED : LIGHTGRAY);
|
||||
DrawRectangle(lastGesturePosition.x + 40, lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_RIGHT ? RED : LIGHTGRAY);
|
||||
DrawRectangle(lastGesturePosition.x + 20, lastGesturePosition.y + 40, 20, 20, lastGesture == GESTURE_SWIPE_DOWN ? RED : LIGHTGRAY);
|
||||
DrawCircle(lastGesturePosition.x + 80, lastGesturePosition.y + 16, 10, lastGesture == GESTURE_TAP ? BLUE : LIGHTGRAY);
|
||||
DrawText("Last gesture", (int)lastGesturePosition.x + 33, (int)lastGesturePosition.y - 47, 20, BLACK);
|
||||
DrawText("Swipe Tap Pinch Touch", (int)lastGesturePosition.x + 17, (int)lastGesturePosition.y - 18, 10, BLACK);
|
||||
DrawRectangle((int)lastGesturePosition.x + 20, (int)lastGesturePosition.y, 20, 20, lastGesture == GESTURE_SWIPE_UP ? RED : LIGHTGRAY);
|
||||
DrawRectangle((int)lastGesturePosition.x, (int)lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_LEFT ? RED : LIGHTGRAY);
|
||||
DrawRectangle((int)lastGesturePosition.x + 40, (int)lastGesturePosition.y + 20, 20, 20, lastGesture == GESTURE_SWIPE_RIGHT ? RED : LIGHTGRAY);
|
||||
DrawRectangle((int)lastGesturePosition.x + 20, (int)lastGesturePosition.y + 40, 20, 20, lastGesture == GESTURE_SWIPE_DOWN ? RED : LIGHTGRAY);
|
||||
DrawCircle((int)lastGesturePosition.x + 80, (int)lastGesturePosition.y + 16, 10, lastGesture == GESTURE_TAP ? BLUE : LIGHTGRAY);
|
||||
DrawRing( (Vector2){lastGesturePosition.x + 103, lastGesturePosition.y + 16}, 6.0f, 11.0f, 0.0f, 360.0f, 0, lastGesture == GESTURE_DRAG ? LIME : LIGHTGRAY);
|
||||
DrawCircle(lastGesturePosition.x + 80, lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
|
||||
DrawCircle(lastGesturePosition.x + 103, lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
|
||||
DrawTriangle((Vector2){ lastGesturePosition.x + 122, lastGesturePosition.y + 16 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 26 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 6 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
|
||||
DrawCircle((int)lastGesturePosition.x + 80, (int)lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
|
||||
DrawCircle((int)lastGesturePosition.x + 103, (int)lastGesturePosition.y + 43, 10, lastGesture == GESTURE_DOUBLETAP ? SKYBLUE : LIGHTGRAY);
|
||||
DrawTriangle((Vector2){ lastGesturePosition.x + 122, lastGesturePosition.y + 16 }, (Vector2){ lastGesturePosition.x + 137, lastGesturePosition.y + 26 }, (Vector2){lastGesturePosition.x + 137, lastGesturePosition.y + 6 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
|
||||
DrawTriangle((Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 6 }, (Vector2){ lastGesturePosition.x + 147, lastGesturePosition.y + 26 }, (Vector2){ lastGesturePosition.x + 162, lastGesturePosition.y + 16 }, lastGesture == GESTURE_PINCH_OUT? ORANGE : LIGHTGRAY);
|
||||
DrawTriangle((Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 33 }, (Vector2){ lastGesturePosition.x + 125, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 140, lastGesturePosition.y + 43 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
|
||||
DrawTriangle((Vector2){ lastGesturePosition.x + 144, lastGesturePosition.y + 43 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 53 }, (Vector2){ lastGesturePosition.x + 159, lastGesturePosition.y + 33 }, lastGesture == GESTURE_PINCH_IN? VIOLET : LIGHTGRAY);
|
||||
for (i = 0; i < 4; i++) DrawCircle(lastGesturePosition.x + 180, lastGesturePosition.y + 7 + i*15, 5, touchCount <= i? LIGHTGRAY : gestureColor);
|
||||
for (i = 0; i < 4; i++) DrawCircle((int)lastGesturePosition.x + 180, (int)lastGesturePosition.y + 7 + i*15, 5, touchCount <= i? LIGHTGRAY : gestureColor);
|
||||
|
||||
// Draw gesture log
|
||||
DrawText("Log", gestureLogPosition.x, gestureLogPosition.y, 20, BLACK);
|
||||
DrawText("Log", (int)gestureLogPosition.x, (int)gestureLogPosition.y, 20, BLACK);
|
||||
|
||||
// Loop in both directions to print the gesture log array in the inverted order (and looping around if the index started somewhere in the middle)
|
||||
for (i = 0, ii = gestureLogIndex; i < GESTURE_LOG_SIZE; i++, ii = (ii + 1) % GESTURE_LOG_SIZE) DrawText(gestureLog[ii], gestureLogPosition.x, gestureLogPosition.y + 410 - i*20, 20, (i == 0 ? gestureColor : LIGHTGRAY));
|
||||
for (i = 0, ii = gestureLogIndex; i < GESTURE_LOG_SIZE; i++, ii = (ii + 1) % GESTURE_LOG_SIZE) DrawText(gestureLog[ii], (int)gestureLogPosition.x, (int)gestureLogPosition.y + 410 - i*20, 20, (i == 0 ? gestureColor : LIGHTGRAY));
|
||||
Color logButton1Color, logButton2Color;
|
||||
switch (logMode)
|
||||
{
|
||||
@ -213,31 +213,31 @@ int main(void)
|
||||
default: logButton1Color=GRAY; logButton2Color=GRAY; break;
|
||||
}
|
||||
DrawRectangleRec(logButton1, logButton1Color);
|
||||
DrawText("Hide", logButton1.x + 7, logButton1.y + 3, 10, WHITE);
|
||||
DrawText("Repeat", logButton1.x + 7, logButton1.y + 13, 10, WHITE);
|
||||
DrawText("Hide", (int)logButton1.x + 7, (int)logButton1.y + 3, 10, WHITE);
|
||||
DrawText("Repeat", (int)logButton1.x + 7, (int)logButton1.y + 13, 10, WHITE);
|
||||
DrawRectangleRec(logButton2, logButton2Color);
|
||||
DrawText("Hide", logButton1.x + 62, logButton1.y + 3, 10, WHITE);
|
||||
DrawText("Hold", logButton1.x + 62, logButton1.y + 13, 10, WHITE);
|
||||
DrawText("Hide", (int)logButton1.x + 62, (int)logButton1.y + 3, 10, WHITE);
|
||||
DrawText("Hold", (int)logButton1.x + 62, (int)logButton1.y + 13, 10, WHITE);
|
||||
|
||||
// Draw protractor
|
||||
DrawText("Angle", protractorPosition.x + 55, protractorPosition.y + 76, 10, BLACK);
|
||||
DrawText("Angle", (int)protractorPosition.x + 55, (int)protractorPosition.y + 76, 10, BLACK);
|
||||
const char *angleString = TextFormat("%f", currentAngleDegrees);
|
||||
const int angleStringDot = TextFindIndex(angleString, ".");
|
||||
const char *angleStringTrim = TextSubtext(angleString, 0, angleStringDot + 3);
|
||||
DrawText( angleStringTrim, protractorPosition.x + 55, protractorPosition.y + 92, 20, gestureColor);
|
||||
DrawCircle(protractorPosition.x, protractorPosition.y, 80.0f, WHITE);
|
||||
DrawText( angleStringTrim, (int)protractorPosition.x + 55, (int)protractorPosition.y + 92, 20, gestureColor);
|
||||
DrawCircleV(protractorPosition, 80.0f, WHITE);
|
||||
DrawLineEx((Vector2){ protractorPosition.x - 90, protractorPosition.y }, (Vector2){ protractorPosition.x + 90, protractorPosition.y }, 3.0f, LIGHTGRAY);
|
||||
DrawLineEx((Vector2){ protractorPosition.x, protractorPosition.y - 90 }, (Vector2){ protractorPosition.x, protractorPosition.y + 90 }, 3.0f, LIGHTGRAY);
|
||||
DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y - 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y + 45 }, 3.0f, GREEN);
|
||||
DrawLineEx((Vector2){ protractorPosition.x - 80, protractorPosition.y + 45 }, (Vector2){ protractorPosition.x + 80, protractorPosition.y - 45 }, 3.0f, GREEN);
|
||||
DrawText("0", protractorPosition.x + 96, protractorPosition.y - 9, 20, BLACK);
|
||||
DrawText("30", protractorPosition.x + 74, protractorPosition.y - 68, 20, BLACK);
|
||||
DrawText("90", protractorPosition.x - 11, protractorPosition.y - 110, 20, BLACK);
|
||||
DrawText("150", protractorPosition.x - 100, protractorPosition.y - 68, 20, BLACK);
|
||||
DrawText("180", protractorPosition.x - 124, protractorPosition.y - 9, 20, BLACK);
|
||||
DrawText("210", protractorPosition.x - 100, protractorPosition.y + 50, 20, BLACK);
|
||||
DrawText("270", protractorPosition.x - 18, protractorPosition.y + 92, 20, BLACK);
|
||||
DrawText("330", protractorPosition.x + 72, protractorPosition.y + 50, 20, BLACK);
|
||||
DrawText("0", (int)protractorPosition.x + 96, (int)protractorPosition.y - 9, 20, BLACK);
|
||||
DrawText("30", (int)protractorPosition.x + 74, (int)protractorPosition.y - 68, 20, BLACK);
|
||||
DrawText("90", (int)protractorPosition.x - 11, (int)protractorPosition.y - 110, 20, BLACK);
|
||||
DrawText("150", (int)protractorPosition.x - 100, (int)protractorPosition.y - 68, 20, BLACK);
|
||||
DrawText("180", (int)protractorPosition.x - 124, (int)protractorPosition.y - 9, 20, BLACK);
|
||||
DrawText("210", (int)protractorPosition.x - 100, (int)protractorPosition.y + 50, 20, BLACK);
|
||||
DrawText("270", (int)protractorPosition.x - 18, (int)protractorPosition.y + 92, 20, BLACK);
|
||||
DrawText("330", (int)protractorPosition.x + 72, (int)protractorPosition.y + 50, 20, BLACK);
|
||||
if (currentAngleDegrees != 0.0f) DrawLineEx(protractorPosition, finalVector, 3.0f, gestureColor);
|
||||
|
||||
// Draw touch and mouse pointer points
|
||||
@ -251,7 +251,7 @@ int main(void)
|
||||
DrawCircleV(touchPosition[i], 5.0f, gestureColor);
|
||||
}
|
||||
|
||||
if (touchCount == 2) DrawLineEx(touchPosition[0], touchPosition[1], ((currentGesture == 512)? 8 : 12), gestureColor);
|
||||
if (touchCount == 2) DrawLineEx(touchPosition[0], touchPosition[1], ((currentGesture == 512)? 8.0f : 12.0f), gestureColor);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -22,7 +22,7 @@
|
||||
// Monitor Details
|
||||
typedef struct Monitor {
|
||||
Vector2 position;
|
||||
char *name;
|
||||
const char *name;
|
||||
int width;
|
||||
int height;
|
||||
int physicalWidth;
|
||||
@ -76,10 +76,10 @@ int main(void)
|
||||
GetMonitorPhysicalHeight(i),
|
||||
GetMonitorRefreshRate(i)
|
||||
};
|
||||
if (monitors[i].position.x < monitorOffsetX) monitorOffsetX = monitors[i].position.x*-1;
|
||||
if (monitors[i].position.x < monitorOffsetX) monitorOffsetX = (int)monitors[i].position.x*-1;
|
||||
|
||||
const int width = monitors[i].position.x + monitors[i].width;
|
||||
const int height = monitors[i].position.y + monitors[i].height;
|
||||
const int width = (int)monitors[i].position.x + monitors[i].width;
|
||||
const int height = (int)monitors[i].position.y + monitors[i].height;
|
||||
|
||||
if (maxWidth < width) maxWidth = width;
|
||||
if (maxHeight < height) maxHeight = height;
|
||||
@ -99,9 +99,8 @@ int main(void)
|
||||
// Get currentMonitorIndex if manually moved
|
||||
currentMonitorIndex = GetCurrentMonitor();
|
||||
}
|
||||
const Monitor currentMonitor = monitors[currentMonitorIndex];
|
||||
|
||||
float monitorScale = 0.6;
|
||||
float monitorScale = 0.6f;
|
||||
|
||||
if(maxHeight > maxWidth + monitorOffsetX) monitorScale *= ((float)screenHeight/(float)maxHeight);
|
||||
else monitorScale *= ((float)screenWidth/(float)(maxWidth + monitorOffsetX));
|
||||
@ -128,7 +127,7 @@ int main(void)
|
||||
};
|
||||
|
||||
// Draw monitor name and information inside the rectangle
|
||||
DrawText(TextFormat("[%i] %s", i, monitors[i].name), rec.x + 10, rec.y + (int)(100*monitorScale), (int)(120*monitorScale), BLUE);
|
||||
DrawText(TextFormat("[%i] %s", i, monitors[i].name), (int)rec.x + 10, (int)rec.y + (int)(100*monitorScale), (int)(120*monitorScale), BLUE);
|
||||
DrawText(
|
||||
TextFormat("Resolution: [%ipx x %ipx]\nRefreshRate: [%ihz]\nPhysical Size: [%imm x %imm]\nPosition: %3.0f x %3.0f",
|
||||
monitors[i].width,
|
||||
@ -138,7 +137,7 @@ int main(void)
|
||||
monitors[i].physicalHeight,
|
||||
monitors[i].position.x,
|
||||
monitors[i].position.y
|
||||
), rec.x + 10, rec.y + (int)(200*monitorScale), (int)(120*monitorScale), DARKGRAY);
|
||||
), (int)rec.x + 10, (int)rec.y + (int)(200*monitorScale), (int)(120*monitorScale), DARKGRAY);
|
||||
|
||||
// Highlight current monitor
|
||||
if (i == currentMonitorIndex)
|
||||
|
||||
@ -79,9 +79,9 @@ int main(void)
|
||||
// NOTE 1: We set the origin of the texture to the center of the render texture
|
||||
// NOTE 2: We flip vertically the texture setting negative source rectangle height
|
||||
DrawTexturePro(target.texture,
|
||||
(Rectangle){ 0, 0, target.texture.width, -target.texture.height },
|
||||
(Rectangle){ screenWidth/2, screenHeight/2, target.texture.width, target.texture.height },
|
||||
(Vector2){ target.texture.width/2, target.texture.height/2 }, rotation, WHITE);
|
||||
(Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height },
|
||||
(Rectangle){ screenWidth/2.0f, screenHeight/2.0f, (float)target.texture.width, (float)target.texture.height },
|
||||
(Vector2){ target.texture.width/2.0f, target.texture.height/2.0f }, rotation, WHITE);
|
||||
|
||||
DrawText("DRAWING BOUNCING BALL INSIDE RENDER TEXTURE!", 10, screenHeight - 40, 20, BLACK);
|
||||
|
||||
|
||||
@ -187,42 +187,42 @@ int main(void)
|
||||
if (lastUndoIndex > firstUndoIndex)
|
||||
{
|
||||
for (int i = firstUndoIndex; i < currentUndoIndex; i++)
|
||||
DrawRectangle(gridPosition.x + states[i].cell.x*GRID_CELL_SIZE, gridPosition.y + states[i].cell.y*GRID_CELL_SIZE,
|
||||
GRID_CELL_SIZE, GRID_CELL_SIZE, LIGHTGRAY);
|
||||
DrawRectangleRec((Rectangle){gridPosition.x + states[i].cell.x * GRID_CELL_SIZE, gridPosition.y + states[i].cell.y * GRID_CELL_SIZE,
|
||||
GRID_CELL_SIZE, GRID_CELL_SIZE }, LIGHTGRAY);
|
||||
}
|
||||
else if (firstUndoIndex > lastUndoIndex)
|
||||
{
|
||||
if ((currentUndoIndex < MAX_UNDO_STATES) && (currentUndoIndex > lastUndoIndex))
|
||||
{
|
||||
for (int i = firstUndoIndex; i < currentUndoIndex; i++)
|
||||
DrawRectangle(gridPosition.x + states[i].cell.x*GRID_CELL_SIZE, gridPosition.y + states[i].cell.y*GRID_CELL_SIZE,
|
||||
GRID_CELL_SIZE, GRID_CELL_SIZE, LIGHTGRAY);
|
||||
DrawRectangleRec((Rectangle) { gridPosition.x + states[i].cell.x * GRID_CELL_SIZE, gridPosition.y + states[i].cell.y * GRID_CELL_SIZE,
|
||||
GRID_CELL_SIZE, GRID_CELL_SIZE }, LIGHTGRAY);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = firstUndoIndex; i < MAX_UNDO_STATES; i++)
|
||||
DrawRectangle(gridPosition.x + states[i].cell.x*GRID_CELL_SIZE, gridPosition.y + states[i].cell.y*GRID_CELL_SIZE,
|
||||
DrawRectangle((int)gridPosition.x + states[i].cell.x*GRID_CELL_SIZE, (int)gridPosition.y + states[i].cell.y*GRID_CELL_SIZE,
|
||||
GRID_CELL_SIZE, GRID_CELL_SIZE, LIGHTGRAY);
|
||||
for (int i = 0; i < currentUndoIndex; i++)
|
||||
DrawRectangle(gridPosition.x + states[i].cell.x*GRID_CELL_SIZE, gridPosition.y + states[i].cell.y*GRID_CELL_SIZE,
|
||||
DrawRectangle((int)gridPosition.x + states[i].cell.x*GRID_CELL_SIZE, (int)gridPosition.y + states[i].cell.y*GRID_CELL_SIZE,
|
||||
GRID_CELL_SIZE, GRID_CELL_SIZE, LIGHTGRAY);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw game grid
|
||||
for (int y = 0; y <= MAX_GRID_CELLS_Y; y++)
|
||||
DrawLine(gridPosition.x, gridPosition.y + y*GRID_CELL_SIZE,
|
||||
gridPosition.x + MAX_GRID_CELLS_X*GRID_CELL_SIZE, gridPosition.y + y*GRID_CELL_SIZE, GRAY);
|
||||
DrawLine((int)gridPosition.x, (int)gridPosition.y + y*GRID_CELL_SIZE,
|
||||
(int)gridPosition.x + MAX_GRID_CELLS_X*GRID_CELL_SIZE, (int)gridPosition.y + y*GRID_CELL_SIZE, GRAY);
|
||||
for (int x = 0; x <= MAX_GRID_CELLS_X; x++)
|
||||
DrawLine(gridPosition.x + x*GRID_CELL_SIZE, gridPosition.y,
|
||||
gridPosition.x + x*GRID_CELL_SIZE, gridPosition.y + MAX_GRID_CELLS_Y*GRID_CELL_SIZE, GRAY);
|
||||
DrawLine((int)gridPosition.x + x*GRID_CELL_SIZE, (int)gridPosition.y,
|
||||
(int)gridPosition.x + x*GRID_CELL_SIZE, (int)gridPosition.y + MAX_GRID_CELLS_Y*GRID_CELL_SIZE, GRAY);
|
||||
|
||||
// Draw player
|
||||
DrawRectangle(gridPosition.x + player.cell.x*GRID_CELL_SIZE, gridPosition.y + player.cell.y*GRID_CELL_SIZE,
|
||||
DrawRectangle((int)gridPosition.x + player.cell.x*GRID_CELL_SIZE, (int)gridPosition.y + player.cell.y*GRID_CELL_SIZE,
|
||||
GRID_CELL_SIZE + 1, GRID_CELL_SIZE + 1, player.color);
|
||||
|
||||
// Draw undo system buffer info
|
||||
DrawText("UNDO STATES:", undoInfoPos.x - 85, undoInfoPos.y + 9, 10, DARKGRAY);
|
||||
DrawText("UNDO STATES:", (int)undoInfoPos.x - 85, (int)undoInfoPos.y + 9, 10, DARKGRAY);
|
||||
DrawUndoBuffer(undoInfoPos, firstUndoIndex, lastUndoIndex, currentUndoIndex, 24);
|
||||
|
||||
EndDrawing();
|
||||
@ -247,15 +247,15 @@ int main(void)
|
||||
static void DrawUndoBuffer(Vector2 position, int firstUndoIndex, int lastUndoIndex, int currentUndoIndex, int slotSize)
|
||||
{
|
||||
// Draw index marks
|
||||
DrawRectangle(position.x + 8 + slotSize*currentUndoIndex, position.y - 10, 8, 8, RED);
|
||||
DrawRectangleLines(position.x + 2 + slotSize*firstUndoIndex, position.y + 27, 8, 8, BLACK);
|
||||
DrawRectangle(position.x + 14 + slotSize*lastUndoIndex, position.y + 27, 8, 8, BLACK);
|
||||
DrawRectangle((int)position.x + 8 + slotSize*currentUndoIndex, (int)position.y - 10, 8, 8, RED);
|
||||
DrawRectangleLines((int)position.x + 2 + slotSize*firstUndoIndex, (int)position.y + 27, 8, 8, BLACK);
|
||||
DrawRectangle((int)position.x + 14 + slotSize*lastUndoIndex, (int)position.y + 27, 8, 8, BLACK);
|
||||
|
||||
// Draw background gray slots
|
||||
for (int i = 0; i < MAX_UNDO_STATES; i++)
|
||||
{
|
||||
DrawRectangle(position.x + slotSize*i, position.y, slotSize, slotSize, LIGHTGRAY);
|
||||
DrawRectangleLines(position.x + slotSize*i, position.y, slotSize, slotSize, GRAY);
|
||||
DrawRectangle((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, LIGHTGRAY);
|
||||
DrawRectangleLines((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, GRAY);
|
||||
}
|
||||
|
||||
// Draw occupied slots: firstUndoIndex --> lastUndoIndex
|
||||
@ -263,22 +263,22 @@ static void DrawUndoBuffer(Vector2 position, int firstUndoIndex, int lastUndoInd
|
||||
{
|
||||
for (int i = firstUndoIndex; i < lastUndoIndex + 1; i++)
|
||||
{
|
||||
DrawRectangle(position.x + slotSize*i, position.y, slotSize, slotSize, SKYBLUE);
|
||||
DrawRectangleLines(position.x + slotSize*i, position.y, slotSize, slotSize, BLUE);
|
||||
DrawRectangle((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, SKYBLUE);
|
||||
DrawRectangleLines((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, BLUE);
|
||||
}
|
||||
}
|
||||
else if (lastUndoIndex < firstUndoIndex)
|
||||
{
|
||||
for (int i = firstUndoIndex; i < MAX_UNDO_STATES; i++)
|
||||
{
|
||||
DrawRectangle(position.x + slotSize*i, position.y, slotSize, slotSize, SKYBLUE);
|
||||
DrawRectangleLines(position.x + slotSize*i, position.y, slotSize, slotSize, BLUE);
|
||||
DrawRectangle((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, SKYBLUE);
|
||||
DrawRectangleLines((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, BLUE);
|
||||
}
|
||||
|
||||
for (int i = 0; i < lastUndoIndex + 1; i++)
|
||||
{
|
||||
DrawRectangle(position.x + slotSize*i, position.y, slotSize, slotSize, SKYBLUE);
|
||||
DrawRectangleLines(position.x + slotSize*i, position.y, slotSize, slotSize, BLUE);
|
||||
DrawRectangle((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, SKYBLUE);
|
||||
DrawRectangleLines((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, BLUE);
|
||||
}
|
||||
}
|
||||
|
||||
@ -287,26 +287,26 @@ static void DrawUndoBuffer(Vector2 position, int firstUndoIndex, int lastUndoInd
|
||||
{
|
||||
for (int i = firstUndoIndex; i < currentUndoIndex; i++)
|
||||
{
|
||||
DrawRectangle(position.x + slotSize*i, position.y, slotSize, slotSize, GREEN);
|
||||
DrawRectangleLines(position.x + slotSize*i, position.y, slotSize, slotSize, LIME);
|
||||
DrawRectangle((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, GREEN);
|
||||
DrawRectangleLines((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, LIME);
|
||||
}
|
||||
}
|
||||
else if (currentUndoIndex < firstUndoIndex)
|
||||
{
|
||||
for (int i = firstUndoIndex; i < MAX_UNDO_STATES; i++)
|
||||
{
|
||||
DrawRectangle(position.x + slotSize*i, position.y, slotSize, slotSize, GREEN);
|
||||
DrawRectangleLines(position.x + slotSize*i, position.y, slotSize, slotSize, LIME);
|
||||
DrawRectangle((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, GREEN);
|
||||
DrawRectangleLines((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, LIME);
|
||||
}
|
||||
|
||||
for (int i = 0; i < currentUndoIndex; i++)
|
||||
{
|
||||
DrawRectangle(position.x + slotSize*i, position.y, slotSize, slotSize, GREEN);
|
||||
DrawRectangleLines(position.x + slotSize*i, position.y, slotSize, slotSize, LIME);
|
||||
DrawRectangle((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, GREEN);
|
||||
DrawRectangleLines((int)position.x + slotSize*i, (int)position.y, slotSize, slotSize, LIME);
|
||||
}
|
||||
}
|
||||
|
||||
// Draw current selected UNDO slot
|
||||
DrawRectangle(position.x + slotSize*currentUndoIndex, position.y, slotSize, slotSize, GOLD);
|
||||
DrawRectangleLines(position.x + slotSize*currentUndoIndex, position.y, slotSize, slotSize, ORANGE);
|
||||
DrawRectangle((int)position.x + slotSize*currentUndoIndex, (int)position.y, slotSize, slotSize, GOLD);
|
||||
DrawRectangleLines((int)position.x + slotSize*currentUndoIndex, (int)position.y, slotSize, slotSize, ORANGE);
|
||||
}
|
||||
|
||||
@ -88,7 +88,7 @@ int main(void)
|
||||
if (!voxels[x][y][z]) continue; // Skip empty voxels
|
||||
|
||||
// Build a bounding box for this voxel
|
||||
Vector3 position = { x, y, z };
|
||||
Vector3 position = { (float)x, (float)y, (float)z };
|
||||
BoundingBox box = {
|
||||
(Vector3){ position.x - 0.5f, position.y - 0.5f, position.z - 0.5f },
|
||||
(Vector3){ position.x + 0.5f, position.y + 0.5f, position.z + 0.5f }
|
||||
@ -126,7 +126,7 @@ int main(void)
|
||||
{
|
||||
if (!voxels[x][y][z]) continue;
|
||||
|
||||
Vector3 position = { x, y, z };
|
||||
Vector3 position = { (float)x, (float)y, (float)z };
|
||||
DrawModel(cubeModel, position, 1.0f, BEIGE);
|
||||
DrawCubeWires(position, 1.0f, 1.0f, 1.0f, BLACK);
|
||||
}
|
||||
|
||||
@ -40,7 +40,7 @@ int main(void)
|
||||
// Load image to create texture for the cube
|
||||
Model model = LoadModelFromMesh(GenMeshCube(1.0f, 1.0f, 1.0f));
|
||||
Image img = LoadImage("resources/cubicmap_atlas.png");
|
||||
Image crop = ImageFromImage(img, (Rectangle){0, img.height/2, img.width/2, img.height/2});
|
||||
Image crop = ImageFromImage(img, (Rectangle){0, img.height/2.0f, img.width/2.0f, img.height/2.0f});
|
||||
Texture2D texture = LoadTextureFromImage(crop);
|
||||
UnloadImage(img);
|
||||
UnloadImage(crop);
|
||||
|
||||
@ -65,7 +65,7 @@ int main(void)
|
||||
{
|
||||
// Update
|
||||
//----------------------------------------------------------------------------------
|
||||
rotation = DEG2RAD*45.0f*GetTime();
|
||||
rotation = DEG2RAD*45.0f*(float)GetTime();
|
||||
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
|
||||
@ -59,7 +59,7 @@ int main(void)
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [others] example - compute shader");
|
||||
|
||||
const Vector2 resolution = { screenWidth, screenHeight };
|
||||
const Vector2 resolution = { (float)screenWidth, (float)screenHeight };
|
||||
unsigned int brushSize = 8;
|
||||
|
||||
// Game of Life logic compute shader
|
||||
|
||||
@ -252,7 +252,11 @@ int main()
|
||||
// Draw spheres to show the lights positions
|
||||
for (int i = 0; i < MAX_LIGHTS; i++)
|
||||
{
|
||||
Color lightColor = (Color){ lights[i].color[0]*255, lights[i].color[1]*255, lights[i].color[2]*255, lights[i].color[3]*255 };
|
||||
Color lightColor = (Color){
|
||||
(unsigned char)(lights[i].color[0]*255),
|
||||
(unsigned char)(lights[i].color[1] * 255),
|
||||
(unsigned char)(lights[i].color[2] * 255),
|
||||
(unsigned char)(lights[i].color[3] * 255) };
|
||||
|
||||
if (lights[i].enabled) DrawSphereEx(lights[i].position, 0.2f, 8, 8, lightColor);
|
||||
else DrawSphereWires(lights[i].position, 0.2f, 8, 8, ColorAlpha(lightColor, 0.3f));
|
||||
|
||||
@ -102,7 +102,7 @@ int main(void)
|
||||
BeginBlendMode(BLEND_ADDITIVE);
|
||||
DrawTexturePro(
|
||||
light,
|
||||
(Rectangle){ 0, 0, light.width, light.height },
|
||||
(Rectangle){ 0, 0, (float)light.width, (float)light.height },
|
||||
(Rectangle){ 0, 0, 20, 20 },
|
||||
(Vector2){ 10.0, 10.0 },
|
||||
0.0,
|
||||
@ -110,7 +110,7 @@ int main(void)
|
||||
);
|
||||
DrawTexturePro(
|
||||
light,
|
||||
(Rectangle){ 0, 0, light.width, light.height },
|
||||
(Rectangle){ 0, 0, (float)light.width, (float)light.height },
|
||||
(Rectangle){ 8, 4, 20, 20 },
|
||||
(Vector2){ 10.0, 10.0 },
|
||||
0.0,
|
||||
@ -118,7 +118,7 @@ int main(void)
|
||||
);
|
||||
DrawTexturePro(
|
||||
light,
|
||||
(Rectangle){ 0, 0, light.width, light.height },
|
||||
(Rectangle){ 0, 0, (float)light.width, (float)light.height },
|
||||
(Rectangle){ 8, 8, 10, 10 },
|
||||
(Vector2){ 5.0, 5.0 },
|
||||
0.0,
|
||||
@ -152,7 +152,7 @@ int main(void)
|
||||
DrawTexturePro(
|
||||
lightmap.texture,
|
||||
(Rectangle){ 0, 0, -MAP_SIZE, -MAP_SIZE },
|
||||
(Rectangle){ GetRenderWidth() - MAP_SIZE*8 - 10, 10, MAP_SIZE*8, MAP_SIZE*8 },
|
||||
(Rectangle){ (float)GetRenderWidth() - MAP_SIZE*8 - 10, 10, (float)MAP_SIZE*8, (float)MAP_SIZE*8 },
|
||||
(Vector2){ 0.0, 0.0 },
|
||||
0.0,
|
||||
WHITE);
|
||||
|
||||
@ -113,7 +113,7 @@ int main(void)
|
||||
if (IsKeyPressed(KEY_N)) useNormalMap = !useNormalMap;
|
||||
|
||||
// Spin plane model at a constant rate
|
||||
plane.transform = MatrixRotateY(GetTime()*0.5f);
|
||||
plane.transform = MatrixRotateY((float)GetTime()*0.5f);
|
||||
|
||||
// Update shader values
|
||||
float lightPos[3] = {lightPosition.x, lightPosition.y, lightPosition.z};
|
||||
|
||||
@ -68,8 +68,8 @@ int main(void)
|
||||
// Draw circle to bullet texture, then draw bullet using DrawTexture()
|
||||
// NOTE: This is done to improve the performance, since DrawCircle() is very slow
|
||||
BeginTextureMode(bulletTexture);
|
||||
DrawCircle(12, 12, bulletRadius, WHITE);
|
||||
DrawCircleLines(12, 12, bulletRadius, BLACK);
|
||||
DrawCircle(12, 12, (float)bulletRadius, WHITE);
|
||||
DrawCircleLines(12, 12, (float)bulletRadius, BLACK);
|
||||
EndTextureMode();
|
||||
|
||||
bool drawInPerformanceMode = true; // Switch between DrawCircle() and DrawTexture()
|
||||
@ -192,8 +192,8 @@ int main(void)
|
||||
if (!bullets[i].disabled)
|
||||
{
|
||||
DrawTexture(bulletTexture.texture,
|
||||
bullets[i].position.x - bulletTexture.texture.width*0.5f,
|
||||
bullets[i].position.y - bulletTexture.texture.height*0.5f,
|
||||
(int)(bullets[i].position.x - bulletTexture.texture.width*0.5f),
|
||||
(int)(bullets[i].position.y - bulletTexture.texture.height*0.5f),
|
||||
bullets[i].color);
|
||||
}
|
||||
}
|
||||
@ -206,8 +206,8 @@ int main(void)
|
||||
// Do not draw disabled bullets (out of screen)
|
||||
if (!bullets[i].disabled)
|
||||
{
|
||||
DrawCircleV(bullets[i].position, bulletRadius, bullets[i].color);
|
||||
DrawCircleLinesV(bullets[i].position, bulletRadius, BLACK);
|
||||
DrawCircleV(bullets[i].position, (float)bulletRadius, bullets[i].color);
|
||||
DrawCircleLinesV(bullets[i].position, (float)bulletRadius, BLACK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ int main(void)
|
||||
ClearBackground(RAYWHITE);
|
||||
|
||||
// Draw the dashed line with the current properties
|
||||
DrawLineDashed(lineStartPosition, lineEndPosition, dashLength, blankLength, lineColors[colorIndex]);
|
||||
DrawLineDashed(lineStartPosition, lineEndPosition, (int)dashLength, (int)blankLength, lineColors[colorIndex]);
|
||||
|
||||
// Draw UI and Instructions
|
||||
DrawRectangle(5, 5, 265, 95, Fade(SKYBLUE, 0.5f));
|
||||
|
||||
@ -15,6 +15,8 @@
|
||||
*
|
||||
********************************************************************************************/
|
||||
|
||||
#define _CRT_SECURE_NO_WARNINGS // Disable some Visual Studio warnings
|
||||
|
||||
#include "raylib.h"
|
||||
|
||||
#include <math.h> // Required for: cosf(), sinf()
|
||||
@ -158,7 +160,7 @@ static void UpdateClock(Clock *clock)
|
||||
clock->minute.value = timeinfo->tm_min;
|
||||
clock->hour.value = timeinfo->tm_hour;
|
||||
|
||||
clock->hour.angle = (timeinfo->tm_hour%12)*180.0/6.0f;
|
||||
clock->hour.angle = (timeinfo->tm_hour%12)*180.0f/6.0f;
|
||||
clock->hour.angle += (timeinfo->tm_min%60)*30/60.0f;
|
||||
clock->hour.angle -= 90;
|
||||
|
||||
@ -175,8 +177,8 @@ static void UpdateClock(Clock *clock)
|
||||
static void DrawClockAnalog(Clock clock, Vector2 position)
|
||||
{
|
||||
// Draw clock base
|
||||
DrawCircleV(position, clock.second.length + 40, LIGHTGRAY);
|
||||
DrawCircleV(position, 12, GRAY);
|
||||
DrawCircleV(position, clock.second.length + 40.0f, LIGHTGRAY);
|
||||
DrawCircleV(position, 12.0f, GRAY);
|
||||
|
||||
// Draw clock minutes/seconds lines
|
||||
for (int i = 0; i < 60; i++)
|
||||
@ -192,15 +194,15 @@ static void DrawClockAnalog(Clock clock, Vector2 position)
|
||||
}
|
||||
|
||||
// Draw hand seconds
|
||||
DrawRectanglePro((Rectangle){ position.x, position.y, clock.second.length, clock.second.thickness },
|
||||
DrawRectanglePro((Rectangle){ position.x, position.y, (float)clock.second.length, (float)clock.second.thickness },
|
||||
(Vector2){ 0.0f, clock.second.thickness/2.0f }, clock.second.angle, clock.second.color);
|
||||
|
||||
// Draw hand minutes
|
||||
DrawRectanglePro((Rectangle){ position.x, position.y, clock.minute.length, clock.minute.thickness },
|
||||
DrawRectanglePro((Rectangle){ position.x, position.y, (float)clock.minute.length, (float)clock.minute.thickness },
|
||||
(Vector2){ 0.0f, clock.minute.thickness/2.0f }, clock.minute.angle, clock.minute.color);
|
||||
|
||||
// Draw hand hours
|
||||
DrawRectanglePro((Rectangle){ position.x, position.y, clock.hour.length, clock.hour.thickness },
|
||||
DrawRectanglePro((Rectangle){ position.x, position.y, (float)clock.hour.length, (float)clock.hour.thickness },
|
||||
(Vector2){ 0.0f, clock.hour.thickness/2.0f }, clock.hour.angle, clock.hour.color);
|
||||
}
|
||||
|
||||
@ -212,14 +214,14 @@ static void DrawClockDigital(Clock clock, Vector2 position)
|
||||
DrawDisplayValue((Vector2){ position.x, position.y }, clock.hour.value/10, RED, Fade(LIGHTGRAY, 0.3f));
|
||||
DrawDisplayValue((Vector2){ position.x + 120, position.y }, clock.hour.value%10, RED, Fade(LIGHTGRAY, 0.3f));
|
||||
|
||||
DrawCircle(position.x + 240, position.y + 70, 12, (clock.second.value%2)? RED : Fade(LIGHTGRAY, 0.3f));
|
||||
DrawCircle(position.x + 240, position.y + 150, 12, (clock.second.value%2)? RED : Fade(LIGHTGRAY, 0.3f));
|
||||
DrawCircle((int)position.x + 240, (int)position.y + 70, 12, (clock.second.value%2)? RED : Fade(LIGHTGRAY, 0.3f));
|
||||
DrawCircle((int)position.x + 240, (int)position.y + 150, 12, (clock.second.value%2)? RED : Fade(LIGHTGRAY, 0.3f));
|
||||
|
||||
DrawDisplayValue((Vector2){ position.x + 260, position.y }, clock.minute.value/10, RED, Fade(LIGHTGRAY, 0.3f));
|
||||
DrawDisplayValue((Vector2){ position.x + 380, position.y }, clock.minute.value%10, RED, Fade(LIGHTGRAY, 0.3f));
|
||||
|
||||
DrawCircle(position.x + 500, position.y + 70, 12, (clock.second.value%2)? RED : Fade(LIGHTGRAY, 0.3f));
|
||||
DrawCircle(position.x + 500, position.y + 150, 12, (clock.second.value%2)? RED : Fade(LIGHTGRAY, 0.3f));
|
||||
DrawCircle((int)position.x + 500, (int)position.y + 70, 12, (clock.second.value%2)? RED : Fade(LIGHTGRAY, 0.3f));
|
||||
DrawCircle((int)position.x + 500, (int)position.y + 150, 12, (clock.second.value%2)? RED : Fade(LIGHTGRAY, 0.3f));
|
||||
|
||||
DrawDisplayValue((Vector2){ position.x + 520, position.y }, clock.second.value/10, RED, Fade(LIGHTGRAY, 0.3f));
|
||||
DrawDisplayValue((Vector2){ position.x + 640, position.y }, clock.second.value%10, RED, Fade(LIGHTGRAY, 0.3f));
|
||||
|
||||
@ -21,7 +21,7 @@
|
||||
|
||||
// Constant for Simulation
|
||||
#define SIMULATION_STEPS 30
|
||||
#define G 9.81
|
||||
#define G 9.81f
|
||||
|
||||
//----------------------------------------------------------------------------------
|
||||
// Module Functions Declaration
|
||||
@ -43,9 +43,9 @@ int main(void)
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - double pendulum");
|
||||
|
||||
// Simulation Paramters
|
||||
float l1 = 15, m1 = 0.2, theta1 = DEG2RAD*170, w1 = 0;
|
||||
float l2 = 15, m2 = 0.1, theta2 = DEG2RAD*0, w2 = 0;
|
||||
float lengthScaler = 0.1;
|
||||
float l1 = 15.0f, m1 = 0.2f, theta1 = DEG2RAD*170, w1 = 0;
|
||||
float l2 = 15.0f, m2 = 0.1f, theta2 = DEG2RAD*0, w2 = 0;
|
||||
float lengthScaler = 0.1f;
|
||||
float totalM = m1 + m2;
|
||||
|
||||
Vector2 previousPosition = CalculateDoublePendulumEndPoint(l1, theta1, l2, theta2);
|
||||
@ -57,8 +57,8 @@ int main(void)
|
||||
float L2 = l2*lengthScaler;
|
||||
|
||||
// Draw parameters
|
||||
int lineThick = 20, trailThick = 2;
|
||||
float fateAlpha = 0.01;
|
||||
float lineThick = 20, trailThick = 2;
|
||||
float fateAlpha = 0.01f;
|
||||
|
||||
// Create framebuffer
|
||||
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
|
||||
@ -129,15 +129,15 @@ int main(void)
|
||||
ClearBackground(BLACK);
|
||||
|
||||
// Draw trails texture
|
||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, target.texture.width, -target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
||||
DrawTextureRec(target.texture, (Rectangle){ 0, 0, (float)target.texture.width, (float)-target.texture.height }, (Vector2){ 0, 0 }, WHITE);
|
||||
|
||||
// Draw double pendulum
|
||||
DrawRectanglePro((Rectangle){ screenWidth/2, screenHeight/2 - 100, 10*l1, lineThick },
|
||||
(Vector2){0, lineThick*0.5}, 90 - RAD2DEG*theta1, RAYWHITE);
|
||||
DrawRectanglePro((Rectangle){ screenWidth/2.0f, screenHeight/2.0f - 100, 10*l1, lineThick },
|
||||
(Vector2){0, lineThick*0.5f}, 90 - RAD2DEG*theta1, RAYWHITE);
|
||||
|
||||
Vector2 endpoint1 = CalculatePendulumEndPoint(l1, theta1);
|
||||
DrawRectanglePro((Rectangle){ screenWidth/2 + endpoint1.x, screenHeight/2 - 100 + endpoint1.y, 10*l2, lineThick },
|
||||
(Vector2){0, lineThick*0.5}, 90 - RAD2DEG*theta2, RAYWHITE);
|
||||
DrawRectanglePro((Rectangle){ screenWidth/2.0f + endpoint1.x, screenHeight/2.0f - 100 + endpoint1.y, 10*l2, lineThick },
|
||||
(Vector2){0, lineThick*0.5f}, 90 - RAD2DEG*theta2, RAYWHITE);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -159,7 +159,7 @@ int main(void)
|
||||
// Calculate pendulum end point
|
||||
static Vector2 CalculatePendulumEndPoint(float l, float theta)
|
||||
{
|
||||
return (Vector2){ 10*l*sin(theta), 10*l*cos(theta) };
|
||||
return (Vector2){ 10*l*sinf(theta), 10*l*cosf(theta) };
|
||||
}
|
||||
|
||||
// Calculate double pendulum end point
|
||||
|
||||
@ -48,7 +48,7 @@ int main(void)
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - shapes recursive tree");
|
||||
|
||||
Vector2 start = { (screenWidth/2.0f) - 125.0f, screenHeight };
|
||||
Vector2 start = { (screenWidth/2.0f) - 125.0f, (float)screenHeight };
|
||||
float angle = 40.0f;
|
||||
float thick = 1.0f;
|
||||
float treeDepth = 10.0f;
|
||||
@ -66,7 +66,7 @@ int main(void)
|
||||
//----------------------------------------------------------------------------------
|
||||
|
||||
float theta = angle*DEG2RAD;
|
||||
int maxBranches = (int)(powf(2, (int)(treeDepth)));
|
||||
int maxBranches = (int)(powf(2, floorf(treeDepth)));
|
||||
Branch branches[1024] = { 0 };
|
||||
int count = 0;
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ int main(void)
|
||||
|
||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - vector angle");
|
||||
|
||||
Vector2 v0 = { screenWidth/2, screenHeight/2 };
|
||||
Vector2 v0 = { screenWidth/2.0f, screenHeight/2.0f };
|
||||
Vector2 v1 = Vector2Add(v0, (Vector2){ 100.0f, 80.0f });
|
||||
Vector2 v2 = { 0 }; // Updated with mouse position
|
||||
|
||||
@ -97,17 +97,17 @@ int main(void)
|
||||
DrawCircleSector(v0, 40.0f, startangle, startangle - angle, 32, Fade(GREEN, 0.6f));
|
||||
}
|
||||
|
||||
DrawText("v0", v0.x, v0.y, 10, DARKGRAY);
|
||||
DrawText("v0", (int)v0.x, (int)v0.y, 10, DARKGRAY);
|
||||
|
||||
// If the line from v0 to v1 would overlap the text, move it's position up 10
|
||||
if (angleMode == 0 && Vector2Subtract(v0, v1).y > 0.0f) DrawText("v1", v1.x, v1.y-10.0f, 10, DARKGRAY);
|
||||
if (angleMode == 0 && Vector2Subtract(v0, v1).y < 0.0f) DrawText("v1", v1.x, v1.y, 10, DARKGRAY);
|
||||
if (angleMode == 0 && Vector2Subtract(v0, v1).y > 0.0f) DrawText("v1", (int)v1.x, (int)v1.y-10, 10, DARKGRAY);
|
||||
if (angleMode == 0 && Vector2Subtract(v0, v1).y < 0.0f) DrawText("v1", (int)v1.x, (int)v1.y, 10, DARKGRAY);
|
||||
|
||||
// If angle mode 1, use v1 to emphasize the horizontal line
|
||||
if (angleMode == 1) DrawText("v1", v0.x + 40.0f, v0.y, 10, DARKGRAY);
|
||||
if (angleMode == 1) DrawText("v1", (int)v0.x + 40, (int)v0.y, 10, DARKGRAY);
|
||||
|
||||
// position adjusted by -10 so it isn't hidden by cursor
|
||||
DrawText("v2", v2.x-10.0f, v2.y-10.0f, 10, DARKGRAY);
|
||||
DrawText("v2", (int)v2.x-10, (int)v2.y-10, 10, DARKGRAY);
|
||||
|
||||
DrawText("Press SPACE to change MODE", 460, 10, 20, DARKGRAY);
|
||||
DrawText(TextFormat("ANGLE: %2.2f", angle), 10, 70, 20, LIME);
|
||||
|
||||
@ -86,7 +86,7 @@ int main(void)
|
||||
DrawTextStyled(GetFontDefault(), text, (Vector2){ 100, 220 }, 40.0f, 2.0f, BLACK);
|
||||
|
||||
textSize = MeasureTextStyled(GetFontDefault(), text, 40.0f, 2.0f);
|
||||
DrawRectangleLines(100, 220, textSize.x, textSize.y, GREEN);
|
||||
DrawRectangleLines(100, 220, (int)textSize.x, (int)textSize.y, GREEN);
|
||||
|
||||
EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
@ -154,7 +154,7 @@ static void DrawTextStyled(Font font, const char *text, Vector2 position, float
|
||||
|
||||
// Parse following color
|
||||
char colHexText[9] = { 0 };
|
||||
char *textPtr = &text[i]; // Color should start here, let's see...
|
||||
const char *textPtr = &text[i]; // Color should start here, let's see...
|
||||
|
||||
int colHexCount = 0;
|
||||
while ((textPtr != NULL) && (textPtr[colHexCount] != '\0') && (textPtr[colHexCount] != ']'))
|
||||
@ -186,7 +186,7 @@ static void DrawTextStyled(Font font, const char *text, Vector2 position, float
|
||||
else increaseX += ((float)font.glyphs[index].advanceX*scaleFactor + spacing);
|
||||
|
||||
// Draw background rectangle color (if required)
|
||||
if (colBack.a > 0) DrawRectangle(position.x + textOffsetX, position.y + textOffsetY - backRecPadding, increaseX, fontSize + 2*backRecPadding, colBack);
|
||||
if (colBack.a > 0) DrawRectangleRec((Rectangle) { position.x + textOffsetX, position.y + textOffsetY - backRecPadding, increaseX, fontSize + 2 * backRecPadding }, colBack);
|
||||
|
||||
if ((codepoint != ' ') && (codepoint != '\t'))
|
||||
{
|
||||
@ -236,7 +236,7 @@ static Vector2 MeasureTextStyled(Font font, const char *text, float fontSize, fl
|
||||
{
|
||||
i += 2; // Skip "[c" or "[b" to start parsing color
|
||||
|
||||
char *textPtr = &text[i]; // Color should start here, let's see...
|
||||
const char *textPtr = &text[i]; // Color should start here, let's see...
|
||||
|
||||
int colHexCount = 0;
|
||||
while ((textPtr != NULL) && (textPtr[colHexCount] != '\0') && (textPtr[colHexCount] != ']'))
|
||||
|
||||
@ -144,9 +144,9 @@ int main(void)
|
||||
|
||||
// Draw font texture scaled to screen
|
||||
float atlasScale = 380.0f/font.texture.width;
|
||||
DrawRectangle(400, 16, font.texture.width*atlasScale, font.texture.height*atlasScale, BLACK);
|
||||
DrawTexturePro(font.texture, (Rectangle){ 0, 0, font.texture.width, font.texture.height },
|
||||
(Rectangle){ 400, 16, font.texture.width*atlasScale, font.texture.height*atlasScale }, (Vector2){ 0, 0 }, 0.0f, WHITE);
|
||||
DrawRectangleRec((Rectangle) { 400.0f, 16.0f, font.texture.width* atlasScale, font.texture.height* atlasScale }, BLACK);
|
||||
DrawTexturePro(font.texture, (Rectangle){ 0, 0, (float)font.texture.width, (float)font.texture.height },
|
||||
(Rectangle){ 400.0f, 16.0f, font.texture.width*atlasScale, font.texture.height*atlasScale }, (Vector2){ 0, 0 }, 0.0f, WHITE);
|
||||
DrawRectangleLines(400, 16, 380, 380, RED);
|
||||
|
||||
DrawText(TextFormat("ATLAS SIZE: %ix%i px (x%02.2f)", font.texture.width, font.texture.height, atlasScale), 20, 380, 20, BLUE);
|
||||
|
||||
@ -61,13 +61,13 @@ int main(void)
|
||||
UnloadImage(imageBlue);
|
||||
UnloadImage(backgroundImage);
|
||||
|
||||
Rectangle fudesumiRec = {0, 0, fudesumiImage.width, fudesumiImage.height};
|
||||
Rectangle fudesumiRec = {0, 0, (float)fudesumiImage.width, (float)fudesumiImage.height};
|
||||
|
||||
Rectangle fudesumiPos = {50, 10, fudesumiImage.width*0.8f, fudesumiImage.height*0.8f};
|
||||
Rectangle redPos = { 410, 10, fudesumiPos.width/2, fudesumiPos.height/2 };
|
||||
Rectangle greenPos = { 600, 10, fudesumiPos.width/2, fudesumiPos.height/2 };
|
||||
Rectangle bluePos = { 410, 230, fudesumiPos.width/2, fudesumiPos.height/2 };
|
||||
Rectangle alphaPos = { 600, 230, fudesumiPos.width/2, fudesumiPos.height/2 };
|
||||
Rectangle redPos = { 410, 10, fudesumiPos.width/2.0f, fudesumiPos.height/2.0f };
|
||||
Rectangle greenPos = { 600, 10, fudesumiPos.width/2.0f, fudesumiPos.height/2.0f };
|
||||
Rectangle bluePos = { 410, 230, fudesumiPos.width/2.0f, fudesumiPos.height/2.0f };
|
||||
Rectangle alphaPos = { 600, 230, fudesumiPos.width/2.0f, fudesumiPos.height/2.0f };
|
||||
|
||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user