Review variables initialization
This commit is contained in:
parent
241c4c8d14
commit
87774a0a21
33 changed files with 52 additions and 56 deletions
|
|
@ -40,7 +40,7 @@ int main(void)
|
||||||
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
|
YELLOW, GREEN, SKYBLUE, PURPLE, BEIGE };
|
||||||
|
|
||||||
// Creates ome circles for visual effect
|
// Creates ome circles for visual effect
|
||||||
CircleWave circles[MAX_CIRCLES];
|
CircleWave circles[MAX_CIRCLES] = { 0 };
|
||||||
|
|
||||||
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
for (int i = MAX_CIRCLES - 1; i >= 0; i--)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,6 @@ int main(void)
|
||||||
ClearBackground(RAYWHITE);
|
ClearBackground(RAYWHITE);
|
||||||
|
|
||||||
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY);
|
DrawText("Press SPACE to PLAY the WAV sound!", 200, 180, 20, LIGHTGRAY);
|
||||||
|
|
||||||
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY);
|
DrawText("Press ENTER to PLAY the OGG sound!", 200, 220, 20, LIGHTGRAY);
|
||||||
|
|
||||||
EndDrawing();
|
EndDrawing();
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 2d camera");
|
||||||
|
|
||||||
Rectangle player = { 400, 280, 40, 40 };
|
Rectangle player = { 400, 280, 40, 40 };
|
||||||
Rectangle buildings[MAX_BUILDINGS];
|
Rectangle buildings[MAX_BUILDINGS] = { 0 };
|
||||||
Color buildColors[MAX_BUILDINGS];
|
Color buildColors[MAX_BUILDINGS] = { 0 };
|
||||||
|
|
||||||
int spacing = 0;
|
int spacing = 0;
|
||||||
|
|
||||||
|
|
@ -41,7 +41,6 @@ int main(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
Camera2D camera = { 0 };
|
Camera2D camera = { 0 };
|
||||||
|
|
||||||
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
camera.target = (Vector2){ player.x + 20, player.y + 20 };
|
||||||
camera.offset = (Vector2){ 0, 0 };
|
camera.offset = (Vector2){ 0, 0 };
|
||||||
camera.rotation = 0.0f;
|
camera.rotation = 0.0f;
|
||||||
|
|
|
||||||
|
|
@ -31,9 +31,9 @@ int main(void)
|
||||||
camera.type = CAMERA_PERSPECTIVE;
|
camera.type = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
// Generates some random columns
|
// Generates some random columns
|
||||||
float heights[MAX_COLUMNS];
|
float heights[MAX_COLUMNS] = { 0.0f };
|
||||||
Vector3 positions[MAX_COLUMNS];
|
Vector3 positions[MAX_COLUMNS] = { 0 };
|
||||||
Color colors[MAX_COLUMNS];
|
Color colors[MAX_COLUMNS] = { 0 };
|
||||||
|
|
||||||
for (int i = 0; i < MAX_COLUMNS; i++)
|
for (int i = 0; i < MAX_COLUMNS; i++)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
|
InitWindow(screenWidth, screenHeight, "raylib [core] example - 3d camera free");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera3D camera;
|
Camera3D camera = { 0 };
|
||||||
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
camera.position = (Vector3){ 10.0f, 10.0f, 10.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
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.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@
|
||||||
// Custom logging funtion
|
// Custom logging funtion
|
||||||
void LogCustom(int msgType, const char *text, va_list args)
|
void LogCustom(int msgType, const char *text, va_list args)
|
||||||
{
|
{
|
||||||
char timeStr[64];
|
char timeStr[64] = { 0 };
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm *tm_info = localtime(&now);
|
struct tm *tm_info = localtime(&now);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,7 @@ int main(void)
|
||||||
SetVrConfiguration(hmd, distortion); // Set Vr device parameters for stereo rendering
|
SetVrConfiguration(hmd, distortion); // Set Vr device parameters for stereo rendering
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera;
|
Camera camera = { 0 };
|
||||||
camera.position = (Vector3){ 5.0f, 2.0f, 5.0f }; // Camera position
|
camera.position = (Vector3){ 5.0f, 2.0f, 5.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
|
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
|
||||||
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,7 @@ int main(void)
|
||||||
camera.type = CAMERA_PERSPECTIVE;
|
camera.type = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
Vector3 cubePosition = { 0.0f, 0.0f, 0.0f };
|
||||||
|
Vector2 cubeScreenPosition = { 0.0f, 0.0f };
|
||||||
Vector2 cubeScreenPosition;
|
|
||||||
|
|
||||||
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
SetCameraMode(camera, CAMERA_FREE); // Set a free camera mode
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - box collisions");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
Camera camera = { { 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||||
|
|
||||||
Vector3 playerPosition = { 0.0f, 1.0f, 2.0f };
|
Vector3 playerPosition = { 0.0f, 1.0f, 2.0f };
|
||||||
Vector3 playerSize = { 1.0f, 2.0f, 1.0f };
|
Vector3 playerSize = { 1.0f, 2.0f, 1.0f };
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - cubesmap loading and drawing");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {{ 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
Camera camera = { { 16.0f, 14.0f, 16.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||||
|
|
||||||
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
|
Image image = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
|
||||||
Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)
|
Texture2D cubicmap = LoadTextureFromImage(image); // Convert image to texture to display (VRAM)
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - first person maze");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {{ 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
Camera camera = { { 0.2f, 0.4f, 0.2f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||||
|
|
||||||
Image imMap = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
|
Image imMap = LoadImage("resources/cubicmap.png"); // Load cubicmap image (RAM)
|
||||||
Texture2D cubicmap = LoadTextureFromImage(imMap); // Convert image to texture to display (VRAM)
|
Texture2D cubicmap = LoadTextureFromImage(imMap); // Convert image to texture to display (VRAM)
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing");
|
||||||
|
|
||||||
// Define our custom camera to look into our 3d world
|
// Define our custom camera to look into our 3d world
|
||||||
Camera camera = {{ 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
Camera camera = { { 18.0f, 16.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||||
|
|
||||||
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
|
Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM)
|
||||||
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
|
Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM)
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ int main(void)
|
||||||
Texture2D texture = LoadTextureFromImage(checked);
|
Texture2D texture = LoadTextureFromImage(checked);
|
||||||
UnloadImage(checked);
|
UnloadImage(checked);
|
||||||
|
|
||||||
Model models[NUM_MODELS];
|
Model models[NUM_MODELS] = { 0 };
|
||||||
|
|
||||||
models[0] = LoadModelFromMesh(GenMeshPlane(2, 2, 5, 5));
|
models[0] = LoadModelFromMesh(GenMeshPlane(2, 2, 5, 5));
|
||||||
models[1] = LoadModelFromMesh(GenMeshCube(2.0f, 1.0f, 2.0f));
|
models[1] = LoadModelFromMesh(GenMeshCube(2.0f, 1.0f, 2.0f));
|
||||||
|
|
@ -42,7 +42,7 @@ int main(void)
|
||||||
for (int i = 0; i < NUM_MODELS; i++) models[i].materials[0].maps[MAP_DIFFUSE].texture = texture;
|
for (int i = 0; i < NUM_MODELS; i++) models[i].materials[0].maps[MAP_DIFFUSE].texture = texture;
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {{ 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
Camera camera = { { 5.0f, 5.0f, 5.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||||
|
|
||||||
// Model drawing position
|
// Model drawing position
|
||||||
Vector3 position = { 0.0f, 0.0f, 0.0f };
|
Vector3 position = { 0.0f, 0.0f, 0.0f };
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib example - obj viewer");
|
InitWindow(screenWidth, screenHeight, "raylib example - obj viewer");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {{ 30.0f, 30.0f, 30.0f }, { 0.0f, 10.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
Camera camera = { { 30.0f, 30.0f, 30.0f }, { 0.0f, 10.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||||
|
|
||||||
Model model = LoadModel("resources/models/turret.obj"); // Load default model obj
|
Model model = LoadModel("resources/models/turret.obj"); // Load default model obj
|
||||||
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load default model texture
|
Texture2D texture = LoadTexture("resources/models/turret_diffuse.png"); // Load default model texture
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {{ 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE };
|
Camera camera = { { 0.0f, 10.0f, 10.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, FOVY_PERSPECTIVE, CAMERA_PERSPECTIVE };
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");
|
InitWindow(screenWidth, screenHeight, "raylib [models] example - skybox loading and drawing");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// Define the camera to look into our 3d world
|
||||||
Camera camera = {{ 1.0f, 1.0f, 1.0f }, { 4.0f, 1.0f, 4.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
Camera camera = { { 1.0f, 1.0f, 1.0f }, { 4.0f, 1.0f, 4.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||||
|
|
||||||
// Load skybox model
|
// Load skybox model
|
||||||
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
|
Mesh cube = GenMeshCube(1.0f, 1.0f, 1.0f);
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ int main()
|
||||||
{
|
{
|
||||||
// Initialization
|
// Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
static unsigned char key;
|
static unsigned char key = 0;
|
||||||
|
|
||||||
InitAudioDevice();
|
InitAudioDevice();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ int main(void)
|
||||||
rlClearColor(245, 245, 245, 255); // Define clear color
|
rlClearColor(245, 245, 245, 255); // Define clear color
|
||||||
rlEnableDepthTest(); // Enable DEPTH_TEST for 3D
|
rlEnableDepthTest(); // Enable DEPTH_TEST for 3D
|
||||||
|
|
||||||
Camera camera;
|
Camera camera = { 0 };
|
||||||
camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
|
camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
|
||||||
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
|
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.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
|
||||||
|
|
|
||||||
|
|
@ -61,8 +61,8 @@ int main(void)
|
||||||
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
|
SetPhysicsBodyRotation(bodyA, 30*DEG2RAD);
|
||||||
|
|
||||||
PhysicsBody bodyB = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 35, screenHeight*0.6f }, 40, 40, 10);
|
PhysicsBody bodyB = CreatePhysicsBodyRectangle((Vector2){ screenWidth - 35, screenHeight*0.6f }, 40, 40, 10);
|
||||||
bodyB->staticFriction = 1;
|
bodyB->staticFriction = 1.0f;
|
||||||
bodyB->dynamicFriction = 1;
|
bodyB->dynamicFriction = 1.0f;
|
||||||
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
|
SetPhysicsBodyRotation(bodyB, 330*DEG2RAD);
|
||||||
|
|
||||||
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ int main(void)
|
||||||
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
|
InitWindow(screenWidth, screenHeight, "raylib [shaders] example - postprocessing shader");
|
||||||
|
|
||||||
// Define the camera to look into our 3d world
|
// 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 = { { 2.0f, 3.0f, 2.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 };
|
||||||
|
|
||||||
Model model = LoadModel("resources/models/church.obj"); // Load OBJ model
|
Model model = LoadModel("resources/models/church.obj"); // Load OBJ model
|
||||||
Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map)
|
Texture2D texture = LoadTexture("resources/models/church_diffuse.png"); // Load model texture (diffuse map)
|
||||||
|
|
@ -81,7 +81,7 @@ int main(void)
|
||||||
// Load all postpro shaders
|
// Load all postpro shaders
|
||||||
// NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER)
|
// NOTE 1: All postpro shader use the base vertex shader (DEFAULT_VERTEX_SHADER)
|
||||||
// NOTE 2: We load the correct shader depending on GLSL version
|
// NOTE 2: We load the correct shader depending on GLSL version
|
||||||
Shader shaders[MAX_POSTPRO_SHADERS];
|
Shader shaders[MAX_POSTPRO_SHADERS] = { 0 };
|
||||||
|
|
||||||
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
|
// NOTE: Defining 0 (NULL) for vertex shader forces usage of internal default vertex shader
|
||||||
shaders[FX_GRAYSCALE] = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
|
shaders[FX_GRAYSCALE] = LoadShader(0, FormatText("resources/shaders/glsl%i/grayscale.fs", GLSL_VERSION));
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue