mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-06 14:23:12 +00:00
REVIEWED: Formatting to follow raylib conventions
This commit is contained in:
parent
6c3ef8d9b4
commit
727a90c5d1
@ -148,7 +148,7 @@ int main(void)
|
|||||||
CaptureFrame(&fft, audioSamples);
|
CaptureFrame(&fft, audioSamples);
|
||||||
RenderFrame(&fft, &fftImage);
|
RenderFrame(&fft, &fftImage);
|
||||||
UpdateTexture(fftTexture, fftImage.data);
|
UpdateTexture(fftTexture, fftImage.data);
|
||||||
//------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
@ -278,11 +278,8 @@ static void RenderFrame(const FFTData *fftData, Image *fftImage)
|
|||||||
framesSinceTapback = Clamp(framesSinceTapback, 0.0, fftData->fftHistoryLen - 1);
|
framesSinceTapback = Clamp(framesSinceTapback, 0.0, fftData->fftHistoryLen - 1);
|
||||||
|
|
||||||
int historyPosition = (fftData->historyPos - 1 - (int)framesSinceTapback)%fftData->fftHistoryLen;
|
int historyPosition = (fftData->historyPos - 1 - (int)framesSinceTapback)%fftData->fftHistoryLen;
|
||||||
if (historyPosition < 0)
|
if (historyPosition < 0) historyPosition += fftData->fftHistoryLen;
|
||||||
historyPosition += fftData->fftHistoryLen;
|
|
||||||
|
|
||||||
const float *amplitude = fftData->fftHistory[historyPosition];
|
const float *amplitude = fftData->fftHistory[historyPosition];
|
||||||
for (int bin = 0; bin < BUFFER_SIZE; bin++) {
|
for (int bin = 0; bin < BUFFER_SIZE; bin++) ImageDrawPixel(fftImage, bin, FFT_ROW, ColorFromNormalized((Vector4){ amplitude[bin], UNUSED_CHANNEL, UNUSED_CHANNEL, UNUSED_CHANNEL }));
|
||||||
ImageDrawPixel(fftImage, bin, FFT_ROW, ColorFromNormalized((Vector4){ amplitude[bin], UNUSED_CHANNEL, UNUSED_CHANNEL, UNUSED_CHANNEL }));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -27,9 +27,10 @@ int main(void)
|
|||||||
const int screenWidth = 800;
|
const int screenWidth = 800;
|
||||||
const int screenHeight = 450;
|
const int screenHeight = 450;
|
||||||
|
|
||||||
|
SetConfigFlags(FLAG_WINDOW_HIGHDPI | FLAG_WINDOW_RESIZABLE);
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi testbed");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - highdpi testbed");
|
||||||
|
|
||||||
// TODO: Load resources / Initialize variables at this point
|
int gridSpacing = 40; // Grid spacing in pixels
|
||||||
|
|
||||||
SetTargetFPS(60);
|
SetTargetFPS(60);
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
@ -48,11 +49,12 @@ int main(void)
|
|||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
// TODO: Draw everything that requires to be drawn at this point
|
// Draw grid
|
||||||
|
for (int h = 0; h < 20; h++) DrawLine(0, h*gridSpacing, GetRenderWidth(), h*gridSpacing, LIGHTGRAY);
|
||||||
|
for (int v = 0; v < 40; v++) DrawLine(v*gridSpacing, 0, v*gridSpacing, GetScreenHeight(), LIGHTGRAY);
|
||||||
|
|
||||||
DrawLineEx((Vector2){ 0, 0 }, (Vector2){ screenWidth, screenHeight }, 2.0f, RED);
|
// Draw UI info
|
||||||
DrawLineEx((Vector2){ 0, screenHeight }, (Vector2){ screenWidth, 0 }, 2.0f, RED);
|
DrawText(TextFormat("SCREEN SIZE: %ix%i", GetScreenWidth(), GetScreenHeight()), 10, 10, 20, BLACK);
|
||||||
DrawText("example base code template", 260, 400, 20, LIGHTGRAY);
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -46,7 +46,7 @@ int main(void)
|
|||||||
// Clamp touch points available ( set the maximum touch points allowed )
|
// Clamp touch points available ( set the maximum touch points allowed )
|
||||||
if (tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
|
if (tCount > MAX_TOUCH_POINTS) tCount = MAX_TOUCH_POINTS;
|
||||||
// Get touch points positions
|
// Get touch points positions
|
||||||
for (int i = 0; i < tCount; ++i) touchPositions[i] = GetTouchPosition(i);
|
for (int i = 0; i < tCount; i++) touchPositions[i] = GetTouchPosition(i);
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
@ -55,7 +55,7 @@ int main(void)
|
|||||||
|
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
for (int i = 0; i < tCount; ++i)
|
for (int i = 0; i < tCount; i++)
|
||||||
{
|
{
|
||||||
// Make sure point is not (0, 0) as this means there is no touch for it
|
// Make sure point is not (0, 0) as this means there is no touch for it
|
||||||
if ((touchPositions[i].x > 0) && (touchPositions[i].y > 0))
|
if ((touchPositions[i].x > 0) && (touchPositions[i].y > 0))
|
||||||
|
|||||||
@ -17,11 +17,9 @@
|
|||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
// For itteration purposes and teaching example
|
#define RESOLUTION_COUNT 4 // For iteration purposes and teaching example
|
||||||
#define RESOLUTION_COUNT 4
|
|
||||||
|
|
||||||
enum ViewportType
|
typedef enum {
|
||||||
{
|
|
||||||
// Only upscale, useful for pixel art
|
// Only upscale, useful for pixel art
|
||||||
KEEP_ASPECT_INTEGER,
|
KEEP_ASPECT_INTEGER,
|
||||||
KEEP_HEIGHT_INTEGER,
|
KEEP_HEIGHT_INTEGER,
|
||||||
@ -32,24 +30,28 @@ enum ViewportType
|
|||||||
KEEP_WIDTH,
|
KEEP_WIDTH,
|
||||||
// For itteration purposes and as a teaching example
|
// For itteration purposes and as a teaching example
|
||||||
VIEWPORT_TYPE_COUNT,
|
VIEWPORT_TYPE_COUNT,
|
||||||
|
} ViewportType;
|
||||||
|
|
||||||
|
// For displaying on GUI
|
||||||
|
const char *ViewportTypeNames[VIEWPORT_TYPE_COUNT] = {
|
||||||
|
"KEEP_ASPECT_INTEGER",
|
||||||
|
"KEEP_HEIGHT_INTEGER",
|
||||||
|
"KEEP_WIDTH_INTEGER",
|
||||||
|
"KEEP_ASPECT",
|
||||||
|
"KEEP_HEIGHT",
|
||||||
|
"KEEP_WIDTH",
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// Module Functions Declaration
|
// Module Functions Declaration
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
static void KeepAspectCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
static void KeepAspectCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
||||||
|
|
||||||
static void KeepHeightCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
static void KeepHeightCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
||||||
|
|
||||||
static void KeepWidthCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
static void KeepWidthCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
||||||
|
|
||||||
static void KeepAspectCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
static void KeepAspectCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
||||||
|
|
||||||
static void KeepHeightCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
static void KeepHeightCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
||||||
|
|
||||||
static void KeepWidthCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
static void KeepWidthCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect);
|
||||||
|
static void ResizeRenderSize(ViewportType viewportType, int *screenWidth, int *screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect, RenderTexture2D *target);
|
||||||
static void ResizeRenderSize(enum ViewportType viewportType, int *screenWidth, int *screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect, RenderTexture2D *target);
|
|
||||||
|
|
||||||
// Example how to calculate position on RenderTexture
|
// Example how to calculate position on RenderTexture
|
||||||
static Vector2 Screen2RenderTexturePosition(Vector2 point, Rectangle *textureRect, Rectangle *scaledRect);
|
static Vector2 Screen2RenderTexturePosition(Vector2 point, Rectangle *textureRect, Rectangle *scaledRect);
|
||||||
@ -61,6 +63,12 @@ int main(void)
|
|||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//---------------------------------------------------------
|
//---------------------------------------------------------
|
||||||
|
int screenWidth = 800;
|
||||||
|
int screenHeight = 450;
|
||||||
|
|
||||||
|
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
||||||
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - viewport scaling");
|
||||||
|
|
||||||
// Preset resolutions that could be created by subdividing screen resolution
|
// Preset resolutions that could be created by subdividing screen resolution
|
||||||
Vector2 resolutionList[RESOLUTION_COUNT] = {
|
Vector2 resolutionList[RESOLUTION_COUNT] = {
|
||||||
(Vector2){ 64, 64 },
|
(Vector2){ 64, 64 },
|
||||||
@ -69,10 +77,8 @@ int main(void)
|
|||||||
// 4K doesn't work with integer scaling but included for example purposes with non-integer scaling
|
// 4K doesn't work with integer scaling but included for example purposes with non-integer scaling
|
||||||
(Vector2){ 3840, 2160 },
|
(Vector2){ 3840, 2160 },
|
||||||
};
|
};
|
||||||
int resolutionIndex = 0;
|
|
||||||
|
|
||||||
int screenWidth = 800;
|
int resolutionIndex = 0;
|
||||||
int screenHeight = 450;
|
|
||||||
int gameWidth = 64;
|
int gameWidth = 64;
|
||||||
int gameHeight = 64;
|
int gameHeight = 64;
|
||||||
|
|
||||||
@ -80,72 +86,66 @@ int main(void)
|
|||||||
Rectangle sourceRect = (Rectangle){ 0 };
|
Rectangle sourceRect = (Rectangle){ 0 };
|
||||||
Rectangle destRect = (Rectangle){ 0 };
|
Rectangle destRect = (Rectangle){ 0 };
|
||||||
|
|
||||||
// For displaying on GUI
|
ViewportType viewportType = KEEP_ASPECT_INTEGER;
|
||||||
const char *ViewportTypeNames[VIEWPORT_TYPE_COUNT] = {
|
|
||||||
"KEEP_ASPECT_INTEGER",
|
|
||||||
"KEEP_HEIGHT_INTEGER",
|
|
||||||
"KEEP_WIDTH_INTEGER",
|
|
||||||
"KEEP_ASPECT",
|
|
||||||
"KEEP_HEIGHT",
|
|
||||||
"KEEP_WIDTH",
|
|
||||||
};
|
|
||||||
enum ViewportType viewportType = KEEP_ASPECT_INTEGER;
|
|
||||||
|
|
||||||
SetConfigFlags(FLAG_WINDOW_RESIZABLE);
|
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - viewport scaling");
|
|
||||||
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
|
||||||
//----------------------------------------------------------
|
|
||||||
|
|
||||||
// Button rectangles
|
// Button rectangles
|
||||||
Rectangle decreaseResolutionButton = (Rectangle){ 200, 30, 10, 10 };
|
Rectangle decreaseResolutionButton = (Rectangle){ 200, 30, 10, 10 };
|
||||||
Rectangle increaseResolutionButton = (Rectangle){ 215, 30, 10, 10 };
|
Rectangle increaseResolutionButton = (Rectangle){ 215, 30, 10, 10 };
|
||||||
Rectangle decreaseTypeButton = (Rectangle){ 200, 45, 10, 10 };
|
Rectangle decreaseTypeButton = (Rectangle){ 200, 45, 10, 10 };
|
||||||
Rectangle increaseTypeButton = (Rectangle){ 215, 45, 10, 10 };
|
Rectangle increaseTypeButton = (Rectangle){ 215, 45, 10, 10 };
|
||||||
|
|
||||||
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
//----------------------------------------------------------
|
||||||
|
|
||||||
// Main game loop
|
// Main game loop
|
||||||
while (!WindowShouldClose()) // Detect window close button or ESC key
|
while (!WindowShouldClose()) // Detect window close button or ESC key
|
||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//-----------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsWindowResized()){
|
if (IsWindowResized()) ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
||||||
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
|
||||||
}
|
|
||||||
Vector2 mousePosition = GetMousePosition();
|
Vector2 mousePosition = GetMousePosition();
|
||||||
bool mousePressed = IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
bool mousePressed = IsMouseButtonPressed(MOUSE_BUTTON_LEFT);
|
||||||
|
|
||||||
// Check buttons and rescale
|
// Check buttons and rescale
|
||||||
if (CheckCollisionPointRec(mousePosition, decreaseResolutionButton) && mousePressed){
|
if (CheckCollisionPointRec(mousePosition, decreaseResolutionButton) && mousePressed)
|
||||||
|
{
|
||||||
resolutionIndex = (resolutionIndex + RESOLUTION_COUNT - 1)%RESOLUTION_COUNT;
|
resolutionIndex = (resolutionIndex + RESOLUTION_COUNT - 1)%RESOLUTION_COUNT;
|
||||||
gameWidth = resolutionList[resolutionIndex].x;
|
gameWidth = resolutionList[resolutionIndex].x;
|
||||||
gameHeight = resolutionList[resolutionIndex].y;
|
gameHeight = resolutionList[resolutionIndex].y;
|
||||||
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
||||||
}
|
}
|
||||||
if (CheckCollisionPointRec(mousePosition, increaseResolutionButton) && mousePressed){
|
|
||||||
|
if (CheckCollisionPointRec(mousePosition, increaseResolutionButton) && mousePressed)
|
||||||
|
{
|
||||||
resolutionIndex = (resolutionIndex + 1)%RESOLUTION_COUNT;
|
resolutionIndex = (resolutionIndex + 1)%RESOLUTION_COUNT;
|
||||||
gameWidth = resolutionList[resolutionIndex].x;
|
gameWidth = resolutionList[resolutionIndex].x;
|
||||||
gameHeight = resolutionList[resolutionIndex].y;
|
gameHeight = resolutionList[resolutionIndex].y;
|
||||||
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
||||||
}
|
}
|
||||||
if (CheckCollisionPointRec(mousePosition, decreaseTypeButton) && mousePressed){
|
|
||||||
|
if (CheckCollisionPointRec(mousePosition, decreaseTypeButton) && mousePressed)
|
||||||
|
{
|
||||||
viewportType = (viewportType + VIEWPORT_TYPE_COUNT - 1)%VIEWPORT_TYPE_COUNT;
|
viewportType = (viewportType + VIEWPORT_TYPE_COUNT - 1)%VIEWPORT_TYPE_COUNT;
|
||||||
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
||||||
}
|
}
|
||||||
if (CheckCollisionPointRec(mousePosition, increaseTypeButton) && mousePressed){
|
|
||||||
|
if (CheckCollisionPointRec(mousePosition, increaseTypeButton) && mousePressed)
|
||||||
|
{
|
||||||
viewportType = (viewportType + 1)%VIEWPORT_TYPE_COUNT;
|
viewportType = (viewportType + 1)%VIEWPORT_TYPE_COUNT;
|
||||||
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
ResizeRenderSize(viewportType, &screenWidth, &screenHeight, gameWidth, gameHeight, &sourceRect, &destRect, &target);
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector2 textureMousePosition = Screen2RenderTexturePosition(mousePosition, &sourceRect, &destRect);
|
Vector2 textureMousePosition = Screen2RenderTexturePosition(mousePosition, &sourceRect, &destRect);
|
||||||
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
//-----------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
// Draw our scene to the render texture
|
// Draw our scene to the render texture
|
||||||
BeginTextureMode(target);
|
BeginTextureMode(target);
|
||||||
ClearBackground(WHITE);
|
ClearBackground(WHITE);
|
||||||
DrawCircle(textureMousePosition.x, textureMousePosition.y, 20.f, LIME);
|
DrawCircle(textureMousePosition.x, textureMousePosition.y, 20.0f, LIME);
|
||||||
|
|
||||||
|
|
||||||
EndTextureMode();
|
EndTextureMode();
|
||||||
|
|
||||||
// Draw render texture to main framebuffer
|
// Draw render texture to main framebuffer
|
||||||
@ -153,9 +153,7 @@ int main(void)
|
|||||||
ClearBackground(BLACK);
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
// Draw our render texture with rotation applied
|
// Draw our render texture with rotation applied
|
||||||
const Vector2 ORIGIN_POSITION = (Vector2){ 0.0f, 0.0f };
|
DrawTexturePro(target.texture, sourceRect, destRect, (Vector2){ 0.0f, 0.0f }, 0.0f, WHITE);
|
||||||
const float ROTATION = 0.f;
|
|
||||||
DrawTexturePro(target.texture, sourceRect, destRect, ORIGIN_POSITION, ROTATION, WHITE);
|
|
||||||
|
|
||||||
// Draw Native resolution (GUI or anything)
|
// Draw Native resolution (GUI or anything)
|
||||||
// Draw info box
|
// Draw info box
|
||||||
@ -167,15 +165,10 @@ int main(void)
|
|||||||
DrawText(TextFormat("Game Resolution: %d x %d", gameWidth, gameHeight), 15, 30, 10, BLACK);
|
DrawText(TextFormat("Game Resolution: %d x %d", gameWidth, gameHeight), 15, 30, 10, BLACK);
|
||||||
|
|
||||||
DrawText(TextFormat("Type: %s", ViewportTypeNames[viewportType]), 15, 45, 10, BLACK);
|
DrawText(TextFormat("Type: %s", ViewportTypeNames[viewportType]), 15, 45, 10, BLACK);
|
||||||
Vector2 scaleRatio = (Vector2){destRect.width / sourceRect.width, destRect.height / -sourceRect.height};
|
Vector2 scaleRatio = (Vector2){destRect.width/sourceRect.width, -destRect.height/sourceRect.height};
|
||||||
if (scaleRatio.x < 0.001f || scaleRatio.y < 0.001f)
|
if (scaleRatio.x < 0.001f || scaleRatio.y < 0.001f) DrawText(TextFormat("Scale ratio: INVALID"), 15, 60, 10, BLACK);
|
||||||
{
|
else DrawText(TextFormat("Scale ratio: %.2f x %.2f", scaleRatio.x, scaleRatio.y), 15, 60, 10, BLACK);
|
||||||
DrawText(TextFormat("Scale ratio: INVALID"), 15, 60, 10, BLACK);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DrawText(TextFormat("Scale ratio: %.2f x %.2f", scaleRatio.x, scaleRatio.y), 15, 60, 10, BLACK);
|
|
||||||
}
|
|
||||||
DrawText(TextFormat("Source size: %.2f x %.2f", sourceRect.width, -sourceRect.height), 15, 75, 10, BLACK);
|
DrawText(TextFormat("Source size: %.2f x %.2f", sourceRect.width, -sourceRect.height), 15, 75, 10, BLACK);
|
||||||
DrawText(TextFormat("Destination size: %.2f x %.2f", destRect.width, destRect.height), 15, 90, 10, BLACK);
|
DrawText(TextFormat("Destination size: %.2f x %.2f", destRect.width, destRect.height), 15, 90, 10, BLACK);
|
||||||
|
|
||||||
@ -190,13 +183,13 @@ int main(void)
|
|||||||
DrawText(">", increaseResolutionButton.x + 3, increaseResolutionButton.y + 1, 10, BLACK);
|
DrawText(">", increaseResolutionButton.x + 3, increaseResolutionButton.y + 1, 10, BLACK);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//-----------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//---------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//----------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -206,17 +199,17 @@ int main(void)
|
|||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
static void KeepAspectCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
static void KeepAspectCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
||||||
{
|
{
|
||||||
sourceRect->x = 0.f;
|
sourceRect->x = 0.0f;
|
||||||
sourceRect->y = (float)gameHeight;
|
sourceRect->y = (float)gameHeight;
|
||||||
sourceRect->width = (float)gameWidth;
|
sourceRect->width = (float)gameWidth;
|
||||||
sourceRect->height = (float)-gameHeight;
|
sourceRect->height = (float)-gameHeight;
|
||||||
|
|
||||||
const int ratio_x = (screenWidth/gameWidth);
|
const int ratio_x = (screenWidth/gameWidth);
|
||||||
const int ratio_y = (screenHeight/gameHeight);
|
const int ratio_y = (screenHeight/gameHeight);
|
||||||
const float resizeRatio = (float)(ratio_x < ratio_y ? ratio_x : ratio_y);
|
const float resizeRatio = (float)((ratio_x < ratio_y)? ratio_x : ratio_y);
|
||||||
|
|
||||||
destRect->x = (float)(int)((screenWidth - (gameWidth * resizeRatio)) * 0.5);
|
destRect->x = (float)(int)((screenWidth - (gameWidth*resizeRatio))*0.5f);
|
||||||
destRect->y = (float)(int)((screenHeight - (gameHeight * resizeRatio)) * 0.5);
|
destRect->y = (float)(int)((screenHeight - (gameHeight*resizeRatio))*0.5f);
|
||||||
destRect->width = (float)(int)(gameWidth*resizeRatio);
|
destRect->width = (float)(int)(gameWidth*resizeRatio);
|
||||||
destRect->height = (float)(int)(gameHeight*resizeRatio);
|
destRect->height = (float)(int)(gameHeight*resizeRatio);
|
||||||
}
|
}
|
||||||
@ -224,13 +217,13 @@ static void KeepAspectCenteredInteger(int screenWidth, int screenHeight, int gam
|
|||||||
static void KeepHeightCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
static void KeepHeightCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
||||||
{
|
{
|
||||||
const float resizeRatio = (float)(screenHeight/gameHeight);
|
const float resizeRatio = (float)(screenHeight/gameHeight);
|
||||||
sourceRect->x = 0.f;
|
sourceRect->x = 0.0f;
|
||||||
sourceRect->y = 0.f;
|
sourceRect->y = 0.0f;
|
||||||
sourceRect->width = (float)(int)(screenWidth/resizeRatio);
|
sourceRect->width = (float)(int)(screenWidth/resizeRatio);
|
||||||
sourceRect->height = (float)-gameHeight;
|
sourceRect->height = (float)-gameHeight;
|
||||||
|
|
||||||
destRect->x = (float)(int)((screenWidth - (sourceRect->width * resizeRatio)) * 0.5);
|
destRect->x = (float)(int)((screenWidth - (sourceRect->width*resizeRatio))*0.5f);
|
||||||
destRect->y = (float)(int)((screenHeight - (gameHeight * resizeRatio)) * 0.5);
|
destRect->y = (float)(int)((screenHeight - (gameHeight*resizeRatio))*0.5f);
|
||||||
destRect->width = (float)(int)(sourceRect->width*resizeRatio);
|
destRect->width = (float)(int)(sourceRect->width*resizeRatio);
|
||||||
destRect->height = (float)(int)(gameHeight*resizeRatio);
|
destRect->height = (float)(int)(gameHeight*resizeRatio);
|
||||||
}
|
}
|
||||||
@ -238,22 +231,22 @@ static void KeepHeightCenteredInteger(int screenWidth, int screenHeight, int gam
|
|||||||
static void KeepWidthCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
static void KeepWidthCenteredInteger(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
||||||
{
|
{
|
||||||
const float resizeRatio = (float)(screenWidth/gameWidth);
|
const float resizeRatio = (float)(screenWidth/gameWidth);
|
||||||
sourceRect->x = 0.f;
|
sourceRect->x = 0.0f;
|
||||||
sourceRect->y = 0.f;
|
sourceRect->y = 0.0f;
|
||||||
sourceRect->width = (float)gameWidth;
|
sourceRect->width = (float)gameWidth;
|
||||||
sourceRect->height = (float)(int)(screenHeight/resizeRatio);
|
sourceRect->height = (float)(int)(screenHeight/resizeRatio);
|
||||||
|
|
||||||
destRect->x = (float)(int)((screenWidth - (gameWidth * resizeRatio)) * 0.5);
|
destRect->x = (float)(int)((screenWidth - (gameWidth*resizeRatio))*0.5f);
|
||||||
destRect->y = (float)(int)((screenHeight - (sourceRect->height * resizeRatio)) * 0.5);
|
destRect->y = (float)(int)((screenHeight - (sourceRect->height*resizeRatio))*0.5f);
|
||||||
destRect->width = (float)(int)(gameWidth*resizeRatio);
|
destRect->width = (float)(int)(gameWidth*resizeRatio);
|
||||||
destRect->height = (float)(int)(sourceRect->height*resizeRatio);
|
destRect->height = (float)(int)(sourceRect->height*resizeRatio);
|
||||||
|
|
||||||
sourceRect->height *= -1.f;
|
sourceRect->height *= -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void KeepAspectCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
static void KeepAspectCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
||||||
{
|
{
|
||||||
sourceRect->x = 0.f;
|
sourceRect->x = 0.0f;
|
||||||
sourceRect->y = (float)gameHeight;
|
sourceRect->y = (float)gameHeight;
|
||||||
sourceRect->width = (float)gameWidth;
|
sourceRect->width = (float)gameWidth;
|
||||||
sourceRect->height = (float)-gameHeight;
|
sourceRect->height = (float)-gameHeight;
|
||||||
@ -262,8 +255,8 @@ static void KeepAspectCentered(int screenWidth, int screenHeight, int gameWidth,
|
|||||||
const float ratio_y = ((float)screenHeight/(float)gameHeight);
|
const float ratio_y = ((float)screenHeight/(float)gameHeight);
|
||||||
const float resizeRatio = (ratio_x < ratio_y ? ratio_x : ratio_y);
|
const float resizeRatio = (ratio_x < ratio_y ? ratio_x : ratio_y);
|
||||||
|
|
||||||
destRect->x = (float)(int)((screenWidth - (gameWidth * resizeRatio)) * 0.5);
|
destRect->x = (float)(int)((screenWidth - (gameWidth*resizeRatio))*0.5f);
|
||||||
destRect->y = (float)(int)((screenHeight - (gameHeight * resizeRatio)) * 0.5);
|
destRect->y = (float)(int)((screenHeight - (gameHeight*resizeRatio))*0.5f);
|
||||||
destRect->width = (float)(int)(gameWidth*resizeRatio);
|
destRect->width = (float)(int)(gameWidth*resizeRatio);
|
||||||
destRect->height = (float)(int)(gameHeight*resizeRatio);
|
destRect->height = (float)(int)(gameHeight*resizeRatio);
|
||||||
}
|
}
|
||||||
@ -271,13 +264,13 @@ static void KeepAspectCentered(int screenWidth, int screenHeight, int gameWidth,
|
|||||||
static void KeepHeightCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
static void KeepHeightCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
||||||
{
|
{
|
||||||
const float resizeRatio = ((float)screenHeight/(float)gameHeight);
|
const float resizeRatio = ((float)screenHeight/(float)gameHeight);
|
||||||
sourceRect->x = 0.f;
|
sourceRect->x = 0.0f;
|
||||||
sourceRect->y = 0.f;
|
sourceRect->y = 0.0f;
|
||||||
sourceRect->width = (float)(int)((float)screenWidth/resizeRatio);
|
sourceRect->width = (float)(int)((float)screenWidth/resizeRatio);
|
||||||
sourceRect->height = (float)-gameHeight;
|
sourceRect->height = (float)-gameHeight;
|
||||||
|
|
||||||
destRect->x = (float)(int)((screenWidth - (sourceRect->width * resizeRatio)) * 0.5);
|
destRect->x = (float)(int)((screenWidth - (sourceRect->width*resizeRatio))*0.5f);
|
||||||
destRect->y = (float)(int)((screenHeight - (gameHeight * resizeRatio)) * 0.5);
|
destRect->y = (float)(int)((screenHeight - (gameHeight*resizeRatio))*0.5f);
|
||||||
destRect->width = (float)(int)(sourceRect->width*resizeRatio);
|
destRect->width = (float)(int)(sourceRect->width*resizeRatio);
|
||||||
destRect->height = (float)(int)(gameHeight*resizeRatio);
|
destRect->height = (float)(int)(gameHeight*resizeRatio);
|
||||||
}
|
}
|
||||||
@ -285,58 +278,35 @@ static void KeepHeightCentered(int screenWidth, int screenHeight, int gameWidth,
|
|||||||
static void KeepWidthCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
static void KeepWidthCentered(int screenWidth, int screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect)
|
||||||
{
|
{
|
||||||
const float resizeRatio = ((float)screenWidth/(float)gameWidth);
|
const float resizeRatio = ((float)screenWidth/(float)gameWidth);
|
||||||
sourceRect->x = 0.f;
|
sourceRect->x = 0.0f;
|
||||||
sourceRect->y = 0.f;
|
sourceRect->y = 0.0f;
|
||||||
sourceRect->width = (float)gameWidth;
|
sourceRect->width = (float)gameWidth;
|
||||||
sourceRect->height = (float)(int)((float)screenHeight/resizeRatio);
|
sourceRect->height = (float)(int)((float)screenHeight/resizeRatio);
|
||||||
|
|
||||||
destRect->x = (float)(int)((screenWidth - (gameWidth * resizeRatio)) * 0.5);
|
destRect->x = (float)(int)((screenWidth - (gameWidth*resizeRatio))*0.5f);
|
||||||
destRect->y = (float)(int)((screenHeight - (sourceRect->height * resizeRatio)) * 0.5);
|
destRect->y = (float)(int)((screenHeight - (sourceRect->height*resizeRatio))*0.5f);
|
||||||
destRect->width = (float)(int)(gameWidth*resizeRatio);
|
destRect->width = (float)(int)(gameWidth*resizeRatio);
|
||||||
destRect->height = (float)(int)(sourceRect->height*resizeRatio);
|
destRect->height = (float)(int)(sourceRect->height*resizeRatio);
|
||||||
|
|
||||||
sourceRect->height *= -1.f;
|
sourceRect->height *= -1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ResizeRenderSize(enum ViewportType viewportType, int *screenWidth, int *screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect, RenderTexture2D *target)
|
static void ResizeRenderSize(ViewportType viewportType, int *screenWidth, int *screenHeight, int gameWidth, int gameHeight, Rectangle *sourceRect, Rectangle *destRect, RenderTexture2D *target)
|
||||||
{
|
{
|
||||||
*screenWidth = GetScreenWidth();
|
*screenWidth = GetScreenWidth();
|
||||||
*screenHeight = GetScreenHeight();
|
*screenHeight = GetScreenHeight();
|
||||||
|
|
||||||
switch(viewportType)
|
switch(viewportType)
|
||||||
{
|
{
|
||||||
case KEEP_ASPECT_INTEGER:
|
case KEEP_ASPECT_INTEGER: KeepAspectCenteredInteger(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect); break;
|
||||||
{
|
case KEEP_HEIGHT_INTEGER: KeepHeightCenteredInteger(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect); break;
|
||||||
KeepAspectCenteredInteger(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect);
|
case KEEP_WIDTH_INTEGER: KeepWidthCenteredInteger(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect); break;
|
||||||
break;
|
case KEEP_ASPECT: KeepAspectCentered(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect); break;
|
||||||
}
|
case KEEP_HEIGHT: KeepHeightCentered(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect); break;
|
||||||
case KEEP_HEIGHT_INTEGER:
|
case KEEP_WIDTH: KeepWidthCentered(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect); break;
|
||||||
{
|
default: break;
|
||||||
KeepHeightCenteredInteger(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case KEEP_WIDTH_INTEGER:
|
|
||||||
{
|
|
||||||
KeepWidthCenteredInteger(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case KEEP_ASPECT:
|
|
||||||
{
|
|
||||||
KeepAspectCentered(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case KEEP_HEIGHT:
|
|
||||||
{
|
|
||||||
KeepHeightCentered(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case KEEP_WIDTH:
|
|
||||||
{
|
|
||||||
KeepWidthCentered(*screenWidth, *screenHeight, gameWidth, gameHeight, sourceRect, destRect);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: {}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UnloadRenderTexture(*target);
|
UnloadRenderTexture(*target);
|
||||||
*target = LoadRenderTexture(sourceRect->width, -sourceRect->height);
|
*target = LoadRenderTexture(sourceRect->width, -sourceRect->height);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -97,7 +97,8 @@ int main(void)
|
|||||||
if (IsWindowState(FLAG_WINDOW_MINIMIZED))
|
if (IsWindowState(FLAG_WINDOW_MINIMIZED))
|
||||||
{
|
{
|
||||||
framesCounter++;
|
framesCounter++;
|
||||||
if (framesCounter >= 240) {
|
if (framesCounter >= 240)
|
||||||
|
{
|
||||||
RestoreWindow(); // Restore window after 3 seconds
|
RestoreWindow(); // Restore window after 3 seconds
|
||||||
framesCounter = 0;
|
framesCounter = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -138,7 +138,7 @@ int main(void)
|
|||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
for (int i = 0; i < MAX_TEXTURES; ++i) UnloadTexture(texture[i]);
|
for (int i = 0; i < MAX_TEXTURES; i++) UnloadTexture(texture[i]);
|
||||||
UnloadShader(shdrColorCorrection);
|
UnloadShader(shdrColorCorrection);
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
|
|||||||
@ -14,9 +14,6 @@
|
|||||||
* Copyright (c) 2025 JP Mortiboys (@themushroompirates)
|
* Copyright (c) 2025 JP Mortiboys (@themushroompirates)
|
||||||
*
|
*
|
||||||
********************************************************************************************/
|
********************************************************************************************/
|
||||||
#if defined(WIN32)
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
@ -63,24 +60,16 @@ int main(void)
|
|||||||
/* 8 */ { TL,HH,HH,TR, /* */ VV,TL,TR,VV,/* */ VV,BL,BR,VV,/* */ VV,TL,TR,VV,/* */ VV,BL,BR,VV,/* */ BL,HH,HH,BR },
|
/* 8 */ { TL,HH,HH,TR, /* */ VV,TL,TR,VV,/* */ VV,BL,BR,VV,/* */ VV,TL,TR,VV,/* */ VV,BL,BR,VV,/* */ BL,HH,HH,BR },
|
||||||
/* 9 */ { TL,HH,HH,TR, /* */ VV,TL,TR,VV,/* */ VV,BL,BR,VV,/* */ BL,HH,TR,VV,/* */ TL,HH,BR,VV,/* */ BL,HH,HH,BR },
|
/* 9 */ { TL,HH,HH,TR, /* */ VV,TL,TR,VV,/* */ VV,BL,BR,VV,/* */ BL,HH,TR,VV,/* */ TL,HH,BR,VV,/* */ BL,HH,HH,BR },
|
||||||
};
|
};
|
||||||
|
|
||||||
// Time for the hands to move to the new position (in seconds); this must be <1s
|
// Time for the hands to move to the new position (in seconds); this must be <1s
|
||||||
const float handsMoveDuration = .5f;
|
const float handsMoveDuration = 0.5f;
|
||||||
|
|
||||||
// We store the previous seconds value so we can see if the time has changed
|
|
||||||
int prevSeconds = -1;
|
int prevSeconds = -1;
|
||||||
|
|
||||||
// This represents the real position where the hands are right now
|
|
||||||
Vector2 currentAngles[6][24] = { 0 };
|
Vector2 currentAngles[6][24] = { 0 };
|
||||||
|
|
||||||
// This is the position where the hands were moving from
|
|
||||||
Vector2 srcAngles[6][24] = { 0 };
|
Vector2 srcAngles[6][24] = { 0 };
|
||||||
// This is the position where the hands are moving to
|
|
||||||
Vector2 dstAngles[6][24] = { 0 };
|
Vector2 dstAngles[6][24] = { 0 };
|
||||||
|
|
||||||
// Current animation timer
|
|
||||||
float handsMoveTimer = 0.0f;
|
float handsMoveTimer = 0.0f;
|
||||||
|
|
||||||
// 12 or 24 hour mode
|
|
||||||
int hourMode = 24;
|
int hourMode = 24;
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
@ -91,7 +80,6 @@ int main(void)
|
|||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Get the current time
|
// Get the current time
|
||||||
time_t rawtime;
|
time_t rawtime;
|
||||||
struct tm *timeinfo;
|
struct tm *timeinfo;
|
||||||
@ -99,7 +87,8 @@ int main(void)
|
|||||||
time(&rawtime);
|
time(&rawtime);
|
||||||
timeinfo = localtime(&rawtime);
|
timeinfo = localtime(&rawtime);
|
||||||
|
|
||||||
if (timeinfo->tm_sec != prevSeconds) {
|
if (timeinfo->tm_sec != prevSeconds)
|
||||||
|
{
|
||||||
// The time has changed, so we need to move the hands to the new positions
|
// The time has changed, so we need to move the hands to the new positions
|
||||||
prevSeconds = timeinfo->tm_sec;
|
prevSeconds = timeinfo->tm_sec;
|
||||||
|
|
||||||
@ -107,22 +96,17 @@ int main(void)
|
|||||||
const char *clockDigits = TextFormat("%02d%02d%02d", timeinfo->tm_hour%hourMode, timeinfo->tm_min, timeinfo->tm_sec);
|
const char *clockDigits = TextFormat("%02d%02d%02d", timeinfo->tm_hour%hourMode, timeinfo->tm_min, timeinfo->tm_sec);
|
||||||
|
|
||||||
// Fetch where we want all the hands to be
|
// Fetch where we want all the hands to be
|
||||||
for (int digit = 0; digit < 6; digit++) {
|
for (int digit = 0; digit < 6; digit++)
|
||||||
for (int cell = 0; cell < 24; cell++) {
|
{
|
||||||
|
for (int cell = 0; cell < 24; cell++)
|
||||||
|
{
|
||||||
srcAngles[digit][cell] = currentAngles[digit][cell];
|
srcAngles[digit][cell] = currentAngles[digit][cell];
|
||||||
dstAngles[digit][cell] = digitAngles[clockDigits[digit] - '0'][cell];
|
dstAngles[digit][cell] = digitAngles[clockDigits[digit] - '0'][cell];
|
||||||
|
|
||||||
// Quick exception for 12h mode
|
// Quick exception for 12h mode
|
||||||
if (digit == 0 && hourMode == 12 && clockDigits[0] == '0') {
|
if ((digit == 0) && (hourMode == 12) && (clockDigits[0] == '0')) dstAngles[digit][cell] = ZZ;
|
||||||
dstAngles[digit][cell] = ZZ;
|
if (srcAngles[digit][cell].x > dstAngles[digit][cell].x) srcAngles[digit][cell].x -= 360.0f;
|
||||||
}
|
if (srcAngles[digit][cell].y > dstAngles[digit][cell].y) srcAngles[digit][cell].y -= 360.0f;
|
||||||
|
|
||||||
if (srcAngles[digit][cell].x > dstAngles[digit][cell].x) {
|
|
||||||
srcAngles[digit][cell].x -= 360.0f;
|
|
||||||
}
|
|
||||||
if (srcAngles[digit][cell].y > dstAngles[digit][cell].y) {
|
|
||||||
srcAngles[digit][cell].y -= 360.0f;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +115,8 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Now let's animate all the hands if we need to
|
// Now let's animate all the hands if we need to
|
||||||
if (handsMoveTimer < handsMoveDuration) {
|
if (handsMoveTimer < handsMoveDuration)
|
||||||
|
{
|
||||||
// Increase the timer but don't go above the maximum
|
// Increase the timer but don't go above the maximum
|
||||||
handsMoveTimer = Clamp(handsMoveTimer + GetFrameTime(), 0, handsMoveDuration);
|
handsMoveTimer = Clamp(handsMoveTimer + GetFrameTime(), 0, handsMoveDuration);
|
||||||
|
|
||||||
@ -141,27 +126,18 @@ int main(void)
|
|||||||
// A little cheeky smoothstep
|
// A little cheeky smoothstep
|
||||||
t = t*t*(3.0f - 2.0f*t);
|
t = t*t*(3.0f - 2.0f*t);
|
||||||
|
|
||||||
for (int digit = 0; digit < 6; digit++) {
|
for (int digit = 0; digit < 6; digit++)
|
||||||
for (int cell = 0; cell < 24; cell++) {
|
{
|
||||||
|
for (int cell = 0; cell < 24; cell++)
|
||||||
|
{
|
||||||
currentAngles[digit][cell].x = Lerp(srcAngles[digit][cell].x, dstAngles[digit][cell].x, t);
|
currentAngles[digit][cell].x = Lerp(srcAngles[digit][cell].x, dstAngles[digit][cell].x, t);
|
||||||
currentAngles[digit][cell].y = Lerp(srcAngles[digit][cell].y, dstAngles[digit][cell].y, t);
|
currentAngles[digit][cell].y = Lerp(srcAngles[digit][cell].y, dstAngles[digit][cell].y, t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handsMoveTimer == handsMoveDuration) {
|
|
||||||
// The animation has now finished
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle input
|
// Handle input
|
||||||
|
if (IsKeyPressed(KEY_SPACE)) hourMode = 36 - hourMode; // Toggle between 12 and 24 hour mode with space
|
||||||
// Toggle between 12 and 24 hour mode with space
|
|
||||||
if (IsKeyPressed(KEY_SPACE)) {
|
|
||||||
hourMode = 36 - hourMode;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
@ -174,19 +150,22 @@ int main(void)
|
|||||||
|
|
||||||
float xOffset = 4.0f;
|
float xOffset = 4.0f;
|
||||||
|
|
||||||
for (int digit = 0; digit < 6; digit++) {
|
for (int digit = 0; digit < 6; digit++)
|
||||||
|
{
|
||||||
for (int row = 0; row < 6; row++) {
|
for (int row = 0; row < 6; row++)
|
||||||
for (int col = 0; col < 4; col++) {
|
{
|
||||||
|
for (int col = 0; col < 4; col++)
|
||||||
|
{
|
||||||
Vector2 centre = (Vector2){
|
Vector2 centre = (Vector2){
|
||||||
xOffset + col*(clockFaceSize+clockFaceSpacing) + clockFaceSize * .5f,
|
xOffset + col*(clockFaceSize+clockFaceSpacing) + clockFaceSize*0.5f,
|
||||||
100 + row*(clockFaceSize+clockFaceSpacing) + clockFaceSize * .5f
|
100 + row*(clockFaceSize+clockFaceSpacing) + clockFaceSize*0.5f
|
||||||
};
|
};
|
||||||
|
|
||||||
DrawRing(centre, clockFaceSize*0.5f - 2.0f, clockFaceSize*0.5f, 0, 360, 24, DARKGRAY);
|
DrawRing(centre, clockFaceSize*0.5f - 2.0f, clockFaceSize*0.5f, 0, 360, 24, DARKGRAY);
|
||||||
|
|
||||||
// Big hand
|
// Big hand
|
||||||
DrawRectanglePro(
|
DrawRectanglePro(
|
||||||
(Rectangle){centre.x, centre.y, clockFaceSize*.5f+4.0f, 4.0f},
|
(Rectangle){centre.x, centre.y, clockFaceSize*0.5f+4.0f, 4.0f},
|
||||||
(Vector2){ 2.0f, 2.0f },
|
(Vector2){ 2.0f, 2.0f },
|
||||||
currentAngles[digit][row*4+col].x,
|
currentAngles[digit][row*4+col].x,
|
||||||
handsColor
|
handsColor
|
||||||
@ -194,7 +173,7 @@ int main(void)
|
|||||||
|
|
||||||
// Little hand
|
// Little hand
|
||||||
DrawRectanglePro(
|
DrawRectanglePro(
|
||||||
(Rectangle){centre.x, centre.y, clockFaceSize*.5f+2.0f, 4.0f},
|
(Rectangle){centre.x, centre.y, clockFaceSize*0.5f+2.0f, 4.0f},
|
||||||
(Vector2){ 2.0f, 2.0f },
|
(Vector2){ 2.0f, 2.0f },
|
||||||
currentAngles[digit][row*4+col].y,
|
currentAngles[digit][row*4+col].y,
|
||||||
handsColor
|
handsColor
|
||||||
@ -203,26 +182,22 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
xOffset += (clockFaceSize+clockFaceSpacing)*4;
|
xOffset += (clockFaceSize+clockFaceSpacing)*4;
|
||||||
if (digit % 2 == 1) {
|
if (digit%2 == 1)
|
||||||
|
{
|
||||||
DrawRing((Vector2){xOffset + 4.0f, 160.0f}, 6.0f, 8.0f, 0.0f, 360.0f, 24, handsColor);
|
DrawRing((Vector2){xOffset + 4.0f, 160.0f}, 6.0f, 8.0f, 0.0f, 360.0f, 24, handsColor);
|
||||||
DrawRing((Vector2){xOffset + 4.0f, 225.0f}, 6.0f, 8.0f, 0.0f, 360.0f, 24, handsColor);
|
DrawRing((Vector2){xOffset + 4.0f, 225.0f}, 6.0f, 8.0f, 0.0f, 360.0f, 24, handsColor);
|
||||||
|
|
||||||
xOffset += sectionSpacing;
|
xOffset += sectionSpacing;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
}
|
}
|
||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -76,7 +76,7 @@ int main(void)
|
|||||||
float step = dt/SIMULATION_STEPS, step2 = step*step;
|
float step = dt/SIMULATION_STEPS, step2 = step*step;
|
||||||
|
|
||||||
// Update Physics - larger steps = better approximation
|
// Update Physics - larger steps = better approximation
|
||||||
for (int i = 0; i < SIMULATION_STEPS; ++i)
|
for (int i = 0; i < SIMULATION_STEPS; i++)
|
||||||
{
|
{
|
||||||
float delta = theta1 - theta2;
|
float delta = theta1 - theta2;
|
||||||
float sinD = sinf(delta), cosD = cosf(delta), cos2D = cosf(2*delta);
|
float sinD = sinf(delta), cosD = cosf(delta), cos2D = cosf(2*delta);
|
||||||
|
|||||||
@ -40,8 +40,8 @@ int main(void)
|
|||||||
|
|
||||||
Vector2 sinePoints[WAVE_POINTS];
|
Vector2 sinePoints[WAVE_POINTS];
|
||||||
Vector2 cosPoints[WAVE_POINTS];
|
Vector2 cosPoints[WAVE_POINTS];
|
||||||
Vector2 center = { (screenWidth/2.0f) - 30.f, screenHeight/2.0f };
|
Vector2 center = { (screenWidth/2.0f) - 30.0f, screenHeight/2.0f };
|
||||||
Rectangle start = { 20.f, screenHeight - 120.f , 200.0f, 100.0f};
|
Rectangle start = { 20.0f, screenHeight - 120.f , 200.0f, 100.0f};
|
||||||
float radius = 130.0f;
|
float radius = 130.0f;
|
||||||
float angle = 0.0f;
|
float angle = 0.0f;
|
||||||
bool pause = false;
|
bool pause = false;
|
||||||
@ -98,7 +98,7 @@ int main(void)
|
|||||||
// Base circle and axes
|
// Base circle and axes
|
||||||
DrawCircleLinesV(center, radius, GRAY);
|
DrawCircleLinesV(center, radius, GRAY);
|
||||||
DrawLineEx((Vector2){ center.x, limitMin.y }, (Vector2){ center.x, limitMax.y }, 1.0f, GRAY);
|
DrawLineEx((Vector2){ center.x, limitMin.y }, (Vector2){ center.x, limitMax.y }, 1.0f, GRAY);
|
||||||
DrawLineEx((Vector2){ limitMin.x, center.y }, (Vector2){ limitMax.x, center.y }, 1.f, GRAY);
|
DrawLineEx((Vector2){ limitMin.x, center.y }, (Vector2){ limitMax.x, center.y }, 1.0f, GRAY);
|
||||||
|
|
||||||
// Wave graph axes
|
// Wave graph axes
|
||||||
DrawLineEx((Vector2){ start.x , start.y }, (Vector2){ start.x , start.y + start.height }, 2.0f, GRAY);
|
DrawLineEx((Vector2){ start.x , start.y }, (Vector2){ start.x , start.y + start.height }, 2.0f, GRAY);
|
||||||
@ -135,19 +135,19 @@ int main(void)
|
|||||||
DrawText(TextFormat("Cotangent %.2f", cotangent), 640, 250, 6, ORANGE);
|
DrawText(TextFormat("Cotangent %.2f", cotangent), 640, 250, 6, ORANGE);
|
||||||
|
|
||||||
// Complementary angle (beige)
|
// Complementary angle (beige)
|
||||||
DrawCircleSectorLines(center, radius*0.6f , -angle, -90.f , 36.0f, BEIGE);
|
DrawCircleSectorLines(center, radius*0.6f , -angle, -90.0f , 36.0f, BEIGE);
|
||||||
DrawText(TextFormat("Complementary %0.f°",complementary), 640, 150, 6, BEIGE);
|
DrawText(TextFormat("Complementary %0.f°",complementary), 640, 150, 6, BEIGE);
|
||||||
|
|
||||||
// Supplementary angle (darkblue)
|
// Supplementary angle (darkblue)
|
||||||
DrawCircleSectorLines(center, radius*0.5f , -angle, -180.f , 36.0f, DARKBLUE);
|
DrawCircleSectorLines(center, radius*0.5f , -angle, -180.0f , 36.0f, DARKBLUE);
|
||||||
DrawText(TextFormat("Supplementary %0.f°",supplementary), 640, 130, 6, DARKBLUE);
|
DrawText(TextFormat("Supplementary %0.f°",supplementary), 640, 130, 6, DARKBLUE);
|
||||||
|
|
||||||
// Explementary angle (pink)
|
// Explementary angle (pink)
|
||||||
DrawCircleSectorLines(center, radius*0.4f , -angle, -360.f , 36.0f, PINK);
|
DrawCircleSectorLines(center, radius*0.4f , -angle, -360.0f , 36.0f, PINK);
|
||||||
DrawText(TextFormat("Explementary %0.f°",explementary), 640, 170, 6, PINK);
|
DrawText(TextFormat("Explementary %0.f°",explementary), 640, 170, 6, PINK);
|
||||||
|
|
||||||
// Current angle - arc (lime), radius (black), endpoint (black)
|
// Current angle - arc (lime), radius (black), endpoint (black)
|
||||||
DrawCircleSectorLines(center, radius*0.7f , -angle, 0.f, 36.0f, LIME);
|
DrawCircleSectorLines(center, radius*0.7f , -angle, 0.0f, 36.0f, LIME);
|
||||||
DrawLineEx((Vector2){ center.x , center.y }, point, 2.0f, BLACK);
|
DrawLineEx((Vector2){ center.x , center.y }, point, 2.0f, BLACK);
|
||||||
DrawCircleV(point, 4.0f, BLACK);
|
DrawCircleV(point, 4.0f, BLACK);
|
||||||
|
|
||||||
@ -156,11 +156,12 @@ int main(void)
|
|||||||
GuiSetStyle(LABEL, TEXT_COLOR_NORMAL, ColorToInt(GRAY));
|
GuiSetStyle(LABEL, TEXT_COLOR_NORMAL, ColorToInt(GRAY));
|
||||||
GuiToggle((Rectangle){ 640, 70, 120, 20}, TextFormat("Pause"), &pause);
|
GuiToggle((Rectangle){ 640, 70, 120, 20}, TextFormat("Pause"), &pause);
|
||||||
GuiSetStyle(LABEL, TEXT_COLOR_NORMAL, ColorToInt(LIME));
|
GuiSetStyle(LABEL, TEXT_COLOR_NORMAL, ColorToInt(LIME));
|
||||||
GuiSliderBar((Rectangle){ 640, 40, 120, 20}, "Angle", TextFormat("%.0f°", angle), &angle, 0.0f, 360.f);
|
GuiSliderBar((Rectangle){ 640, 40, 120, 20}, "Angle", TextFormat("%.0f°", angle), &angle, 0.0f, 360.0f);
|
||||||
|
|
||||||
// Angle values panel
|
// Angle values panel
|
||||||
GuiGroupBox((Rectangle){ 620, 110, 140, 170}, "Angle Values");
|
GuiGroupBox((Rectangle){ 620, 110, 140, 170}, "Angle Values");
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
DrawFPS(10, 10);
|
DrawFPS(10, 10);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|||||||
@ -112,7 +112,7 @@ int main(void)
|
|||||||
GuiSliderBar((Rectangle){ 640, 40, 120, 20}, "Angle", TextFormat("%.0f", angle), &angle, 0, 180);
|
GuiSliderBar((Rectangle){ 640, 40, 120, 20}, "Angle", TextFormat("%.0f", angle), &angle, 0, 180);
|
||||||
GuiSliderBar((Rectangle){ 640, 70, 120, 20 }, "Length", TextFormat("%.0f", length), &length, 12.0f, 240.0f);
|
GuiSliderBar((Rectangle){ 640, 70, 120, 20 }, "Length", TextFormat("%.0f", length), &length, 12.0f, 240.0f);
|
||||||
GuiSliderBar((Rectangle){ 640, 100, 120, 20}, "Decay", TextFormat("%.2f", branchDecay), &branchDecay, 0.1f, 0.78f);
|
GuiSliderBar((Rectangle){ 640, 100, 120, 20}, "Decay", TextFormat("%.2f", branchDecay), &branchDecay, 0.1f, 0.78f);
|
||||||
GuiSliderBar((Rectangle){ 640, 130, 120, 20 }, "Depth", TextFormat("%.0f", treeDepth), &treeDepth, 1.0f, 10.f);
|
GuiSliderBar((Rectangle){ 640, 130, 120, 20 }, "Depth", TextFormat("%.0f", treeDepth), &treeDepth, 1.0f, 10.0f);
|
||||||
GuiSliderBar((Rectangle){ 640, 160, 120, 20}, "Thick", TextFormat("%.0f", thick), &thick, 1, 8);
|
GuiSliderBar((Rectangle){ 640, 160, 120, 20}, "Thick", TextFormat("%.0f", thick), &thick, 1, 8);
|
||||||
GuiCheckBox((Rectangle){ 640, 190, 20, 20 }, "Bezier", &bezier);
|
GuiCheckBox((Rectangle){ 640, 190, 20, 20 }, "Bezier", &bezier);
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -152,21 +152,15 @@ int main(void)
|
|||||||
// If the slider or the wheel was clicked, update the current color
|
// If the slider or the wheel was clicked, update the current color
|
||||||
if (settingColor || sliderClicked)
|
if (settingColor || sliderClicked)
|
||||||
{
|
{
|
||||||
if (settingColor) {
|
if (settingColor) circlePosition = GetMousePosition();
|
||||||
circlePosition = GetMousePosition();
|
|
||||||
}
|
|
||||||
|
|
||||||
float distance = Vector2Distance(center, circlePosition)/pointScale;
|
float distance = Vector2Distance(center, circlePosition)/pointScale;
|
||||||
|
|
||||||
float angle = ((Vector2Angle((Vector2){ 0.0f, -pointScale }, Vector2Subtract(center, circlePosition))/PI + 1.0f)/2.0f);
|
float angle = ((Vector2Angle((Vector2){ 0.0f, -pointScale }, Vector2Subtract(center, circlePosition))/PI + 1.0f)/2.0f);
|
||||||
if (settingColor && distance > 1.0f) {
|
if (settingColor && distance > 1.0f) circlePosition = Vector2Add((Vector2){ sinf(angle*(PI*2.0f))*pointScale, -cosf(angle*(PI* 2.0f))*pointScale }, center);
|
||||||
circlePosition = Vector2Add((Vector2){ sinf(angle*(PI*2.0f))*pointScale, -cosf(angle*(PI* 2.0f))*pointScale }, center);
|
|
||||||
}
|
|
||||||
|
|
||||||
float angle360 = angle*360.0f;
|
float angle360 = angle*360.0f;
|
||||||
|
|
||||||
float valueActual = Clamp(distance, 0.0f, 1.0f);
|
float valueActual = Clamp(distance, 0.0f, 1.0f);
|
||||||
|
|
||||||
color = ColorLerp((Color){ (int)(value*255.0f), (int)(value*255.0f), (int)(value*255.0f), 255 }, ColorFromHSV(angle360, Clamp(distance, 0.0f, 1.0f), 1.0f), valueActual);
|
color = ColorLerp((Color){ (int)(value*255.0f), (int)(value*255.0f), (int)(value*255.0f), 255 }, ColorFromHSV(angle360, Clamp(distance, 0.0f, 1.0f), 1.0f), valueActual);
|
||||||
}
|
}
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|||||||
@ -95,7 +95,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i <= emissionRate; ++i) EmitParticle(&circularBuffer, emitterPosition, currentType);
|
for (int i = 0; i <= emissionRate; i++) EmitParticle(&circularBuffer, emitterPosition, currentType);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the parameters of each particle
|
// Update the parameters of each particle
|
||||||
|
|||||||
@ -34,7 +34,7 @@ int main(void)
|
|||||||
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - triangle strip");
|
InitWindow(screenWidth, screenHeight, "raylib [shapes] example - triangle strip");
|
||||||
|
|
||||||
Vector2 points[122] = { 0 };
|
Vector2 points[122] = { 0 };
|
||||||
Vector2 center = { (screenWidth/2.0f) - 125.f, screenHeight/2.0f };
|
Vector2 center = { (screenWidth/2.0f) - 125.0f, screenHeight/2.0f };
|
||||||
float segments = 6.0f;
|
float segments = 6.0f;
|
||||||
float insideRadius = 100.0f;
|
float insideRadius = 100.0f;
|
||||||
float outsideRadius = 150.0f;
|
float outsideRadius = 150.0f;
|
||||||
@ -92,7 +92,7 @@ int main(void)
|
|||||||
|
|
||||||
// Draw GUI controls
|
// Draw GUI controls
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
GuiSliderBar((Rectangle){ 640, 40, 120, 20}, "Segments", TextFormat("%.0f", segments), &segments, 6.0f, 60.f);
|
GuiSliderBar((Rectangle){ 640, 40, 120, 20}, "Segments", TextFormat("%.0f", segments), &segments, 6.0f, 60.0f);
|
||||||
GuiCheckBox((Rectangle){ 640, 70, 20, 20 }, "Outline", &outline);
|
GuiCheckBox((Rectangle){ 640, 70, 20, 20 }, "Outline", &outline);
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -231,7 +231,7 @@ int main(void)
|
|||||||
if (multicolor)
|
if (multicolor)
|
||||||
{
|
{
|
||||||
// Fill color array with random colors
|
// Fill color array with random colors
|
||||||
for (int i = 0; i < TEXT_MAX_LAYERS; ++i)
|
for (int i = 0; i < TEXT_MAX_LAYERS; i++)
|
||||||
{
|
{
|
||||||
multi[i] = GenerateRandomColor(0.5f, 0.8f);
|
multi[i] = GenerateRandomColor(0.5f, 0.8f);
|
||||||
multi[i].a = GetRandomValue(0, 255);
|
multi[i].a = GetRandomValue(0, 255);
|
||||||
@ -296,7 +296,7 @@ int main(void)
|
|||||||
rlRotatef(90.0f, 1.0f, 0.0f, 0.0f);
|
rlRotatef(90.0f, 1.0f, 0.0f, 0.0f);
|
||||||
rlRotatef(90.0f, 0.0f, 0.0f, -1.0f);
|
rlRotatef(90.0f, 0.0f, 0.0f, -1.0f);
|
||||||
|
|
||||||
for (int i = 0; i < layers; ++i)
|
for (int i = 0; i < layers; i++)
|
||||||
{
|
{
|
||||||
Color clr = light;
|
Color clr = light;
|
||||||
if (multicolor) clr = multi[i];
|
if (multicolor) clr = multi[i];
|
||||||
|
|||||||
@ -210,7 +210,7 @@ int main(void)
|
|||||||
|
|
||||||
// Draw random emojis in the background
|
// Draw random emojis in the background
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
for (int i = 0; i < SIZEOF(emoji); ++i)
|
for (int i = 0; i < SIZEOF(emoji); i++)
|
||||||
{
|
{
|
||||||
const char *txt = &emojiCodepoints[emoji[i].index];
|
const char *txt = &emojiCodepoints[emoji[i].index];
|
||||||
Rectangle emojiRect = { position.x, position.y, (float)fontEmoji.baseSize, (float)fontEmoji.baseSize };
|
Rectangle emojiRect = { position.x, position.y, (float)fontEmoji.baseSize, (float)fontEmoji.baseSize };
|
||||||
@ -316,7 +316,7 @@ static void RandomizeEmoji(void)
|
|||||||
hovered = selected = -1;
|
hovered = selected = -1;
|
||||||
int start = GetRandomValue(45, 360);
|
int start = GetRandomValue(45, 360);
|
||||||
|
|
||||||
for (int i = 0; i < SIZEOF(emoji); ++i)
|
for (int i = 0; i < SIZEOF(emoji); i++)
|
||||||
{
|
{
|
||||||
// 0-179 emoji codepoints (from emoji char array) each 4bytes + null char
|
// 0-179 emoji codepoints (from emoji char array) each 4bytes + null char
|
||||||
emoji[i].index = GetRandomValue(0, 179)*5;
|
emoji[i].index = GetRandomValue(0, 179)*5;
|
||||||
|
|||||||
@ -70,27 +70,32 @@ int main(void)
|
|||||||
{
|
{
|
||||||
// Update
|
// Update
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
if (IsKeyPressed(KEY_LEFT))
|
||||||
if (IsKeyPressed(KEY_LEFT)) {
|
{
|
||||||
hAlign = hAlign - 1;
|
hAlign = hAlign - 1;
|
||||||
if (hAlign < 0) hAlign = 0;
|
if (hAlign < 0) hAlign = 0;
|
||||||
}
|
}
|
||||||
if (IsKeyPressed(KEY_RIGHT)) {
|
|
||||||
|
if (IsKeyPressed(KEY_RIGHT))
|
||||||
|
{
|
||||||
hAlign = hAlign + 1;
|
hAlign = hAlign + 1;
|
||||||
if (hAlign > 2) hAlign = 2;
|
if (hAlign > 2) hAlign = 2;
|
||||||
}
|
}
|
||||||
if (IsKeyPressed(KEY_UP)) {
|
|
||||||
|
if (IsKeyPressed(KEY_UP))
|
||||||
|
{
|
||||||
vAlign = vAlign - 1;
|
vAlign = vAlign - 1;
|
||||||
if (vAlign < 0) vAlign = 0;
|
if (vAlign < 0) vAlign = 0;
|
||||||
}
|
}
|
||||||
if (IsKeyPressed(KEY_DOWN)) {
|
|
||||||
|
if (IsKeyPressed(KEY_DOWN))
|
||||||
|
{
|
||||||
vAlign = vAlign + 1;
|
vAlign = vAlign + 1;
|
||||||
if (vAlign > 2) vAlign = 2;
|
if (vAlign > 2) vAlign = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// One word per second
|
// One word per second
|
||||||
wordIndex = (int)GetTime()%wordCount;
|
wordIndex = (int)GetTime()%wordCount;
|
||||||
|
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|||||||
@ -100,7 +100,7 @@ int main(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check to see which color was clicked and set it as the active color
|
// Check to see which color was clicked and set it as the active color
|
||||||
for (int i = 0; i < MAX_COLORS; ++i)
|
for (int i = 0; i < MAX_COLORS; i++)
|
||||||
{
|
{
|
||||||
if (CheckCollisionPointRec(mouse, colorRec[i]))
|
if (CheckCollisionPointRec(mouse, colorRec[i]))
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user