mirror of
https://github.com/raysan5/raylib.git
synced 2025-12-06 06:13:10 +00:00
Updated some examples
This commit is contained in:
parent
063986fdae
commit
a590126351
@ -17,11 +17,11 @@
|
|||||||
|
|
||||||
#include "raylib.h"
|
#include "raylib.h"
|
||||||
|
|
||||||
#include <stdio.h> // Required for: fopen(), fclose(), fputc(), fwrite(), printf(), fprintf(), funopen()
|
#include <stdio.h> // Required for: printf(), vprintf(), fprintf()
|
||||||
#include <time.h> // Required for: time_t, tm, time(), localtime(), strftime()
|
#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");
|
||||||
|
|
||||||
|
|||||||
@ -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 1024
|
||||||
|
|
||||||
#define MAX_FILEPATH_SIZE 2048
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------------
|
||||||
// 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;
|
||||||
|
|||||||
@ -118,4 +118,6 @@ int main(void)
|
|||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
@ -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
|
||||||
|
|
||||||
|
|||||||
@ -40,14 +40,8 @@ int main(void)
|
|||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
if (IsKeyPressed(KEY_H))
|
if (IsKeyPressed(KEY_H))
|
||||||
{
|
{
|
||||||
if (IsCursorHidden())
|
if (IsCursorHidden()) ShowCursor();
|
||||||
{
|
else HideCursor();
|
||||||
ShowCursor();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HideCursor();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ballPosition = GetMousePosition();
|
ballPosition = GetMousePosition();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user