diff options
| -rw-r--r-- | projects/4coder/Makefile | 4 | ||||
| -rw-r--r-- | projects/CodeBlocks/core_basic_window.cbp | 8 | ||||
| -rw-r--r-- | projects/Geany/raylib_compile_execute.bat | 4 | ||||
| -rw-r--r-- | projects/Geany/raylib_compile_sources.bat | 6 | ||||
| -rw-r--r-- | projects/VSCode/.vscode/c_cpp_properties.json | 2 | ||||
| -rw-r--r-- | projects/VSCode/.vscode/launch.json | 4 | ||||
| -rw-r--r-- | projects/VSCode/.vscode/tasks.json | 4 | ||||
| -rw-r--r-- | projects/VSCode/Makefile | 4 | ||||
| -rw-r--r-- | src/camera.h | 68 | ||||
| -rw-r--r-- | src/config.h | 2 |
10 files changed, 67 insertions, 39 deletions
diff --git a/projects/4coder/Makefile b/projects/4coder/Makefile index 63d093a2..a00f4fab 100644 --- a/projects/4coder/Makefile +++ b/projects/4coder/Makefile @@ -27,7 +27,7 @@ PROJECT_NAME ?= game RAYLIB_VERSION ?= 2.5.0 RAYLIB_API_VERSION ?= 2 -RAYLIB_PATH ?= C:\GitHub\raylib +RAYLIB_PATH ?= ..\.. # Define default options @@ -200,7 +200,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) # resource file contains windows executable icon and properties # -Wl,--subsystem,windows hides the console window - CFLAGS += $(RAYLIB_PATH)/raylib.rc.data -Wl,--subsystem,windows + CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data -Wl,--subsystem,windows endif ifeq ($(PLATFORM_OS),LINUX) ifeq ($(RAYLIB_LIBTYPE),STATIC) diff --git a/projects/CodeBlocks/core_basic_window.cbp b/projects/CodeBlocks/core_basic_window.cbp index 0000860f..c4b22a9e 100644 --- a/projects/CodeBlocks/core_basic_window.cbp +++ b/projects/CodeBlocks/core_basic_window.cbp @@ -13,11 +13,11 @@ <Option compiler="gcc" /> <Compiler> <Add option="-g" /> - <Add directory="../../raylib/raylib/release/include" /> + <Add directory="../../src" /> </Compiler> <Linker> <Add option="-lraylib -lopengl32 -lgdi32 -lwinmm" /> - <Add library="../../../../raylib/raylib/release/libs/win32/mingw32/libraylib.a" /> + <Add library="../../src/libraylib.a" /> </Linker> </Target> <Target title="Release"> @@ -27,12 +27,12 @@ <Option compiler="gcc" /> <Compiler> <Add option="-O2" /> - <Add directory="../../../../raylib/raylib/release/include" /> + <Add directory="../../src" /> </Compiler> <Linker> <Add option="-s" /> <Add option="-lraylib -lopengl32 -lgdi32 -lwinmm" /> - <Add library="../../../../raylib/raylib/release/libs/win32/mingw32/libraylib.a" /> + <Add library="../../src/libraylib.a" /> </Linker> </Target> </Build> diff --git a/projects/Geany/raylib_compile_execute.bat b/projects/Geany/raylib_compile_execute.bat index eeba0b05..09783383 100644 --- a/projects/Geany/raylib_compile_execute.bat +++ b/projects/Geany/raylib_compile_execute.bat @@ -2,7 +2,7 @@ :: > Setup required Environment :: ------------------------------------- set RAYLIB_DIR=C:\raylib -set PATH=%PATH%;%RAYLIB_DIR%\mingw32\bin +set PATH=%PATH%;%RAYLIB_DIR%\mingw\bin set FILE_NAME=%1 set NAME_PART=%FILE_NAME:~0,-2% cd %~dp0 @@ -13,7 +13,7 @@ cmd /c if exist %NAME_PART%.exe del /F %NAME_PART%.exe :: . :: > Compiling program :: -------------------------- -gcc -o %NAME_PART%.exe %FILE_NAME% %RAYLIB_DIR%\raylib.rc.data -s -O2 -I../../src -Iexternal -lraylib -lopengl32 -lgdi32 -lwinmm -std=c99 -Wall -mwindows +gcc -o %NAME_PART%.exe %FILE_NAME% %RAYLIB_DIR%\src\raylib.rc.data -s -O2 -I../../src -Iexternal -lraylib -lopengl32 -lgdi32 -lwinmm -std=c99 -Wall -mwindows :: . :: . > Executing program :: ------------------------- diff --git a/projects/Geany/raylib_compile_sources.bat b/projects/Geany/raylib_compile_sources.bat index f0090990..c17ffba9 100644 --- a/projects/Geany/raylib_compile_sources.bat +++ b/projects/Geany/raylib_compile_sources.bat @@ -7,7 +7,7 @@ set GRAPHICS_API=GRAPHICS_API_OPENGL_33 :: > Setup required Environment :: ------------------------------------- set RAYLIB_DIR=C:\raylib -set PATH=%PATH%;%RAYLIB_DIR%\mingw32\bin +set PATH=%PATH%;%RAYLIB_DIR%\mingw\bin cd %RAYLIB_DIR%\raylib\src :: . :: > Cleaning latest build @@ -33,8 +33,8 @@ ar rcs libraylib.a core.o rglfw.o shapes.o textures.o text.o models.o raudio.o u :: . :: > Installing raylib library :: ----------------------------- -cmd /c copy raylib.h %RAYLIB_DIR%\mingw32\i686-w64-mingw32\include /Y -cmd /c copy libraylib.a %RAYLIB_DIR%\mingw32\i686-w64-mingw32\lib /Y +cmd /c copy raylib.h %RAYLIB_DIR%\mingw\i686-w64-mingw32\include /Y +cmd /c copy libraylib.a %RAYLIB_DIR%\mingw\i686-w64-mingw32\lib /Y :: . :: > Restore environment :: ----------------------------- diff --git a/projects/VSCode/.vscode/c_cpp_properties.json b/projects/VSCode/.vscode/c_cpp_properties.json index d4d8e14a..496a9b2d 100644 --- a/projects/VSCode/.vscode/c_cpp_properties.json +++ b/projects/VSCode/.vscode/c_cpp_properties.json @@ -13,7 +13,7 @@ "GRAPHICS_API_OPENGL_33", "PLATFORM_DESKTOP" ], - "compilerPath": "C:/raylib/mingw32/bin/gcc.exe", + "compilerPath": "C:/raylib/mingw/bin/gcc.exe", "cStandard": "c11", "cppStandard": "c++14", "intelliSenseMode": "clang-x64" diff --git a/projects/VSCode/.vscode/launch.json b/projects/VSCode/.vscode/launch.json index be3fa55a..afb54b7f 100644 --- a/projects/VSCode/.vscode/launch.json +++ b/projects/VSCode/.vscode/launch.json @@ -23,7 +23,7 @@ } ], "windows": { - "miDebuggerPath": "C:/raylib/mingw32/bin/gdb.exe", + "miDebuggerPath": "C:/raylib/mingw/bin/gdb.exe", }, "osx": { "MIMode": "lldb" @@ -46,7 +46,7 @@ "MIMode": "gdb", "windows": { "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe", - "miDebuggerPath": "C:/raylib/mingw32/bin/gdb.exe" + "miDebuggerPath": "C:/raylib/mingw/bin/gdb.exe" }, "osx": { "MIMode": "lldb" diff --git a/projects/VSCode/.vscode/tasks.json b/projects/VSCode/.vscode/tasks.json index 0d8be4cf..072fa179 100644 --- a/projects/VSCode/.vscode/tasks.json +++ b/projects/VSCode/.vscode/tasks.json @@ -12,7 +12,7 @@ "DEBUGGING=TRUE" ], "windows": { - "command": "C:/raylib/mingw32/bin/mingw32-make.exe", + "command": "C:/raylib/mingw/bin/mingw32-make.exe", "args": [ "RAYLIB_PATH=C:/raylib/raylib" ], @@ -35,7 +35,7 @@ "PLATFORM=PLATFORM_DESKTOP", ], "windows": { - "command": "C:/raylib/mingw32/bin/mingw32-make.exe", + "command": "C:/raylib/mingw/bin/mingw32-make.exe", "args": [ "RAYLIB_PATH=C:/raylib/raylib", ], diff --git a/projects/VSCode/Makefile b/projects/VSCode/Makefile index 63d093a2..a00f4fab 100644 --- a/projects/VSCode/Makefile +++ b/projects/VSCode/Makefile @@ -27,7 +27,7 @@ PROJECT_NAME ?= game RAYLIB_VERSION ?= 2.5.0 RAYLIB_API_VERSION ?= 2 -RAYLIB_PATH ?= C:\GitHub\raylib +RAYLIB_PATH ?= ..\.. # Define default options @@ -200,7 +200,7 @@ ifeq ($(PLATFORM),PLATFORM_DESKTOP) ifeq ($(PLATFORM_OS),WINDOWS) # resource file contains windows executable icon and properties # -Wl,--subsystem,windows hides the console window - CFLAGS += $(RAYLIB_PATH)/raylib.rc.data -Wl,--subsystem,windows + CFLAGS += $(RAYLIB_PATH)/src/raylib.rc.data -Wl,--subsystem,windows endif ifeq ($(PLATFORM_OS),LINUX) ifeq ($(RAYLIB_LIBTYPE),STATIC) diff --git a/src/camera.h b/src/camera.h index d80f8346..1d580a20 100644 --- a/src/camera.h +++ b/src/camera.h @@ -410,8 +410,7 @@ void UpdateCamera(Camera *camera) } break; case CAMERA_FIRST_PERSON: - case CAMERA_THIRD_PERSON: - { + { camera->position.x += (sinf(cameraAngle.x)*direction[MOVE_BACK] - sinf(cameraAngle.x)*direction[MOVE_FRONT] - cosf(cameraAngle.x)*direction[MOVE_LEFT] + @@ -433,7 +432,7 @@ void UpdateCamera(Camera *camera) // Camera orientation calculation cameraAngle.x += (mousePositionDelta.x*-CAMERA_MOUSE_MOVE_SENSITIVITY); cameraAngle.y += (mousePositionDelta.y*-CAMERA_MOUSE_MOVE_SENSITIVITY); - + // Angle clamp if (cameraAngle.y > CAMERA_FIRST_PERSON_MIN_CLAMP*DEG2RAD) cameraAngle.y = CAMERA_FIRST_PERSON_MIN_CLAMP*DEG2RAD; else if (cameraAngle.y < CAMERA_FIRST_PERSON_MAX_CLAMP*DEG2RAD) cameraAngle.y = CAMERA_FIRST_PERSON_MAX_CLAMP*DEG2RAD; @@ -442,28 +441,57 @@ void UpdateCamera(Camera *camera) camera->target.x = camera->position.x - sinf(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE; camera->target.y = camera->position.y + sinf(cameraAngle.y)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE; camera->target.z = camera->position.z - cosf(cameraAngle.x)*CAMERA_FIRST_PERSON_FOCUS_DISTANCE; - - if (cameraMode == CAMERA_FIRST_PERSON) - { - if (isMoving) swingCounter++; + + if (isMoving) swingCounter++; - // Camera position update - // NOTE: On CAMERA_FIRST_PERSON player Y-movement is limited to player 'eyes position' - camera->position.y = playerEyesPosition - sinf(swingCounter/CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER)/CAMERA_FIRST_PERSON_STEP_DIVIDER; + // Camera position update + // NOTE: On CAMERA_FIRST_PERSON player Y-movement is limited to player 'eyes position' + camera->position.y = playerEyesPosition - sinf(swingCounter/CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER)/CAMERA_FIRST_PERSON_STEP_DIVIDER; - camera->up.x = sinf(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER; - camera->up.z = -sinf(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER; - } - else if (cameraMode == CAMERA_THIRD_PERSON) - { - // Camera zoom - cameraTargetDistance -= (mouseWheelMove*CAMERA_MOUSE_SCROLL_SENSITIVITY); - if (cameraTargetDistance < CAMERA_THIRD_PERSON_DISTANCE_CLAMP) cameraTargetDistance = CAMERA_THIRD_PERSON_DISTANCE_CLAMP; - } + camera->up.x = sinf(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER; + camera->up.z = -sinf(swingCounter/(CAMERA_FIRST_PERSON_STEP_TRIGONOMETRIC_DIVIDER*2))/CAMERA_FIRST_PERSON_WAVING_DIVIDER; + } break; + case CAMERA_THIRD_PERSON: + { + camera->position.x += (sinf(cameraAngle.x)*direction[MOVE_BACK] - + sinf(cameraAngle.x)*direction[MOVE_FRONT] - + cosf(cameraAngle.x)*direction[MOVE_LEFT] + + cosf(cameraAngle.x)*direction[MOVE_RIGHT])/PLAYER_MOVEMENT_SENSITIVITY; + + camera->position.y += (sinf(cameraAngle.y)*direction[MOVE_FRONT] - + sinf(cameraAngle.y)*direction[MOVE_BACK] + + 1.0f*direction[MOVE_UP] - 1.0f*direction[MOVE_DOWN])/PLAYER_MOVEMENT_SENSITIVITY; + + camera->position.z += (cosf(cameraAngle.x)*direction[MOVE_BACK] - + cosf(cameraAngle.x)*direction[MOVE_FRONT] + + sinf(cameraAngle.x)*direction[MOVE_LEFT] - + sinf(cameraAngle.x)*direction[MOVE_RIGHT])/PLAYER_MOVEMENT_SENSITIVITY; + + + // Camera orientation calculation + cameraAngle.x += (mousePositionDelta.x*-CAMERA_MOUSE_MOVE_SENSITIVITY); + cameraAngle.y += (mousePositionDelta.y*-CAMERA_MOUSE_MOVE_SENSITIVITY); + + // Angle clamp + if (cameraAngle.y > CAMERA_THIRD_PERSON_MIN_CLAMP*DEG2RAD) cameraAngle.y = CAMERA_THIRD_PERSON_MIN_CLAMP*DEG2RAD; + else if (cameraAngle.y < CAMERA_THIRD_PERSON_MAX_CLAMP*DEG2RAD) cameraAngle.y = CAMERA_THIRD_PERSON_MAX_CLAMP*DEG2RAD; + + // Camera zoom + cameraTargetDistance -= (mouseWheelMove*CAMERA_MOUSE_SCROLL_SENSITIVITY); + + // Camera distance clamp + if (cameraTargetDistance < CAMERA_THIRD_PERSON_DISTANCE_CLAMP) cameraTargetDistance = CAMERA_THIRD_PERSON_DISTANCE_CLAMP; + + // TODO: It seems camera->position is not correctly updated or some rounding issue makes the camera move straight to camera->target... + camera->position.x = sinf(cameraAngle.x)*cameraTargetDistance*cosf(cameraAngle.y) + camera->target.x; + if (cameraAngle.y <= 0.0f) camera->position.y = sinf(cameraAngle.y)*cameraTargetDistance*sinf(cameraAngle.y) + camera->target.y; + else camera->position.y = -sinf(cameraAngle.y)*cameraTargetDistance*sinf(cameraAngle.y) + camera->target.y; + camera->position.z = cosf(cameraAngle.x)*cameraTargetDistance*cosf(cameraAngle.y) + camera->target.z; + } break; default: break; - } + } } // Set camera pan key to combine with mouse movement (free camera) diff --git a/src/config.h b/src/config.h index b4c5c3d1..07cf5fe7 100644 --- a/src/config.h +++ b/src/config.h @@ -43,7 +43,7 @@ // Mouse gestures are directly mapped like touches and processed by gestures system #define SUPPORT_MOUSE_GESTURES 1 // Reconfigure standard input to receive key inputs, works with SSH connection. -//#define SUPPORT_SSH_KEYBOARD_RPI 1 +#define SUPPORT_SSH_KEYBOARD_RPI 1 // Use busy wait loop for timing sync, if not defined, a high-resolution timer is setup and used //#define SUPPORT_BUSY_WAIT_LOOP 1 // Wait for events passively (sleeping while no events) instead of polling them actively every frame |
