Browse Source

Updated some examples

pull/5359/head
Ray 2 weeks ago
parent
commit
a590126351
5 changed files with 14 additions and 22 deletions
  1. +4
    -4
      examples/core/core_custom_logging.c
  2. +4
    -8
      examples/core/core_directory_files.c
  3. +2
    -0
      examples/core/core_input_gestures.c
  4. +2
    -2
      examples/core/core_input_gestures_testbed.c
  5. +2
    -8
      examples/core/core_input_mouse.c

+ 4
- 4
examples/core/core_custom_logging.c View File

@ -17,11 +17,11 @@
#include "raylib.h" #include "raylib.h"
#include <stdio.h> // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen()
#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime()
#include <stdio.h> // Required for: printf(), vprintf(), fprintf()
#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime()
// Custom logging function // Custom logging function
void CustomLog(int msgType, const char *text, va_list args)
void CustomTraceLog(int msgType, const char *text, va_list args)
{ {
char timeStr[64] = { 0 }; char timeStr[64] = { 0 };
time_t now = time(NULL); time_t now = time(NULL);
@ -54,7 +54,7 @@ int main(void)
const int screenHeight = 450; const int screenHeight = 450;
// Set custom logger // Set custom logger
SetTraceLogCallback(CustomLog);
SetTraceLogCallback(CustomTraceLog);
InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging"); InitWindow(screenWidth, screenHeight, "raylib [core] example - custom logging");

+ 4
- 8
examples/core/core_directory_files.c View File

@ -20,9 +20,7 @@
#define RAYGUI_IMPLEMENTATION #define RAYGUI_IMPLEMENTATION
#include "raygui.h" // Required for GUI controls #include "raygui.h" // Required for GUI controls
#include <string.h> // Required for: strcpy()
#define MAX_FILEPATH_SIZE 2048
#define MAX_FILEPATH_SIZE 1024
//------------------------------------------------------------------------------------ //------------------------------------------------------------------------------------
// Program main entry point // Program main entry point
@ -53,12 +51,10 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (btnBackPressed) if (btnBackPressed)
{ {
strcpy(directory, GetPrevDirectoryPath(directory));
TextCopy(directory, GetPrevDirectoryPath(directory));
UnloadDirectoryFiles(files); UnloadDirectoryFiles(files);
files = LoadDirectoryFiles(directory); files = LoadDirectoryFiles(directory);
} }
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
// Draw // Draw
@ -68,7 +64,7 @@ int main(void)
DrawText(directory, 100, 40, 20, DARKGRAY); DrawText(directory, 100, 40, 20, DARKGRAY);
btnBackPressed = GuiButton((Rectangle){ 40.0f, 40.0f, 20, 20 }, "<");
btnBackPressed = GuiButton((Rectangle){ 40.0f, 38.0f, 48, 24 }, "<");
for (int i = 0; i < (int)files.count; i++) for (int i = 0; i < (int)files.count; i++)
{ {
@ -78,7 +74,7 @@ int main(void)
{ {
if (GuiButton((Rectangle){0.0f, 85.0f + 40.0f*(float)i, screenWidth, 40}, "")) if (GuiButton((Rectangle){0.0f, 85.0f + 40.0f*(float)i, screenWidth, 40}, ""))
{ {
strcpy(directory, files.paths[i]);
TextCopy(directory, files.paths[i]);
UnloadDirectoryFiles(files); UnloadDirectoryFiles(files);
files = LoadDirectoryFiles(directory); files = LoadDirectoryFiles(directory);
continue; continue;

+ 2
- 0
examples/core/core_input_gestures.c View File

@ -118,4 +118,6 @@ int main(void)
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context CloseWindow(); // Close window and OpenGL context
//-------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------
return 0;
} }

+ 2
- 2
examples/core/core_input_gestures_testbed.c View File

@ -22,9 +22,9 @@
#define GESTURE_LOG_SIZE 20 #define GESTURE_LOG_SIZE 20
#define MAX_TOUCH_COUNT 32 #define MAX_TOUCH_COUNT 32
//----------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
// Module Functions Declaration // Module Functions Declaration
//----------------------------------------------------------------------------------
//------------------------------------------------------------------------------------
static char const *GetGestureName(int gesture); // Get text string for gesture value static char const *GetGestureName(int gesture); // Get text string for gesture value
static Color GetGestureColor(int gesture); // Get color for gesture value static Color GetGestureColor(int gesture); // Get color for gesture value

+ 2
- 8
examples/core/core_input_mouse.c View File

@ -40,14 +40,8 @@ int main(void)
//---------------------------------------------------------------------------------- //----------------------------------------------------------------------------------
if (IsKeyPressed(KEY_H)) if (IsKeyPressed(KEY_H))
{ {
if (IsCursorHidden())
{
ShowCursor();
}
else
{
HideCursor();
}
if (IsCursorHidden()) ShowCursor();
else HideCursor();
} }
ballPosition = GetMousePosition(); ballPosition = GetMousePosition();

Loading…
Cancel
Save