summaryrefslogtreecommitdiffhomepage
path: root/examples/core
diff options
context:
space:
mode:
authorRay <[email protected]>2022-06-21 19:53:18 +0200
committerRay <[email protected]>2022-06-21 19:53:18 +0200
commitc1b01c0d5d2f2bb5108df910b2376d45314e7335 (patch)
tree02b65387eacae0324a3ff28851fa43d78cd6fb09 /examples/core
parent8bd3ecaa66a2a13dca9f7b3532b2c8b1298b206b (diff)
downloadraylib-c1b01c0d5d2f2bb5108df910b2376d45314e7335.tar.gz
raylib-c1b01c0d5d2f2bb5108df910b2376d45314e7335.zip
Added new comment to examples
Diffstat (limited to 'examples/core')
-rw-r--r--examples/core/core_2d_camera.c3
-rw-r--r--examples/core/core_2d_camera_platformer.c9
-rw-r--r--examples/core/core_3d_camera_first_person.c3
-rw-r--r--examples/core/core_3d_camera_free.c3
-rw-r--r--examples/core/core_3d_camera_mode.c3
-rw-r--r--examples/core/core_3d_picking.c3
-rw-r--r--examples/core/core_basic_screen_manager.c6
-rw-r--r--examples/core/core_basic_window.c3
-rw-r--r--examples/core/core_basic_window_web.c10
-rw-r--r--examples/core/core_custom_frame_control.c3
-rw-r--r--examples/core/core_custom_logging.c12
-rw-r--r--examples/core/core_drop_files.c3
-rw-r--r--examples/core/core_input_gamepad.c3
-rw-r--r--examples/core/core_input_gestures.c4
-rw-r--r--examples/core/core_input_keys.c3
-rw-r--r--examples/core/core_input_mouse.c3
-rw-r--r--examples/core/core_input_mouse_wheel.c3
-rw-r--r--examples/core/core_input_multitouch.c3
-rw-r--r--examples/core/core_loading_thread.c3
-rw-r--r--examples/core/core_quat_conversion.c3
-rw-r--r--examples/core/core_random_values.c3
-rw-r--r--examples/core/core_scissor_test.c3
-rw-r--r--examples/core/core_smooth_pixelperfect.c3
-rw-r--r--examples/core/core_split_screen.c3
-rw-r--r--examples/core/core_storage_values.c3
-rw-r--r--examples/core/core_vr_simulator.c3
-rw-r--r--examples/core/core_window_flags.c3
-rw-r--r--examples/core/core_window_letterbox.c23
-rw-r--r--examples/core/core_world_screen.c3
29 files changed, 102 insertions, 31 deletions
diff --git a/examples/core/core_2d_camera.c b/examples/core/core_2d_camera.c
index 7336bbbd..1c7c8a30 100644
--- a/examples/core/core_2d_camera.c
+++ b/examples/core/core_2d_camera.c
@@ -13,6 +13,9 @@
#define MAX_BUILDINGS 100
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_2d_camera_platformer.c b/examples/core/core_2d_camera_platformer.c
index 9ab20492..1ebb8e8b 100644
--- a/examples/core/core_2d_camera_platformer.c
+++ b/examples/core/core_2d_camera_platformer.c
@@ -30,16 +30,19 @@ typedef struct EnvItem {
Color color;
} EnvItem;
-
+//----------------------------------------------------------------------------------
+// Module functions declaration
+//----------------------------------------------------------------------------------
void UpdatePlayer(Player *player, EnvItem *envItems, int envItemsLength, float delta);
-
void UpdateCameraCenter(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
void UpdateCameraCenterInsideMap(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
void UpdateCameraCenterSmoothFollow(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
void UpdateCameraEvenOutOnLanding(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
void UpdateCameraPlayerBoundsPush(Camera2D *camera, Player *player, EnvItem *envItems, int envItemsLength, float delta, int width, int height);
-
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_3d_camera_first_person.c b/examples/core/core_3d_camera_first_person.c
index 59fc8307..4f565235 100644
--- a/examples/core/core_3d_camera_first_person.c
+++ b/examples/core/core_3d_camera_first_person.c
@@ -13,6 +13,9 @@
#define MAX_COLUMNS 20
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_3d_camera_free.c b/examples/core/core_3d_camera_free.c
index f469d121..7ee12d72 100644
--- a/examples/core/core_3d_camera_free.c
+++ b/examples/core/core_3d_camera_free.c
@@ -11,6 +11,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_3d_camera_mode.c b/examples/core/core_3d_camera_mode.c
index 654fc2db..5d63ccc8 100644
--- a/examples/core/core_3d_camera_mode.c
+++ b/examples/core/core_3d_camera_mode.c
@@ -11,6 +11,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_3d_picking.c b/examples/core/core_3d_picking.c
index 1c42de79..f20cefaf 100644
--- a/examples/core/core_3d_picking.c
+++ b/examples/core/core_3d_picking.c
@@ -11,6 +11,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_basic_screen_manager.c b/examples/core/core_basic_screen_manager.c
index 6051f175..009dd014 100644
--- a/examples/core/core_basic_screen_manager.c
+++ b/examples/core/core_basic_screen_manager.c
@@ -18,9 +18,9 @@
//------------------------------------------------------------------------------------------
typedef enum GameScreen { LOGO = 0, TITLE, GAMEPLAY, ENDING } GameScreen;
-//------------------------------------------------------------------------------------------
-// Main entry point
-//------------------------------------------------------------------------------------------
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_basic_window.c b/examples/core/core_basic_window.c
index 3c103a5f..d354cb2e 100644
--- a/examples/core/core_basic_window.c
+++ b/examples/core/core_basic_window.c
@@ -21,6 +21,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_basic_window_web.c b/examples/core/core_basic_window_web.c
index 119d4b00..cdd44c4c 100644
--- a/examples/core/core_basic_window_web.c
+++ b/examples/core/core_basic_window_web.c
@@ -28,14 +28,14 @@ const int screenWidth = 800;
const int screenHeight = 450;
//----------------------------------------------------------------------------------
-// Module Functions Declaration
+// Module functions declaration
//----------------------------------------------------------------------------------
void UpdateDrawFrame(void); // Update and Draw one frame
-//----------------------------------------------------------------------------------
-// Main Enry Point
-//----------------------------------------------------------------------------------
-int main()
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
diff --git a/examples/core/core_custom_frame_control.c b/examples/core/core_custom_frame_control.c
index 93181e76..208e131b 100644
--- a/examples/core/core_custom_frame_control.c
+++ b/examples/core/core_custom_frame_control.c
@@ -26,6 +26,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_custom_logging.c b/examples/core/core_custom_logging.c
index 56e168ee..5b39f428 100644
--- a/examples/core/core_custom_logging.c
+++ b/examples/core/core_custom_logging.c
@@ -17,7 +17,7 @@
#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime()
// Custom logging funtion
-void LogCustom(int msgType, const char *text, va_list args)
+void CustomLog(int msgType, const char *text, va_list args)
{
char timeStr[64] = { 0 };
time_t now = time(NULL);
@@ -39,16 +39,18 @@ void LogCustom(int msgType, const char *text, va_list args)
printf("\n");
}
-int main(int argc, char* argv[])
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
+int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
- // First thing we do is setting our custom logger to ensure everything raylib logs
- // will use our own logger instead of its internal one
- SetTraceLogCallback(LogCustom);
+ // Set custom logger
+ SetTraceLogCallback(CustomLog);
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging");
diff --git a/examples/core/core_drop_files.c b/examples/core/core_drop_files.c
index dda31a43..8ac5c265 100644
--- a/examples/core/core_drop_files.c
+++ b/examples/core/core_drop_files.c
@@ -13,6 +13,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_input_gamepad.c b/examples/core/core_input_gamepad.c
index 405f78e8..6c54ba6b 100644
--- a/examples/core/core_input_gamepad.c
+++ b/examples/core/core_input_gamepad.c
@@ -27,6 +27,9 @@
#define PS3_NAME_ID "PLAYSTATION(R)3 Controller"
#endif
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_input_gestures.c b/examples/core/core_input_gestures.c
index 50bbff7e..89c7e72e 100644
--- a/examples/core/core_input_gestures.c
+++ b/examples/core/core_input_gestures.c
@@ -10,10 +10,14 @@
********************************************************************************************/
#include "raylib.h"
+
#include <string.h>
#define MAX_GESTURE_STRINGS 20
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_input_keys.c b/examples/core/core_input_keys.c
index bbb71ee3..5313d5af 100644
--- a/examples/core/core_input_keys.c
+++ b/examples/core/core_input_keys.c
@@ -11,6 +11,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_input_mouse.c b/examples/core/core_input_mouse.c
index c3415e8b..bad1ce2e 100644
--- a/examples/core/core_input_mouse.c
+++ b/examples/core/core_input_mouse.c
@@ -11,6 +11,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_input_mouse_wheel.c b/examples/core/core_input_mouse_wheel.c
index 232d62c1..9080aafb 100644
--- a/examples/core/core_input_mouse_wheel.c
+++ b/examples/core/core_input_mouse_wheel.c
@@ -11,6 +11,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_input_multitouch.c b/examples/core/core_input_multitouch.c
index ef15a966..69f45bd8 100644
--- a/examples/core/core_input_multitouch.c
+++ b/examples/core/core_input_multitouch.c
@@ -15,6 +15,9 @@
#define MAX_TOUCH_POINTS 10
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_loading_thread.c b/examples/core/core_loading_thread.c
index 773ad2ea..20e032b4 100644
--- a/examples/core/core_loading_thread.c
+++ b/examples/core/core_loading_thread.c
@@ -27,6 +27,9 @@ static void *LoadDataThread(void *arg); // Loading data thread function decl
static int dataProgress = 0; // Data progress accumulator
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_quat_conversion.c b/examples/core/core_quat_conversion.c
index a60e4000..a2cf9338 100644
--- a/examples/core/core_quat_conversion.c
+++ b/examples/core/core_quat_conversion.c
@@ -18,6 +18,9 @@
#include "raymath.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_random_values.c b/examples/core/core_random_values.c
index b44b5faf..986014b5 100644
--- a/examples/core/core_random_values.c
+++ b/examples/core/core_random_values.c
@@ -11,6 +11,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_scissor_test.c b/examples/core/core_scissor_test.c
index 56eb84f8..162cc7bc 100644
--- a/examples/core/core_scissor_test.c
+++ b/examples/core/core_scissor_test.c
@@ -13,6 +13,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_smooth_pixelperfect.c b/examples/core/core_smooth_pixelperfect.c
index e0c6d197..a49d5b4c 100644
--- a/examples/core/core_smooth_pixelperfect.c
+++ b/examples/core/core_smooth_pixelperfect.c
@@ -16,6 +16,9 @@
#include <math.h> // Required for: sinf(), cosf()
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_split_screen.c b/examples/core/core_split_screen.c
index c05c0b32..2f7cc2df 100644
--- a/examples/core/core_split_screen.c
+++ b/examples/core/core_split_screen.c
@@ -40,6 +40,9 @@ void DrawScene(void)
DrawCube(cameraPlayer2.position, 1, 1, 1, BLUE);
}
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_storage_values.c b/examples/core/core_storage_values.c
index 2ae1cc39..41173d26 100644
--- a/examples/core/core_storage_values.c
+++ b/examples/core/core_storage_values.c
@@ -17,6 +17,9 @@ typedef enum {
STORAGE_POSITION_HISCORE = 1
} StorageData;
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_vr_simulator.c b/examples/core/core_vr_simulator.c
index c0f1b8d2..c39f2df7 100644
--- a/examples/core/core_vr_simulator.c
+++ b/examples/core/core_vr_simulator.c
@@ -17,6 +17,9 @@
#define GLSL_VERSION 100
#endif
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_window_flags.c b/examples/core/core_window_flags.c
index 4b20066f..534a1878 100644
--- a/examples/core/core_window_flags.c
+++ b/examples/core/core_window_flags.c
@@ -11,6 +11,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
diff --git a/examples/core/core_window_letterbox.c b/examples/core/core_window_letterbox.c
index 1e076516..7c17c8c5 100644
--- a/examples/core/core_window_letterbox.c
+++ b/examples/core/core_window_letterbox.c
@@ -13,21 +13,14 @@
#include "raylib.h"
-#define max(a, b) ((a)>(b)? (a) : (b))
-#define min(a, b) ((a)<(b)? (a) : (b))
+#include "raymath.h" // Required for: Vector2Clamp()
-// Clamp Vector2 value with min and max and return a new vector2
-// NOTE: Required for virtual mouse, to clamp inside virtual game size
-Vector2 ClampValue(Vector2 value, Vector2 min, Vector2 max)
-{
- Vector2 result = value;
- result.x = (result.x > max.x)? max.x : result.x;
- result.x = (result.x < min.x)? min.x : result.x;
- result.y = (result.y > max.y)? max.y : result.y;
- result.y = (result.y < min.y)? min.y : result.y;
- return result;
-}
+#define MAX(a, b) ((a)>(b)? (a) : (b))
+#define MIN(a, b) ((a)<(b)? (a) : (b))
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
const int windowWidth = 800;
@@ -57,7 +50,7 @@ int main(void)
// Update
//----------------------------------------------------------------------------------
// Compute required framebuffer scaling
- float scale = min((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight);
+ float scale = MIN((float)GetScreenWidth()/gameScreenWidth, (float)GetScreenHeight()/gameScreenHeight);
if (IsKeyPressed(KEY_SPACE))
{
@@ -70,7 +63,7 @@ int main(void)
Vector2 virtualMouse = { 0 };
virtualMouse.x = (mouse.x - (GetScreenWidth() - (gameScreenWidth*scale))*0.5f)/scale;
virtualMouse.y = (mouse.y - (GetScreenHeight() - (gameScreenHeight*scale))*0.5f)/scale;
- virtualMouse = ClampValue(virtualMouse, (Vector2){ 0, 0 }, (Vector2){ (float)gameScreenWidth, (float)gameScreenHeight });
+ virtualMouse = Vector2Clamp(virtualMouse, (Vector2){ 0, 0 }, (Vector2){ (float)gameScreenWidth, (float)gameScreenHeight });
// Apply the same transformation as the virtual mouse to the real mouse (i.e. to work with raygui)
//SetMouseOffset(-(GetScreenWidth() - (gameScreenWidth*scale))*0.5f, -(GetScreenHeight() - (gameScreenHeight*scale))*0.5f);
diff --git a/examples/core/core_world_screen.c b/examples/core/core_world_screen.c
index fe13b1b4..cd380a30 100644
--- a/examples/core/core_world_screen.c
+++ b/examples/core/core_world_screen.c
@@ -11,6 +11,9 @@
#include "raylib.h"
+//------------------------------------------------------------------------------------
+// Program main entry point
+//------------------------------------------------------------------------------------
int main(void)
{
// Initialization