summaryrefslogtreecommitdiffhomepage
path: root/examples/shaders
diff options
context:
space:
mode:
authorRay <[email protected]>2023-02-14 20:00:51 +0100
committerRay <[email protected]>2023-02-14 20:00:51 +0100
commitea590c44a967075b3f6b420fa76e6387075ecf1d (patch)
treeb456de45fef83507415dcc309c05e64cb9232946 /examples/shaders
parent73989a49817225f11f547d270598e93745bf7df0 (diff)
downloadraylib-ea590c44a967075b3f6b420fa76e6387075ecf1d.tar.gz
raylib-ea590c44a967075b3f6b420fa76e6387075ecf1d.zip
REVIEWED: Camera redesign PR
Diffstat (limited to 'examples/shaders')
-rw-r--r--examples/shaders/shaders_basic_lighting.c8
-rw-r--r--examples/shaders/shaders_custom_uniform.c11
-rw-r--r--examples/shaders/shaders_fog.c17
-rw-r--r--examples/shaders/shaders_mesh_instancing.c16
-rw-r--r--examples/shaders/shaders_model_shader.c16
-rw-r--r--examples/shaders/shaders_postprocessing.c17
-rw-r--r--examples/shaders/shaders_raymarching.c7
-rw-r--r--examples/shaders/shaders_simple_mask.c26
-rw-r--r--examples/shaders/shaders_spotlight.c79
9 files changed, 100 insertions, 97 deletions
diff --git a/examples/shaders/shaders_basic_lighting.c b/examples/shaders/shaders_basic_lighting.c
index 702177f1..49dc1e7d 100644
--- a/examples/shaders/shaders_basic_lighting.c
+++ b/examples/shaders/shaders_basic_lighting.c
@@ -50,7 +50,7 @@ int main(void)
camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
- camera.projection = CAMERA_PERSPECTIVE; // Camera mode type
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Load plane model from a generated mesh
Model model = LoadModelFromMesh(GenMeshPlane(10.0f, 10.0f, 3, 3));
@@ -80,12 +80,12 @@ int main(void)
lights[2] = CreateLight(LIGHT_POINT, (Vector3){ -2, 1, 2 }, Vector3Zero(), GREEN, shader);
lights[3] = CreateLight(LIGHT_POINT, (Vector3){ 2, 1, -2 }, Vector3Zero(), BLUE, shader);
- DisableCursor(); // Catch cursor
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ DisableCursor(); // Limit cursor to relative movement inside the window
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_custom_uniform.c b/examples/shaders/shaders_custom_uniform.c
index c617a6d1..eaeca5e5 100644
--- a/examples/shaders/shaders_custom_uniform.c
+++ b/examples/shaders/shaders_custom_uniform.c
@@ -42,11 +42,11 @@ int main(void)
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 8.0f, 8.0f, 8.0f };
- camera.target = (Vector3){ 0.0f, 1.5f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ 8.0f, 8.0f, 8.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 1.5f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Model model = LoadModel("resources/models/barracks.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/barracks_diffuse.png"); // Load model texture (diffuse map)
@@ -67,7 +67,6 @@ int main(void)
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
- DisableCursor(); // Catch cursor
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_fog.c b/examples/shaders/shaders_fog.c
index c4b619ed..ddd721d4 100644
--- a/examples/shaders/shaders_fog.c
+++ b/examples/shaders/shaders_fog.c
@@ -45,11 +45,12 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - fog");
// Define the camera to look into our 3d world
- Camera camera = {
- (Vector3){ 2.0f, 2.0f, 6.0f }, // position
- (Vector3){ 0.0f, 0.5f, 0.0f }, // target
- (Vector3){ 0.0f, 1.0f, 0.0f }, // up
- 45.0f, CAMERA_PERSPECTIVE }; // fov, type
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 2.0f, 2.0f, 6.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.5f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Load models and texture
Model modelA = LoadModelFromMesh(GenMeshTorus(0.4f, 1.0f, 16, 32));
@@ -84,12 +85,12 @@ int main(void)
// Using just 1 point lights
CreateLight(LIGHT_POINT, (Vector3){ 0, 2, 6 }, Vector3Zero(), WHITE, shader);
- DisableCursor(); // Catch cursor
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ DisableCursor(); // Limit cursor to relative movement inside the window
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_mesh_instancing.c b/examples/shaders/shaders_mesh_instancing.c
index 0c2f9e1d..02a7ee8f 100644
--- a/examples/shaders/shaders_mesh_instancing.c
+++ b/examples/shaders/shaders_mesh_instancing.c
@@ -44,11 +44,11 @@ int main(void)
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ -125.0f, 125.0f, -125.0f };
- camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ -125.0f, 125.0f, -125.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Define mesh to be instanced
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
@@ -94,12 +94,12 @@ int main(void)
Material matDefault = LoadMaterialDefault();
matDefault.maps[MATERIAL_MAP_DIFFUSE].color = BLUE;
- DisableCursor(); // Catch cursor
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ DisableCursor(); // Limit cursor to relative movement inside the window
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_model_shader.c b/examples/shaders/shaders_model_shader.c
index 069d0ee2..e84ecbfb 100644
--- a/examples/shaders/shaders_model_shader.c
+++ b/examples/shaders/shaders_model_shader.c
@@ -42,11 +42,11 @@ int main(void)
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 4.0f, 4.0f, 4.0f };
- camera.target = (Vector3){ 0.0f, 1.0f, -1.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ 4.0f, 4.0f, 4.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 1.0f, -1.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Model model = LoadModel("resources/models/watermill.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/watermill_diffuse.png"); // Load model texture
@@ -60,12 +60,12 @@ int main(void)
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
- DisableCursor(); // Catch cursor
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ DisableCursor(); // Limit cursor to relative movement inside the window
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_postprocessing.c b/examples/shaders/shaders_postprocessing.c
index 688ca909..991e9839 100644
--- a/examples/shaders/shaders_postprocessing.c
+++ b/examples/shaders/shaders_postprocessing.c
@@ -75,13 +75,18 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
// Define the camera to look into our 3d world
- Camera camera = { { 2.0f, 3.0f, 2.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
+ Camera camera = { 0 };
+ camera.position = (Vector3){ 2.0f, 3.0f, 2.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
Model model = LoadModel("resources/models/church.obj"); // Load OBJ model
Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map)
- model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
+ model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set model diffuse texture
- Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
+ Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
// Load all postpro shaders
// NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER)
@@ -107,12 +112,12 @@ int main(void)
// Create a RenderTexture2D to be used for render to texture
RenderTexture2D target = LoadRenderTexture(screenWidth, screenHeight);
- DisableCursor(); // Catch cursor
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ DisableCursor(); // Limit cursor to relative movement inside the window
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_raymarching.c b/examples/shaders/shaders_raymarching.c
index 5cc9af05..7b34a523 100644
--- a/examples/shaders/shaders_raymarching.c
+++ b/examples/shaders/shaders_raymarching.c
@@ -40,6 +40,7 @@ int main(void)
camera.target = (Vector3){ 0.0f, 0.0f, 0.7f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 65.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Load raymarching shader
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
@@ -56,12 +57,12 @@ int main(void)
float runTime = 0.0f;
- DisableCursor(); // Catch cursor
- SetTargetFPS(60); // Set our game to run at 60 frames-per-second
+ DisableCursor(); // Limit cursor to relative movement inside the window
+ SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
diff --git a/examples/shaders/shaders_simple_mask.c b/examples/shaders/shaders_simple_mask.c
index 49470294..6283ccbc 100644
--- a/examples/shaders/shaders_simple_mask.c
+++ b/examples/shaders/shaders_simple_mask.c
@@ -39,15 +39,15 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib - simple shader mask");
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - simple shader mask");
// Define the camera to look into our 3d world
Camera camera = { 0 };
- camera.position = (Vector3){ 0.0f, 1.0f, 2.0f };
- camera.target = (Vector3){ 0.0f, 0.0f, 0.0f };
- camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
- camera.fovy = 45.0f;
- camera.projection = CAMERA_PERSPECTIVE;
+ camera.position = (Vector3){ 0.0f, 1.0f, 2.0f }; // Camera position
+ camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
+ camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
+ camera.fovy = 45.0f; // Camera field-of-view Y
+ camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Define our three models to show the shader on
Mesh torus = GenMeshTorus(0.3f, 1, 16, 32);
@@ -83,14 +83,14 @@ int main(void)
model2.materials[0].shader = shader;
int framesCounter = 0;
- Vector3 rotation = { 0 }; // Model rotation angles
+ Vector3 rotation = { 0 }; // Model rotation angles
- DisableCursor(); // Catch cursor
- SetTargetFPS(60); // Set to run at 60 frames-per-second
+ DisableCursor(); // Limit cursor to relative movement inside the window
+ SetTargetFPS(60); // Set to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
- while (!WindowShouldClose()) // Detect window close button or ESC key
+ while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
@@ -116,9 +116,9 @@ int main(void)
BeginMode3D(camera);
- DrawModel(model1, (Vector3){0.5,0,0}, 1, WHITE);
- DrawModelEx(model2, (Vector3){-.5,0,0}, (Vector3){1,1,0}, 50, (Vector3){1,1,1}, WHITE);
- DrawModel(model3,(Vector3){0,0,-1.5}, 1, WHITE);
+ DrawModel(model1, (Vector3){ 0.5f, 0.0f, 0.0f }, 1, WHITE);
+ DrawModelEx(model2, (Vector3){ -0.5f, 0.0f, 0.0f }, (Vector3){ 1.0f, 1.0f, 0.0f }, 50, (Vector3){ 1.0f, 1.0f, 1.0f }, WHITE);
+ DrawModel(model3,(Vector3){ 0.0f, 0.0f, -1.5f }, 1, WHITE);
DrawGrid(10, 1.0f); // Draw a grid
EndMode3D();
diff --git a/examples/shaders/shaders_spotlight.c b/examples/shaders/shaders_spotlight.c
index a21e3c82..c96c983d 100644
--- a/examples/shaders/shaders_spotlight.c
+++ b/examples/shaders/shaders_spotlight.c
@@ -29,10 +29,8 @@
********************************************************************************************/
#include "raylib.h"
-#include "raymath.h"
-#include <stddef.h>
-#include <stdint.h>
+#include "raymath.h"
#if defined(PLATFORM_DESKTOP)
#define GLSL_VERSION 330
@@ -44,26 +42,26 @@
#define MAX_STARS 400
// Spot data
-typedef struct {
- Vector2 pos;
- Vector2 vel;
+typedef struct Spot {
+ Vector2 position;
+ Vector2 speed;
float inner;
float radius;
// Shader locations
- unsigned int posLoc;
+ unsigned int positionLoc;
unsigned int innerLoc;
unsigned int radiusLoc;
} Spot;
// Stars in the star field have a position and velocity
typedef struct Star {
- Vector2 pos;
- Vector2 vel;
+ Vector2 position;
+ Vector2 speed;
} Star;
-void UpdateStar(Star *s);
-void ResetStar(Star *s);
+static void UpdateStar(Star *s);
+static void ResetStar(Star *s);
//------------------------------------------------------------------------------------
// Program main entry point
@@ -75,7 +73,7 @@ int main(void)
const int screenWidth = 800;
const int screenHeight = 450;
- InitWindow(screenWidth, screenHeight, "raylib - shader spotlight");
+ InitWindow(screenWidth, screenHeight, "raylib [shaders] example - shader spotlight");
HideCursor();
Texture texRay = LoadTexture("resources/raysan.png");
@@ -108,7 +106,7 @@ int main(void)
innerName[6] = '0' + i;
radiusName[6] = '0' + i;
- spots[i].posLoc = GetShaderLocation(shdrSpot, posName);
+ spots[i].positionLoc = GetShaderLocation(shdrSpot, posName);
spots[i].innerLoc = GetShaderLocation(shdrSpot, innerName);
spots[i].radiusLoc = GetShaderLocation(shdrSpot, radiusName);
@@ -124,20 +122,20 @@ int main(void)
// and initialize the shader locations
for (int i = 0; i < MAX_SPOTS; i++)
{
- spots[i].pos.x = (float)GetRandomValue(64, screenWidth - 64);
- spots[i].pos.y = (float)GetRandomValue(64, screenHeight - 64);
- spots[i].vel = (Vector2){ 0, 0 };
+ spots[i].position.x = (float)GetRandomValue(64, screenWidth - 64);
+ spots[i].position.y = (float)GetRandomValue(64, screenHeight - 64);
+ spots[i].speed = (Vector2){ 0, 0 };
- while ((fabs(spots[i].vel.x) + fabs(spots[i].vel.y)) < 2)
+ while ((fabs(spots[i].speed.x) + fabs(spots[i].speed.y)) < 2)
{
- spots[i].vel.x = GetRandomValue(-400, 40) / 10.0f;
- spots[i].vel.y = GetRandomValue(-400, 40) / 10.0f;
+ spots[i].speed.x = GetRandomValue(-400, 40) / 10.0f;
+ spots[i].speed.y = GetRandomValue(-400, 40) / 10.0f;
}
spots[i].inner = 28.0f * (i + 1);
spots[i].radius = 48.0f * (i + 1);
- SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
+ SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
SetShaderValue(shdrSpot, spots[i].innerLoc, &spots[i].inner, SHADER_UNIFORM_FLOAT);
SetShaderValue(shdrSpot, spots[i].radiusLoc, &spots[i].radius, SHADER_UNIFORM_FLOAT);
}
@@ -161,21 +159,21 @@ int main(void)
if (i == 0)
{
Vector2 mp = GetMousePosition();
- spots[i].pos.x = mp.x;
- spots[i].pos.y = screenHeight - mp.y;
+ spots[i].position.x = mp.x;
+ spots[i].position.y = screenHeight - mp.y;
}
else
{
- spots[i].pos.x += spots[i].vel.x;
- spots[i].pos.y += spots[i].vel.y;
+ spots[i].position.x += spots[i].speed.x;
+ spots[i].position.y += spots[i].speed.y;
- if (spots[i].pos.x < 64) spots[i].vel.x = -spots[i].vel.x;
- if (spots[i].pos.x > (screenWidth - 64)) spots[i].vel.x = -spots[i].vel.x;
- if (spots[i].pos.y < 64) spots[i].vel.y = -spots[i].vel.y;
- if (spots[i].pos.y > (screenHeight - 64)) spots[i].vel.y = -spots[i].vel.y;
+ if (spots[i].position.x < 64) spots[i].speed.x = -spots[i].speed.x;
+ if (spots[i].position.x > (screenWidth - 64)) spots[i].speed.x = -spots[i].speed.x;
+ if (spots[i].position.y < 64) spots[i].speed.y = -spots[i].speed.y;
+ if (spots[i].position.y > (screenHeight - 64)) spots[i].speed.y = -spots[i].speed.y;
}
- SetShaderValue(shdrSpot, spots[i].posLoc, &spots[i].pos.x, SHADER_UNIFORM_VEC2);
+ SetShaderValue(shdrSpot, spots[i].positionLoc, &spots[i].position.x, SHADER_UNIFORM_VEC2);
}
// Draw
@@ -188,7 +186,7 @@ int main(void)
for (int n = 0; n < MAX_STARS; n++)
{
// Single pixel is just too small these days!
- DrawRectangle((int)stars[n].pos.x, (int)stars[n].pos.y, 2, 2, WHITE);
+ DrawRectangle((int)stars[n].position.x, (int)stars[n].position.y, 2, 2, WHITE);
}
for (int i = 0; i < 16; i++)
@@ -213,7 +211,6 @@ int main(void)
DrawText("Pitch Black", (int)(screenWidth*0.2f), screenHeight/2, 20, GREEN);
DrawText("Dark", (int)(screenWidth*.66f), screenHeight/2, 20, GREEN);
-
EndDrawing();
//----------------------------------------------------------------------------------
}
@@ -230,26 +227,26 @@ int main(void)
}
-void ResetStar(Star *s)
+static void ResetStar(Star *s)
{
- s->pos = (Vector2){ GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
+ s->position = (Vector2){ GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
do
{
- s->vel.x = (float)GetRandomValue(-1000, 1000)/100.0f;
- s->vel.y = (float)GetRandomValue(-1000, 1000)/100.0f;
+ s->speed.x = (float)GetRandomValue(-1000, 1000)/100.0f;
+ s->speed.y = (float)GetRandomValue(-1000, 1000)/100.0f;
- } while (!(fabs(s->vel.x) + (fabs(s->vel.y) > 1)));
+ } while (!(fabs(s->speed.x) + (fabs(s->speed.y) > 1)));
- s->pos = Vector2Add(s->pos, Vector2Multiply(s->vel, (Vector2){ 8.0f, 8.0f }));
+ s->position = Vector2Add(s->position, Vector2Multiply(s->speed, (Vector2){ 8.0f, 8.0f }));
}
-void UpdateStar(Star *s)
+static void UpdateStar(Star *s)
{
- s->pos = Vector2Add(s->pos, s->vel);
+ s->position = Vector2Add(s->position, s->speed);
- if ((s->pos.x < 0) || (s->pos.x > GetScreenWidth()) ||
- (s->pos.y < 0) || (s->pos.y > GetScreenHeight()))
+ if ((s->position.x < 0) || (s->position.x > GetScreenWidth()) ||
+ (s->position.y < 0) || (s->position.y > GetScreenHeight()))
{
ResetStar(s);
}