Remove trail spaces

This commit is contained in:
Ray 2021-04-22 18:55:24 +02:00
parent f92ee46d86
commit dcf52c132f
61 changed files with 565 additions and 565 deletions

View file

@ -32,12 +32,12 @@ int main(void)
Texture2D fgTexture = LoadTextureFromImage(fgImage); // Image converted to texture, GPU memory (VRAM)
// Once image has been converted to texture and uploaded to VRAM, it can be unloaded from RAM
UnloadImage(bgImage);
UnloadImage(bgImage);
UnloadImage(fgImage);
const int blendCountMax = 4;
BlendMode blendMode = 0;
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
@ -49,7 +49,7 @@ int main(void)
else blendMode++;
}
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
@ -65,7 +65,7 @@ int main(void)
// Draw the texts
DrawText("Press SPACE to change blend modes.", 310, 350, 10, GRAY);
switch (blendMode)
{
case BLEND_ALPHA: DrawText("Current: BLEND_ALPHA", (screenWidth / 2) - 60, 370, 10, GRAY); break;
@ -74,7 +74,7 @@ int main(void)
case BLEND_ADD_COLORS: DrawText("Current: BLEND_ADD_COLORS", (screenWidth / 2) - 60, 370, 10, GRAY); break;
default: break;
}
DrawText("(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)", screenWidth - 330, screenHeight - 20, 10, GRAY);
EndDrawing();
@ -88,6 +88,6 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View file

@ -21,24 +21,24 @@ int main(int argc, char **argv)
//--------------------------------------------------------------------------------------
int screenWidth = 800;
int screenHeight = 450;
SetConfigFlags(FLAG_WINDOW_RESIZABLE); // Make the window resizable
InitWindow(screenWidth, screenHeight, "raylib [textures] example - Draw part of a texture tiled");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture texPattern = LoadTexture("resources/patterns.png");
SetTextureFilter(texPattern, TEXTURE_FILTER_TRILINEAR); // Makes the texture smoother when upscaled
// Coordinates for all patterns inside the texture
const Rectangle recPattern[] = {
(Rectangle){ 3, 3, 66, 66 },
(Rectangle){ 75, 3, 100, 100 },
const Rectangle recPattern[] = {
(Rectangle){ 3, 3, 66, 66 },
(Rectangle){ 75, 3, 100, 100 },
(Rectangle){ 3, 75, 66, 66 },
(Rectangle){ 7, 156, 50, 50 },
(Rectangle){ 85, 106, 90, 45 },
(Rectangle){ 75, 154, 100, 60}
};
// Setup colors
const Color colors[] = { BLACK, MAROON, ORANGE, BLUE, PURPLE, BEIGE, LIME, RED, DARKGRAY, SKYBLUE };
enum { MAX_COLORS = SIZEOF(colors) };
@ -51,21 +51,21 @@ int main(int argc, char **argv)
colorRec[i].y = 22.0f + 256.0f + MARGIN_SIZE + y;
colorRec[i].width = COLOR_SIZE*2.0f;
colorRec[i].height = (float)COLOR_SIZE;
if (i == (MAX_COLORS/2 - 1))
{
x = 0;
x = 0;
y += COLOR_SIZE + MARGIN_SIZE;
}
}
else x += (COLOR_SIZE*2 + MARGIN_SIZE);
}
int activePattern = 0, activeCol = 0;
float scale = 1.0f, rotation = 0.0f;
SetTargetFPS(60);
//---------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
@ -73,22 +73,22 @@ int main(int argc, char **argv)
//----------------------------------------------------------------------------------
screenWidth = GetScreenWidth();
screenHeight = GetScreenHeight();
// Handle mouse
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
const Vector2 mouse = GetMousePosition();
// Check which pattern was clicked and set it as the active pattern
for (int i = 0; i < SIZEOF(recPattern); i++)
{
if (CheckCollisionPointRec(mouse, (Rectangle){ 2 + MARGIN_SIZE + recPattern[i].x, 40 + MARGIN_SIZE + recPattern[i].y, recPattern[i].width, recPattern[i].height }))
{
activePattern = i;
break;
{
activePattern = i;
break;
}
}
// Check to see which color was clicked and set it as the active color
for (int i = 0; i < MAX_COLORS; ++i)
{
@ -99,67 +99,67 @@ int main(int argc, char **argv)
}
}
}
// Handle keys
// Change scale
if (IsKeyPressed(KEY_UP)) scale += 0.25f;
if (IsKeyPressed(KEY_DOWN)) scale -= 0.25f;
if (scale > 10.0f) scale = 10.0f;
else if ( scale <= 0.0f) scale = 0.25f;
// Change rotation
if (IsKeyPressed(KEY_LEFT)) rotation -= 25.0f;
if (IsKeyPressed(KEY_RIGHT)) rotation += 25.0f;
// Reset
if (IsKeyPressed(KEY_SPACE)) { rotation = 0.0f; scale = 1.0f; }
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Draw the tiled area
DrawTextureTiled(texPattern, recPattern[activePattern], (Rectangle){(float)OPT_WIDTH+MARGIN_SIZE, (float)MARGIN_SIZE, screenWidth - OPT_WIDTH - 2.0f*MARGIN_SIZE, screenHeight - 2.0f*MARGIN_SIZE},
(Vector2){0.0f, 0.0f}, rotation, scale, colors[activeCol]);
// Draw options
DrawRectangle(MARGIN_SIZE, MARGIN_SIZE, OPT_WIDTH - MARGIN_SIZE, screenHeight - 2*MARGIN_SIZE, ColorAlpha(LIGHTGRAY, 0.5f));
DrawText("Select Pattern", 2 + MARGIN_SIZE, 30 + MARGIN_SIZE, 10, BLACK);
DrawTexture(texPattern, 2 + MARGIN_SIZE, 40 + MARGIN_SIZE, BLACK);
DrawRectangle(2 + MARGIN_SIZE + (int)recPattern[activePattern].x, 40 + MARGIN_SIZE + (int)recPattern[activePattern].y, (int)recPattern[activePattern].width, (int)recPattern[activePattern].height, ColorAlpha(DARKBLUE, 0.3f));
DrawText("Select Color", 2+MARGIN_SIZE, 10+256+MARGIN_SIZE, 10, BLACK);
for (int i = 0; i < MAX_COLORS; i++)
{
DrawRectangleRec(colorRec[i], colors[i]);
if (activeCol == i) DrawRectangleLinesEx(colorRec[i], 3, ColorAlpha(WHITE, 0.5f));
}
DrawText("Scale (UP/DOWN to change)", 2 + MARGIN_SIZE, 80 + 256 + MARGIN_SIZE, 10, BLACK);
DrawText(TextFormat("%.2fx", scale), 2 + MARGIN_SIZE, 92 + 256 + MARGIN_SIZE, 20, BLACK);
DrawText("Rotation (LEFT/RIGHT to change)", 2 + MARGIN_SIZE, 122 + 256 + MARGIN_SIZE, 10, BLACK);
DrawText(TextFormat("%.0f degrees", rotation), 2 + MARGIN_SIZE, 134 + 256 + MARGIN_SIZE, 20, BLACK);
DrawText("Press [SPACE] to reset", 2 + MARGIN_SIZE, 164 + 256 + MARGIN_SIZE, 10, DARKBLUE);
// Draw FPS
DrawText(TextFormat("%i FPS", GetFPS()), 2 + MARGIN_SIZE, 2 + MARGIN_SIZE, 20, BLACK);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texPattern); // Unload texture
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}

View file

@ -53,7 +53,7 @@ int main(void)
Image imOrigin = LoadImage("resources/parrots.png"); // Loaded in CPU memory (RAM)
ImageFormat(&imOrigin, PIXELFORMAT_UNCOMPRESSED_R8G8B8A8); // Format image to RGBA 32bit (required for texture update) <-- ISSUE
Texture2D texture = LoadTextureFromImage(imOrigin); // Image converted to texture, GPU memory (VRAM)
Image imCopy = ImageCopy(imOrigin);
int currentProcess = NONE;
@ -72,7 +72,7 @@ int main(void)
{
// Update
//----------------------------------------------------------------------------------
// Mouse toggle group logic
for (int i = 0; i < NUM_PROCESSES; i++)
{
@ -89,7 +89,7 @@ int main(void)
}
else mouseHoverRec = -1;
}
// Keyboard toggle group logic
if (IsKeyPressed(KEY_DOWN))
{
@ -109,7 +109,7 @@ int main(void)
{
UnloadImage(imCopy); // Unload image-copy data
imCopy = ImageCopy(imOrigin); // Restore image-copy from image-origin
// NOTE: Image processing is a costly CPU process to be done every frame,
// If image processing is required in a frame-basis, it should be done
// with a texture and by shaders

View file

@ -19,7 +19,7 @@ int main(void)
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [texture] example - image text drawing");
Image parrots = LoadImage("resources/parrots.png"); // Load image in CPU memory (RAM)
// TTF Font loading with custom generation parameters

View file

@ -5,7 +5,7 @@
* This example has been created using raylib 3.7 (www.raylib.com)
* raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details)
*
* Example contributed by Chris Camacho (@codifies - bedroomcoders.co.uk) and
* Example contributed by Chris Camacho (@codifies - bedroomcoders.co.uk) and
* reviewed by Ramon Santamaria (@raysan5)
*
* Copyright (c) 2021 Chris Camacho (@codifies) and Ramon Santamaria (@raysan5)
@ -52,7 +52,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [textures] example - textured polygon");
Texture texture = LoadTexture("resources/cat.png");
float ang = 0;
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
@ -64,9 +64,9 @@ int main(void)
// Update
//----------------------------------------------------------------------------------
ang++;
Vector2 positions[MAX_POINTS] = { 0 };
for (int i = 0; i < MAX_POINTS; i++) positions[i] = Vector2Rotate(points[i], ang);
//----------------------------------------------------------------------------------
@ -77,8 +77,8 @@ int main(void)
ClearBackground(RAYWHITE);
DrawText("textured polygon", 20, 20, 20, DARKGRAY);
DrawTexturePoly(texture, (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 },
DrawTexturePoly(texture, (Vector2){ GetScreenWidth()/2, GetScreenHeight()/2 },
positions, texcoords, MAX_POINTS, WHITE);
EndDrawing();
@ -88,7 +88,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadTexture(texture); // Unload texture
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------

View file

@ -54,8 +54,8 @@ int main(void)
.height = height,
.format = PIXELFORMAT_UNCOMPRESSED_R8G8B8A8,
.mipmaps = 1
};
};
Texture2D checked = LoadTextureFromImage(checkedIm);
UnloadImage(checkedIm); // Unload CPU (RAM) image data (pixels)
//---------------------------------------------------------------------------------------

View file

@ -30,7 +30,7 @@ int main(void)
// Load explosion texture
Texture2D explosion = LoadTexture("resources/explosion.png");
// Init variables for animation
int frameWidth = explosion.width/NUM_FRAMES_PER_LINE; // Sprite one frame rectangle width
int frameHeight = explosion.height/NUM_LINES; // Sprite one frame rectangle height

View file

@ -21,7 +21,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [textures] examples - texture source and destination rectangles");
// NOTE: Textures MUST be loaded after Window initialization (OpenGL context is required)
Texture2D scarfy = LoadTexture("resources/scarfy.png"); // Texture loading
int frameWidth = scarfy.width/6;