diff options
| author | raysan5 <[email protected]> | 2017-07-24 19:45:46 +0200 |
|---|---|---|
| committer | raysan5 <[email protected]> | 2017-07-24 19:45:46 +0200 |
| commit | 46ad8ae6eefc76a2e1f0ce88cdef2b919bb2d936 (patch) | |
| tree | fae44589bea3de03639b0ce88d0adc29044ed062 /cheatsheet | |
| download | raylib.com-46ad8ae6eefc76a2e1f0ce88cdef2b919bb2d936.tar.gz raylib.com-46ad8ae6eefc76a2e1f0ce88cdef2b919bb2d936.zip | |
Added webpage
Moved from @raysan5/raylib/docs
Diffstat (limited to 'cheatsheet')
| -rw-r--r-- | cheatsheet/cheatsheet.html | 173 | ||||
| -rw-r--r-- | cheatsheet/raylib_audio.c | 56 | ||||
| -rw-r--r-- | cheatsheet/raylib_colors.c | 30 | ||||
| -rw-r--r-- | cheatsheet/raylib_core.c | 128 | ||||
| -rw-r--r-- | cheatsheet/raylib_defines.c | 82 | ||||
| -rw-r--r-- | cheatsheet/raylib_models.c | 61 | ||||
| -rw-r--r-- | cheatsheet/raylib_shaders.c | 32 | ||||
| -rw-r--r-- | cheatsheet/raylib_shapes.c | 33 | ||||
| -rw-r--r-- | cheatsheet/raylib_structs.c | 29 | ||||
| -rw-r--r-- | cheatsheet/raylib_text.c | 19 | ||||
| -rw-r--r-- | cheatsheet/raylib_textures.c | 52 |
11 files changed, 695 insertions, 0 deletions
diff --git a/cheatsheet/cheatsheet.html b/cheatsheet/cheatsheet.html new file mode 100644 index 0000000..b540461 --- /dev/null +++ b/cheatsheet/cheatsheet.html @@ -0,0 +1,173 @@ +<!DOCTYPE html> +<html> + <head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> + + <title>raylib - cheatsheet</title> + <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> + + <meta name="title" content="raylib - cheatsheet"> + <meta name="description" content="raylib is a simple and easy-to-use library to learn videogames programming. Don't miss latest functions added to raylib... check raylib cheatsheet"> + <meta name="keywords" content="raylib, videogames, programming, C, C++, library, learn, study, simple, easy, free, open source, raysan"> + <meta name="viewport" content="width=device-width"> + + <!-- Facebook metatags for sharing --> + <meta property="og:title" content="raylib - cheatsheet"/> + <meta property="og:image" content="http://www.raylib.com/common/img/fb_raylib_logo.png"/> + <meta property="og:url" content="http://www.raylib.com" /> + <meta property="og:site_name" content="raylib"/> + <meta property="og:description" content="don't miss latest functions added to raylib... check raylib cheatsheet"/> + + <!-- Add jQuery library --> + <script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script> + + <!-- hightlight.js - Syntax highlighting for the Web --> + <link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.1/styles/docco.min.css"> + <script src="http://cdnjs.cloudflare.com/ajax/libs/highlight.js/8.1/highlight.min.js"></script> + + <style type="text/css"> + @font-face { + font-family: 'grixel_acme_7_wide_xtnd'; + src: url('../common/font/acme_7_wide_xtnd.eot'); + src: url('../common/font/acme_7_wide_xtnd.eot?#iefix') format('embedded-opentype'), + url('../common/font/acme_7_wide_xtnd.woff') format('woff'), + url('../common/font/acme_7_wide_xtnd.ttf') format('truetype'); + font-weight: normal; + font-style: normal; + font-size-adjust:0.49; + } + body{background-color:#f5f5f5;} + #fulldata{width: 1315px!important;} + .eximage img{ margin: 0 auto; border: 1px solid; border-color: black; width:770px; height:auto;} + pre code{ width: auto!important; border: 1px solid; border-color:#b0b0b0; width:758px; height:auto; } + .exdownbtn{width:250px; height:30px; float:left; position: relative; cursor:pointer; font-weight:bold; font-size:10px; + line-height:30px; text-align: center; border-width:5px; background-color:#e1e1e1; color:#5c5a5a; + border:4px solid #898888; font-family: grixel_acme_7_wide_xtnd, Courier New, Verdana, Arial;} + .exdownbtn:hover{background-color:#f0d6d6; color:#c55757; border:4px solid #e66666;} + #core pre code{border:10px solid; border-color:#888888; background-color:#dbdbe1; } + #shapes pre code{border:10px solid; border-color:#e66666; background-color:#e9d0d6; } + #textures pre code{border:10px solid; border-color:#75a06d; background-color:#c3e4bf; } + #text pre code{border:10px solid; border-color:#52b296; background-color:#b9e9dd; } + #models pre code{border:10px solid; border-color:#5d9cbd; background-color:#b9d6e8; } + #shaders pre code{border:10px solid; border-color:#a864d2; background-color:#e0c6f1; } + #audio pre code{border:10px solid; border-color:#d3b157; background-color:#e5d7ae; } + #structs pre code{border:10px solid; border-color:#d2c9c6; background-color:#f8f8ff; height: 440px!important} + #colors pre code{border:10px solid; border-color:#c6d2c6; background-color:#e9f1f2; width:600px!important; } + #logo{width:128px; height:128px; float:left; position:relative; background-image:url(../common/img/raylib_logo.png);} + p{font-family: grixel_acme_7_wide_xtnd, Courier New, Verdana, Arial; font-size:13px; line-height:24px;} + #header{position:relative; height:110px; width: 1000px;} + #title, #plinks, #version{position:relative; float:left; margin:0px; margin-left:10px; margin-top:10px;} + #plinks{color: gray;} + #plinks a, #copyright a{color: gray; text-decoration:none;} + #plinks a:hover{color: black;} + #version {margin-top: 23px;} + #pcore{margin-bottom:-12px; margin-left:12px; color:#5c5a5a;} + #pshapes{margin-bottom:-12px; margin-left:12px; color:#c55757;} + #ptextures{margin-bottom:-12px; margin-left:12px; color:#60815a;} + #ptext{margin-bottom:-12px; margin-left:12px; color:#377764;} + #pmodels{margin-bottom:-12px; margin-left:12px; color:#417794;} + #pshaders{margin-bottom:-12px; margin-left:12px; color:#a864d2;} + #paudio{margin-bottom:-12px; margin-left:12px; color:#8c7539;} + #pstructs{margin-bottom:-12px; margin-left:12px; color:#bcbccd;} + #pcolors{margin-bottom:-12px; margin-left:12px; color:#bcbccd;} + + #leftgroup{position:relative; float:left; width:680px; } + #structs{width:660px!important;} + #colors{position:relative; float:left; width: auto; } + + #copyright{color:#8b8b8b; font-size:10px; margin-left:590px; display:inline; } + #copyright a:hover{color:black;} + </style> + + <script type="text/javascript"> + $(document).ready(function() { + $.get('raylib_core.c', function(data) { + $('#core pre code').text(data); + $('#core pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('raylib_shapes.c', function(data) { + $('#shapes pre code').text(data); + $('#shapes pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('raylib_textures.c', function(data) { + $('#textures pre code').text(data); + $('#textures pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('raylib_text.c', function(data) { + $('#text pre code').text(data); + $('#text pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('raylib_models.c', function(data) { + $('#models pre code').text(data); + $('#models pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('raylib_shaders.c', function(data) { + $('#shaders pre code').text(data); + $('#shaders pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('raylib_audio.c', function(data) { + $('#audio pre code').text(data); + $('#audio pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('raylib_colors.c', function(data) { + $('#colors pre code').text(data); + $('#colors pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + $.get('raylib_structs.c', function(data) { + $('#structs pre code').text(data); + $('#structs pre code').each(function(i, e) {hljs.highlightBlock(e)}); + }, 'text'); + }); + </script> + </head> + + <body> + <div id="header"> + <a id="logo" href="http://www.raylib.com/index.html"></a> + <p id="title">[simple and easy-to-use library to learn videogames programming]</p> + <p id="plinks">[<a href="http://www.facebook.com/raylibgames" target="_blank">www.facebook.com/raylibgames</a>][<a href="https://github.com/raysan5/raylib">github.com/raysan5/raylib</a>]</p> + <p id="version">v1.7.0 quick reference card</p> + </div> + <br> + <div id="fulldata"> + <p id="pcore">module: core</p> + <div id="core"><pre><code class="cpp"></code></pre></div> + <p id="pshapes">module: shapes</p> + <div id="shapes"><pre><code class="cpp"></code></pre></div> + <p id="ptextures">module: textures</p> + <div id="textures"><pre><code class="cpp"></code></pre></div> + <p id="ptext">module: text</p> + <div id="text"><pre><code class="cpp"></code></pre></div> + <p id="pmodels">module: models</p> + <div id="models"><pre><code class="cpp"></code></pre></div> + <p id="pshaders">module: shaders (rlgl)</p> + <div id="shaders"><pre><code class="cpp"></code></pre></div> + <p id="paudio">module: audio</p> + <div id="audio"><pre><code class="cpp"></code></pre></div> + + <div id="fullgroup"> + <div id="leftgroup"> + <p id="pstructs">structs</p> + <div id="structs"><pre><code class="cpp"></code></pre></div> + </div> + <p id="pcolors">colors</p> + <div id="colors"><pre><code class="cpp"></code></pre></div> + </div> + <p id="copyright">raylib quick reference card - Copyright (c) 2013-2017 Ramon Santamaria (<a href="http://www.twitter.com/raysan5">@raysan5</a>)</p> + </div> + + + <!-- Google Analytics tracking code --> + <script> + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','http://www.google-analytics.com/analytics.js','ga'); + + ga('create', 'UA-45733555-1', 'raylib.com'); + ga('require', 'linkid', 'linkid.js'); + ga('send', 'pageview'); + </script> + </body> +</html>
\ No newline at end of file diff --git a/cheatsheet/raylib_audio.c b/cheatsheet/raylib_audio.c new file mode 100644 index 0000000..3d0447b --- /dev/null +++ b/cheatsheet/raylib_audio.c @@ -0,0 +1,56 @@ + + // Audio device management functions + void InitAudioDevice(void); // Initialize audio device and context + void CloseAudioDevice(void); // Close the audio device and context (and music stream) + bool IsAudioDeviceReady(void); // Check if audio device is ready + void SetMasterVolume(float volume); // Set master volume (listener) + + // Wave/Sound loading/unloading functions + Wave LoadWave(const char *fileName); // Load wave data from file into RAM + Wave LoadWaveEx(float *data, int sampleCount, int sampleRate, + int sampleSize, int channels); // Load wave data from float array data (32bit) + Sound LoadSound(const char *fileName); // Load sound to memory + Sound LoadSoundFromWave(Wave wave); // Load sound to memory from wave data + void UpdateSound(Sound sound, void *data, int numSamples); // Update sound buffer with new data + void UnloadWave(Wave wave); // Unload wave data + void UnloadSound(Sound sound); // Unload sound + + // Wave/Sound management functions + void PlaySound(Sound sound); // Play a sound + void PauseSound(Sound sound); // Pause a sound + void ResumeSound(Sound sound); // Resume a paused sound + void StopSound(Sound sound); // Stop playing a sound + bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing + void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level) + void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level) + void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format + Wave WaveCopy(Wave wave); // Copy a wave to a new wave + void WaveCrop(Wave *wave, int initSample, int finalSample); // Crop a wave to defined samples range + float *GetWaveData(Wave wave); // Get samples data from wave as a floats array + + // Music management functions + Music LoadMusicStream(const char *fileName); // Load music stream from file + void UnloadMusicStream(Music music); // Unload music stream + void PlayMusicStream(Music music); // Start music playing + void UpdateMusicStream(Music music); // Updates buffers for music streaming + void StopMusicStream(Music music); // Stop music playing + void PauseMusicStream(Music music); // Pause music playing + void ResumeMusicStream(Music music); // Resume playing paused music + bool IsMusicPlaying(Music music); // Check if music is playing + void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level) + void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level) + void SetMusicLoopCount(Music music, float count); // Set music loop count (loop repeats) + float GetMusicTimeLength(Music music); // Get music time length (in seconds) + float GetMusicTimePlayed(Music music); // Get current music time played (in seconds) + + // AudioStream management functions + AudioStream InitAudioStream(unsigned int sampleRate, unsigned int sampleSize, + unsigned int channels); // Init audio stream (to stream raw audio pcm data) + void UpdateAudioStream(AudioStream stream, void *data, int numSamples); // Update audio stream buffers with data + void CloseAudioStream(AudioStream stream); // Close audio stream and free memory + bool IsAudioBufferProcessed(AudioStream stream); // Check if any audio stream buffers requires refill + void PlayAudioStream(AudioStream stream); // Play audio stream + void PauseAudioStream(AudioStream stream); // Pause audio stream + void ResumeAudioStream(AudioStream stream); // Resume audio stream + void StopAudioStream(AudioStream stream); // Stop audio stream + diff --git a/cheatsheet/raylib_colors.c b/cheatsheet/raylib_colors.c new file mode 100644 index 0000000..555a75e --- /dev/null +++ b/cheatsheet/raylib_colors.c @@ -0,0 +1,30 @@ + + // Custom raylib color palette for amazing visuals + #define LIGHTGRAY (Color){ 200, 200, 200, 255 } // Light Gray + #define GRAY (Color){ 130, 130, 130, 255 } // Gray + #define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray + #define YELLOW (Color){ 253, 249, 0, 255 } // Yellow + #define GOLD (Color){ 255, 203, 0, 255 } // Gold + #define ORANGE (Color){ 255, 161, 0, 255 } // Orange + #define PINK (Color){ 255, 109, 194, 255 } // Pink + #define RED (Color){ 230, 41, 55, 255 } // Red + #define MAROON (Color){ 190, 33, 55, 255 } // Maroon + #define GREEN (Color){ 0, 228, 48, 255 } // Green + #define LIME (Color){ 0, 158, 47, 255 } // Lime + #define DARKGREEN (Color){ 0, 117, 44, 255 } // Dark Green + #define SKYBLUE (Color){ 102, 191, 255, 255 } // Sky Blue + #define BLUE (Color){ 0, 121, 241, 255 } // Blue + #define DARKBLUE (Color){ 0, 82, 172, 255 } // Dark Blue + #define PURPLE (Color){ 200, 122, 255, 255 } // Purple + #define VIOLET (Color){ 135, 60, 190, 255 } // Violet + #define DARKPURPLE (Color){ 112, 31, 126, 255 } // Dark Purple + #define BEIGE (Color){ 211, 176, 131, 255 } // Beige + #define BROWN (Color){ 127, 106, 79, 255 } // Brown + #define DARKBROWN (Color){ 76, 63, 47, 255 } // Dark Brown + + #define WHITE (Color){ 255, 255, 255, 255 } // White + #define BLACK (Color){ 0, 0, 0, 255 } // Black + #define BLANK (Color){ 0, 0, 0, 0 } // Transparent + #define MAGENTA (Color){ 255, 0, 255, 255 } // Magenta + #define RAYWHITE (Color){ 245, 245, 245, 255 } // Ray White + diff --git a/cheatsheet/raylib_core.c b/cheatsheet/raylib_core.c new file mode 100644 index 0000000..b2827c4 --- /dev/null +++ b/cheatsheet/raylib_core.c @@ -0,0 +1,128 @@ + + // Window-related functions + void InitWindow(int width, int height, char* title); // Initialize Window and Graphics Context (OpenGL) + void CloseWindow(void); // Close window and unload OpenGL context + bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed + bool IsWindowMinimized(void); // Check if window has been minimized (or lost focus) + void ToggleFullscreen(void); // Toggle fullscreen mode (only PLATFORM_DESKTOP) + void SetWindowIcon(Image image); // Set icon for window (only PLATFORM_DESKTOP) + void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP) + void SetWindowMonitor(int monitor); // Set monitor for the current window (fullscreen mode) + void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) + int GetScreenWidth(void); // Get current screen width + int GetScreenHeight(void); // Get current screen height + + // Cursor-related functions + void ShowCursor(void); // Shows cursor + void HideCursor(void); // Hides cursor + bool IsCursorHidden(void); // Check if cursor is not visible + void EnableCursor(void); // Enables cursor (unlock cursor) + void DisableCursor(void); // Disables cursor (lock cursor) + + // Drawing-related functions + void ClearBackground(Color color); // Set background color (framebuffer clear color) + void BeginDrawing(void); // Setup canvas (framebuffer) to start drawing + void EndDrawing(void); // End canvas drawing and swap buffers (double buffering) + void Begin2dMode(Camera2D camera); // Initialize 2D mode with custom camera (2D) + void End2dMode(void); // Ends 2D mode with custom camera + void Begin3dMode(Camera camera); // Initializes 3D mode with custom camera (3D) + void End3dMode(void); // Ends 3D mode and returns to default 2D orthographic mode + void BeginTextureMode(RenderTexture2D target); // Initializes render texture for drawing + void EndTextureMode(void); // Ends drawing to render texture + + // Screen-space-related functions + Ray GetMouseRay(Vector2 mousePosition, Camera camera); // Returns a ray trace from mouse position + Vector2 GetWorldToScreen(Vector3 position, Camera camera); // Returns the screen space position for a 3d world space position + Matrix GetCameraMatrix(Camera camera); // Returns camera transform matrix (view matrix) + + // Timming-related functions + void SetTargetFPS(int fps); // Set target FPS (maximum) + int GetFPS(void); // Returns current FPS + float GetFrameTime(void); // Returns time in seconds for last frame drawn + + // Color-related functions + int GetHexValue(Color color); // Returns hexadecimal value for a Color + Color GetColor(int hexValue); // Returns a Color struct from hexadecimal value + Color Fade(Color color, float alpha); // Color fade-in or fade-out, alpha goes from 0.0f to 1.0f + float *ColorToFloat(Color color); // Converts Color to float array and normalizes + float *VectorToFloat(Vector3 vec); // Converts Vector3 to float array + float *MatrixToFloat(Matrix mat); // Converts Matrix to float array + + // Misc. functions + void ShowLogo(void); // Activate raylib logo at startup (can be done with flags) + void SetConfigFlags(char flags); // Setup window configuration flags (view FLAGS) + void TraceLog(int logType, const char *text, ...); // Show trace log messages (INFO, WARNING, ERROR, DEBUG) + void TakeScreenshot(const char *fileName); // Takes a screenshot of current screen (saved a .png) + int GetRandomValue(int min, int max); // Returns a random value between min and max (both included) + + // Files management functions + bool IsFileExtension(const char *fileName, const char *ext); // Check file extension + const char *GetDirectoryPath(const char *fileName); // Get directory for a given fileName (with path) + const char *GetWorkingDirectory(void); // Get current working directory + bool ChangeDirectory(const char *dir); // Change working directory, returns true if success + bool IsFileDropped(void); // Check if a file has been dropped into window + char **GetDroppedFiles(int *count); // Get dropped files names + void ClearDroppedFiles(void); // Clear dropped files paths buffer + + // Persistent storage management + void StorageSaveValue(int position, int value); // Save integer value to storage file (to defined position) + int StorageLoadValue(int position); // Load integer value from storage file (from defined position) + + // Input-related functions: keyboard + bool IsKeyPressed(int key); // Detect if a key has been pressed once + bool IsKeyDown(int key); // Detect if a key is being pressed + bool IsKeyReleased(int key); // Detect if a key has been released once + bool IsKeyUp(int key); // Detect if a key is NOT being pressed + int GetKeyPressed(void); // Get latest key pressed + void SetExitKey(int key); // Set a custom key to exit program (default is ESC) + + // Input-related functions: gamepads + bool IsGamepadAvailable(int gamepad); // Detect if a gamepad is available + bool IsGamepadName(int gamepad, const char *name); // Check gamepad name (if available) + const char *GetGamepadName(int gamepad); // Return gamepad internal name id + bool IsGamepadButtonPressed(int gamepad, int button); // Detect if a gamepad button has been pressed once + bool IsGamepadButtonDown(int gamepad, int button); // Detect if a gamepad button is being pressed + bool IsGamepadButtonReleased(int gamepad, int button); // Detect if a gamepad button has been released once + bool IsGamepadButtonUp(int gamepad, int button); // Detect if a gamepad button is NOT being pressed + int GetGamepadButtonPressed(void); // Get the last gamepad button pressed + int GetGamepadAxisCount(int gamepad); // Return gamepad axis count for a gamepad + float GetGamepadAxisMovement(int gamepad, int axis); // Return axis movement value for a gamepad axis + + // Input-related functions: mouse + bool IsMouseButtonPressed(int button); // Detect if a mouse button has been pressed once + bool IsMouseButtonDown(int button); // Detect if a mouse button is being pressed + bool IsMouseButtonReleased(int button); // Detect if a mouse button has been released once + bool IsMouseButtonUp(int button); // Detect if a mouse button is NOT being pressed + int GetMouseX(void); // Returns mouse position X + int GetMouseY(void); // Returns mouse position Y + Vector2 GetMousePosition(void); // Returns mouse position XY + void SetMousePosition(Vector2 position); // Set mouse position XY + int GetMouseWheelMove(void); // Returns mouse wheel movement Y + + // Input-related functions: touch + int GetTouchX(void); // Get touch position X for touch point 0 (relative to screen size) + int GetTouchY(void); // Get touch position Y for touch point 0 (relative to screen size) + Vector2 GetTouchPosition(int index); // Get touch position XY for a touch point index (relative to screen size) + + // Gestures-related functions + void SetGesturesEnabled(unsigned int gestureFlags); // Enable a set of gestures using flags + bool IsGestureDetected(int gesture); // Check if a gesture have been detected + int GetGestureDetected(void); // Get latest detected gesture + int GetTouchPointsCount(void); // Get touch points count + float GetGestureHoldDuration(void); // Get gesture hold time in milliseconds + Vector2 GetGestureDragVector(void); // Get gesture drag vector + float GetGestureDragAngle(void); // Get gesture drag angle + Vector2 GetGesturePinchVector(void); // Get gesture pinch delta + float GetGesturePinchAngle(void); // Get gesture pinch angle + + // Camera-related functions + SetCameraMode(Camera camera, int mode); // Set camera mode (multiple camera modes available) + void UpdateCamera(Camera *camera); // Update camera position for selected mode + void SetCameraPanControl(int panKey); // Set camera pan key to combine with mouse movement (free camera) + void SetCameraAltControl(int altKey); // Set camera alt key to combine with mouse movement (free camera) + void SetCameraSmoothZoomControl(int szKey); // Set camera smooth zoom key to combine with mouse (free camera) + void SetCameraMoveControls(int frontKey, int backKey, + int rightKey, int leftKey, + int upKey, int downKey); // Set camera move controls (1st person and 3rd person cameras) + +
\ No newline at end of file diff --git a/cheatsheet/raylib_defines.c b/cheatsheet/raylib_defines.c new file mode 100644 index 0000000..db538e5 --- /dev/null +++ b/cheatsheet/raylib_defines.c @@ -0,0 +1,82 @@ + + + // Keyboard Function Keys + #define KEY_SPACE 32 + #define KEY_ESCAPE 256 + #define KEY_ENTER 257 + #define KEY_BACKSPACE 259 + #define KEY_RIGHT 262 + #define KEY_LEFT 263 + #define KEY_DOWN 264 + #define KEY_UP 265 + #define KEY_F1 290 + #define KEY_F2 291 + #define KEY_F3 292 + #define KEY_F4 293 + #define KEY_F5 294 + #define KEY_F6 295 + #define KEY_F7 296 + #define KEY_F8 297 + #define KEY_F9 298 + #define KEY_F10 299 + #define KEY_LEFT_SHIFT 340 + #define KEY_LEFT_CONTROL 341 + #define KEY_LEFT_ALT 342 + #define KEY_RIGHT_SHIFT 344 + #define KEY_RIGHT_CONTROL 345 + #define KEY_RIGHT_ALT 346 + + // Mouse Buttons + #define MOUSE_LEFT_BUTTON 0 + #define MOUSE_RIGHT_BUTTON 1 + #define MOUSE_MIDDLE_BUTTON 2 + + // Gamepad Number + #define GAMEPAD_PLAYER1 0 + #define GAMEPAD_PLAYER2 1 + #define GAMEPAD_PLAYER3 2 + #define GAMEPAD_PLAYER4 3 + + // Gamepad Buttons + // NOTE: Adjusted for a PS3 USB Controller + #define GAMEPAD_BUTTON_A 2 + #define GAMEPAD_BUTTON_B 1 + #define GAMEPAD_BUTTON_X 3 + #define GAMEPAD_BUTTON_Y 4 + #define GAMEPAD_BUTTON_R1 7 + #define GAMEPAD_BUTTON_R2 5 + #define GAMEPAD_BUTTON_L1 6 + #define GAMEPAD_BUTTON_L2 8 + #define GAMEPAD_BUTTON_SELECT 9 + #define GAMEPAD_BUTTON_START 10 + + + // Some Basic Colors + // NOTE: Custom raylib color palette for amazing visuals + #define LIGHTGRAY (Color){ 200, 200, 200, 255 } // Light Gray + #define GRAY (Color){ 130, 130, 130, 255 } // Gray + #define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray + #define YELLOW (Color){ 253, 249, 0, 255 } // Yellow + #define GOLD (Color){ 255, 203, 0, 255 } // Gold + #define ORANGE (Color){ 255, 161, 0, 255 } // Orange + #define PINK (Color){ 255, 109, 194, 255 } // Pink + #define RED (Color){ 230, 41, 55, 255 } // Red + #define MAROON (Color){ 190, 33, 55, 255 } // Maroon + #define GREEN (Color){ 0, 228, 48, 255 } // Green + #define LIME (Color){ 0, 158, 47, 255 } // Lime + #define DARKGREEN (Color){ 0, 117, 44, 255 } // Dark Green + #define SKYBLUE (Color){ 102, 191, 255, 255 } // Sky Blue + #define BLUE (Color){ 0, 121, 241, 255 } // Blue + #define DARKBLUE (Color){ 0, 82, 172, 255 } // Dark Blue + #define PURPLE (Color){ 200, 122, 255, 255 } // Purple + #define VIOLET (Color){ 135, 60, 190, 255 } // Violet + #define DARKPURPLE (Color){ 112, 31, 126, 255 } // Dark Purple + #define BEIGE (Color){ 211, 176, 131, 255 } // Beige + #define BROWN (Color){ 127, 106, 79, 255 } // Brown + #define DARKBROWN (Color){ 76, 63, 47, 255 } // Dark Brown + + #define WHITE (Color){ 255, 255, 255, 255 } // White + #define BLACK (Color){ 0, 0, 0, 255 } // Black + #define BLANK (Color){ 0, 0, 0, 0 } // Blank (Transparent) + #define MAGENTA (Color){ 255, 0, 255, 255 } // Magenta + #define RAYWHITE (Color){ 245, 245, 245, 255 } // Ray White (raylib logo)
\ No newline at end of file diff --git a/cheatsheet/raylib_models.c b/cheatsheet/raylib_models.c new file mode 100644 index 0000000..d754013 --- /dev/null +++ b/cheatsheet/raylib_models.c @@ -0,0 +1,61 @@ + + // Basic geometric 3D shapes drawing functions + void DrawLine3D(Vector3 startPos, Vector3 endPos, Color color); // Draw a line in 3D world space + void DrawCircle3D(Vector3 center, float radius, Vector3 rotationAxis, + float rotationAngle, Color color); // Draw a circle in 3D world space + void DrawCube(Vector3 position, float width, float height, float length, Color color); // Draw cube + void DrawCubeV(Vector3 position, Vector3 size, Color color); // Draw cube (Vector version) + void DrawCubeWires(Vector3 position, float width, float height, float length, Color color); // Draw cube wires + void DrawCubeTexture(Texture2D texture, Vector3 position, float width, + float height, float length, Color color); // Draw cube textured + void DrawSphere(Vector3 centerPos, float radius, Color color); // Draw sphere + void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere with extended parameters + void DrawSphereWires(Vector3 centerPos, float radius, int rings, int slices, Color color); // Draw sphere wires + void DrawCylinder(Vector3 position, float radiusTop, float radiusBottom, + float height, int slices, Color color); // Draw a cylinder/cone + void DrawCylinderWires(Vector3 position, float radiusTop, float radiusBottom, + float height, int slices, Color color); // Draw a cylinder/cone wires + void DrawPlane(Vector3 centerPos, Vector2 size, Color color); // Draw a plane XZ + void DrawRay(Ray ray, Color color); // Draw a ray line + void DrawGrid(int slices, float spacing); // Draw a grid (centered at (0, 0, 0)) + void DrawGizmo(Vector3 position); // Draw simple gizmo + + // Model loading/unloading functions + Mesh LoadMesh(const char *fileName); // Load mesh from file + Mesh LoadMeshEx(int numVertex, float *vData, float *vtData, float *vnData, Color *cData); // Load mesh from vertex data + Model LoadModel(const char *fileName); // Load model from file + Model LoadModelFromMesh(Mesh data, bool dynamic); // Load model from mesh data + Model LoadHeightmap(Image heightmap, Vector3 size); // Load heightmap model from image data + Model LoadCubicmap(Image cubicmap); // Load cubes-based map model from image data + void UnloadMesh(Mesh *mesh); // Unload mesh from memory (RAM and/or VRAM) + void UnloadModel(Model model); // Unload model from memory (RAM and/or VRAM) + + // Material loading/unloading functions + Material LoadMaterial(const char *fileName); // Load material data (from file) + Material LoadDefaultMaterial(void); // Load default material (uses default models shader) + void UnloadMaterial(Material material); // Unload material textures from VRAM + + // Model drawing functions + void DrawModel(Model model, Vector3 position, float scale, Color tint); // Draw a model (with texture if set) + void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, + float rotationAngle, Vector3 scale, Color tint); // Draw a model with extended parameters + void DrawModelWires(Model model, Vector3 position, float scale, Color tint); // Draw a model wires (with texture if set) + void DrawModelWiresEx(Model model, Vector3 position, Vector3 rotationAxis, + float rotationAngle, Vector3 scale, Color tint); // Draw a model wires + void DrawBoundingBox(BoundingBox box, Color color); // Draw bounding box (wires) + void DrawBillboard(Camera camera, Texture2D texture, Vector3 center, float size, Color tint); // Draw a billboard texture + void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, + Vector3 center, float size, Color tint); // Draw a billboard texture defined by sourceRec + + // Collision detection functions + bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, float radiusB); // Detect collision between two spheres + bool CheckCollisionBoxes(Vector3 minBBox1, Vector3 maxBBox1, Vector3 minBBox2, Vector3 maxBBox2); // Detect collision between two boxes + bool CheckCollisionBoxSphere(Vector3 minBBox, Vector3 maxBBox, Vector3 centerSphere, float radiusSphere); // Detect collision between box and sphere + bool CheckCollisionRaySphere(Ray ray, Vector3 spherePosition, float sphereRadius); // Detect collision between ray and sphere + bool CheckCollisionRaySphereEx(Ray ray, Vector3 spherePosition, float sphereRadius, Vector3 *collisionPoint); // Detect collision between ray and sphere ex. + bool CheckCollisionRayBox(Ray ray, Vector3 minBBox, Vector3 maxBBox); // Detect collision between ray and box + BoundingBox CalculateBoundingBox(Mesh mesh); // Calculate mesh bounding box limits + RayHitInfo GetCollisionRayMesh(Ray ray, Mesh *mesh); // Get collision info between ray and mesh + RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3); // Get collision info between ray and triangle + RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight); // Get collision info between ray and ground plane (Y-normal plane) + diff --git a/cheatsheet/raylib_shaders.c b/cheatsheet/raylib_shaders.c new file mode 100644 index 0000000..c321a50 --- /dev/null +++ b/cheatsheet/raylib_shaders.c @@ -0,0 +1,32 @@ + + // Shader loading/unloading functions + char *LoadText(const char *fileName); // Load chars array from text file + Shader LoadShader(char *vsFileName, char *fsFileName); // Load a custom shader and bind default locations + void UnloadShader(Shader shader); // Unload a custom shader from memory + + Shader GetDefaultShader(void); // Get default shader + Texture2D GetDefaultTexture(void); // Get default texture + + // Shader access functions + int GetShaderLocation(Shader shader, const char *uniformName); // Get shader uniform location + void SetShaderValue(Shader shader, int uniformLoc, float *value, int size); // Set shader uniform value (float) + void SetShaderValuei(Shader shader, int uniformLoc, int *value, int size); // Set shader uniform value (int) + void SetShaderValueMatrix(Shader shader, int uniformLoc, Matrix mat); // Set shader uniform value (matrix 4x4) + void SetMatrixProjection(Matrix proj); // Set a custom projection matrix (replaces internal projection matrix) + void SetMatrixModelview(Matrix view); // Set a custom modelview matrix (replaces internal modelview matrix) + + // Shading beegin/end functions + void BeginShaderMode(Shader shader); // Begin custom shader drawing + void EndShaderMode(void); // End custom shader drawing (use default shader) + void BeginBlendMode(int mode); // Begin blending mode (alpha, additive, multiplied) + void EndBlendMode(void); // End blending mode (reset to default: alpha blending) + + // VR control functions + void InitVrSimulator(int vrDevice); // Init VR simulator for selected device + void CloseVrSimulator(void); // Close VR simulator for current device + bool IsVrSimulatorReady(void); // Detect if VR simulator is ready + void UpdateVrTracking(Camera *camera); // Update VR tracking (position and orientation) and camera + void ToggleVrMode(void); // Enable/Disable VR experience + void BeginVrDrawing(void); // Begin VR simulator stereo rendering + void EndVrDrawing(void); // End VR simulator stereo rendering + diff --git a/cheatsheet/raylib_shapes.c b/cheatsheet/raylib_shapes.c new file mode 100644 index 0000000..7bf4eaa --- /dev/null +++ b/cheatsheet/raylib_shapes.c @@ -0,0 +1,33 @@ + + // Basic shapes drawing functions + void DrawPixel(int posX, int posY, Color color); // Draw a pixel + void DrawPixelV(Vector2 position, Color color); // Draw a pixel (Vector version) + void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); // Draw a line + void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); // Draw a line (Vector version) + void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line defining thickness + void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); // Draw a line using cubic-bezier curves in-out + void DrawCircle(int centerX, int centerY, float radius, Color color); // Draw a color-filled circle + void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); // Draw a gradient-filled circle + void DrawCircleV(Vector2 center, float radius, Color color); // Draw a color-filled circle (Vector version) + void DrawCircleLines(int centerX, int centerY, float radius, Color color); // Draw circle outline + void DrawRectangle(int posX, int posY, int width, int height, Color color); // Draw a color-filled rectangle + void DrawRectangleRec(Rectangle rec, Color color); // Draw a color-filled rectangle + void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); // Draw a color-filled rectangle with pro parameters + void DrawRectangleGradient(int posX, int posY, int width, int height, Color color1, Color color2); // Draw a gradient-filled rectangle + void DrawRectangleV(Vector2 position, Vector2 size, Color color); // Draw a color-filled rectangle (Vector version) + void DrawRectangleLines(int posX, int posY, int width, int height, Color color); // Draw rectangle outline + void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw a color-filled triangle + void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); // Draw triangle outline + void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); // Draw a regular polygon (Vector version) + void DrawPolyEx(Vector2 *points, int numPoints, Color color); // Draw a closed polygon defined by points + void DrawPolyExLines(Vector2 *points, int numPoints, Color color); // Draw polygon lines + + // Basic shapes collision detection functions + bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); // Check collision between two rectangles + bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); // Check collision between two circles + bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); // Check collision between circle and rectangle + Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); // Get collision rectangle for two rectangles collision + bool CheckCollisionPointRec(Vector2 point, Rectangle rec); // Check if point is inside rectangle + bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); // Check if point is inside circle + bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); // Check if point is inside a triangle + diff --git a/cheatsheet/raylib_structs.c b/cheatsheet/raylib_structs.c new file mode 100644 index 0000000..9644147 --- /dev/null +++ b/cheatsheet/raylib_structs.c @@ -0,0 +1,29 @@ + + struct Color; // Color type, RGBA (32bit) + struct Rectangle; // Rectangle type + struct Vector2; // Vector2 type + struct Vector3; // Vector3 type + struct Matrix; // Matrix type (OpenGL style 4x4) + + struct Image; // Image type (multiple data formats supported) + // NOTE: Data stored in CPU memory (RAM) + struct Texture2D; // Texture2D type (multiple internal formats supported) + // NOTE: Data stored in GPU memory (VRAM) + struct RenderTexture2D; // RenderTexture2D type, for texture rendering + struct SpriteFont; // SpriteFont type, includes texture and chars data + + struct Camera; // Camera type, defines 3d camera position/orientation + struct Camera2D; // Camera2D type, defines a 2d camera + struct Mesh; // Vertex data definning a mesh + struct Shader; // Shader type (generic shader) + struct Material; // Material type + struct Light; // Light type, defines light properties + struct Model; // Basic 3d Model type + struct Ray; // Ray type (useful for raycast) + struct RayHitInfo; // Raycast hit information + + struct Wave; // Wave type, defines audio wave data + struct Sound; // Basic Sound source and buffer + struct Music; // Music type (file streaming from memory) + struct AudioStream; // Raw audio stream type + diff --git a/cheatsheet/raylib_text.c b/cheatsheet/raylib_text.c new file mode 100644 index 0000000..1c164e5 --- /dev/null +++ b/cheatsheet/raylib_text.c @@ -0,0 +1,19 @@ + + // SpriteFont loading/unloading functions + SpriteFont GetDefaultFont(void); // Get the default SpriteFont + SpriteFont LoadSpriteFont(const char *fileName); // Load a SpriteFont image into GPU memory + SpriteFont LoadSpriteFontEx(const char *fileName, int fontSize, int numChars, int *fontChars); // Load a SpriteFont from TTF font with parameters + void UnloadSpriteFont(SpriteFont spriteFont); // Unload SpriteFont from GPU memory + + // Text drawing functions + void DrawFPS(int posX, int posY); // Shows current FPS on top-left corner + void DrawText(const char *text, int posX, int posY, int fontSize, Color color); // Draw text (using default font) + void DrawTextEx(SpriteFont spriteFont, const char* text, Vector2 position, // Draw text using SpriteFont and additional parameters + int fontSize, int spacing, Color tint); + + // Text misc. functions + int MeasureText(const char *text, int fontSize); // Measure string width for default font + Vector2 MeasureTextEx(SpriteFont spriteFont, const char *text, int fontSize, int spacing); // Measure string size for SpriteFont + const char *FormatText(const char *text, ...); // Formatting of text with variables to 'embed' + const char *SubText(const char *text, int position, int length); // Get a piece of a text string + diff --git a/cheatsheet/raylib_textures.c b/cheatsheet/raylib_textures.c new file mode 100644 index 0000000..d776c56 --- /dev/null +++ b/cheatsheet/raylib_textures.c @@ -0,0 +1,52 @@ + + // Image/Texture2D data loading/unloading functions + Image LoadImage(const char *fileName); // Load an image into CPU memory (RAM) + Image LoadImageEx(Color *pixels, int width, int height); // Load image data from Color array data (RGBA - 32bit) + Image LoadImagePro(void *data, int width, int height, int format); // Load image from raw data with parameters + Image LoadImageRaw(const char *fileName, int width, int height, int format, int headerSize); // Load image data from RAW file + Texture2D LoadTexture(const char *fileName); // Load an image as texture into GPU memory + Texture2D LoadTextureFromImage(Image image); // Load a texture from image data + RenderTexture2D LoadRenderTexture(int width, int height); // Load a texture to be used for rendering + void UnloadImage(Image image); // Unload image from CPU memory (RAM) + void UnloadTexture(Texture2D texture); // Unload texture from GPU memory + void UnloadRenderTexture(RenderTexture2D target); // Unload render texture from GPU memory + Color *GetImageData(Image image); // Get pixel data from image as a Color struct array + Image GetTextureData(Texture2D texture); // Get pixel data from GPU texture and return an Image + void UpdateTexture(Texture2D texture, void *pixels); // Update GPU texture with new data + + // Image manipulation functions + void ImageToPOT(Image *image, Color fillColor); // Convert image to POT (power-of-two) + void ImageFormat(Image *image, int newFormat); // Convert image data to desired format + void ImageAlphaMask(Image *image, Image alphaMask); // Apply alpha mask to image + void ImageDither(Image *image, int rBpp, int gBpp, int bBpp, int aBpp); // Dither image data to 16bpp or lower (Floyd-Steinberg dithering) + Image ImageCopy(Image image); // Create an image duplicate (useful for transformations) + void ImageCrop(Image *image, Rectangle crop); // Crop an image to a defined rectangle + void ImageResize(Image *image, int newWidth, int newHeight); // Resize and image (bilinear filtering) + void ImageResizeNN(Image *image,int newWidth,int newHeight); // Resize and image (Nearest-Neighbor scaling algorithm) + Image ImageText(const char *text, int fontSize, Color color); // Create an image from text (default font) + Image ImageTextEx(SpriteFont font, const char *text, int fontSize, int spacing, Color tint); // Create an image from text (custom sprite font) + void ImageDraw(Image *dst, Image src, Rectangle srcRec, Rectangle dstRec); // Draw a source image within a destination image + void ImageDrawText(Image *dst, Vector2 position, const char *text, int fontSize, Color color); // Draw text (default font) within an image (destination) + void ImageDrawTextEx(Image *dst, Vector2 position, SpriteFont font, const char *text, + int fontSize, int spacing, Color color); // Draw text (custom sprite font) within image + void ImageFlipVertical(Image *image); // Flip image vertically + void ImageFlipHorizontal(Image *image); // Flip image horizontally + void ImageColorTint(Image *image, Color color); // Modify image color: tint + void ImageColorInvert(Image *image); // Modify image color: invert + void ImageColorGrayscale(Image *image); // Modify bimage color: grayscale + void ImageColorContrast(Image *image, float contrast); // Modify image color: contrast (-100 to 100) + void ImageColorBrightness(Image *image, int brightness); // Modify image color: brightness (-255 to 255) + + // Texture2D configuration functions + void GenTextureMipmaps(Texture2D *texture); // Generate GPU mipmaps for a texture + void SetTextureFilter(Texture2D texture, int filterMode); // Set texture scaling filter mode + void SetTextureWrap(Texture2D texture, int wrapMode); // Set texture wrapping mode + + // Texture2D drawing functions + void DrawTexture(Texture2D texture, int posX, int posY, Color tint); // Draw a Texture2D + void DrawTextureV(Texture2D texture, Vector2 position, Color tint); // Draw a Texture2D with position defined as Vector2 + void DrawTextureEx(Texture2D texture, Vector2 position, float rotation, float scale, Color tint); // Draw a Texture2D with extended parameters + void DrawTextureRec(Texture2D texture, Rectangle sourceRec, Vector2 position, Color tint); // Draw a part of a texture defined by a rectangle + void DrawTexturePro(Texture2D texture, Rectangle sourceRec, Rectangle destRec, Vector2 origin, // Draw a part of a texture defined by a rectangle with 'pro' parameters + float rotation, Color tint); + |
