From dd16f39ccaa4689004c0e3f04b40b6ad74f95809 Mon Sep 17 00:00:00 2001 From: kyomawolf Date: Fri, 16 Feb 2024 20:15:38 +0100 Subject: [PATCH 1/2] fixed compiler warnings --- include/AutomationEventList.hpp | 2 +- include/Functions.hpp | 92 ++++++++++++++++----------------- 2 files changed, 47 insertions(+), 47 deletions(-) diff --git a/include/AutomationEventList.hpp b/include/AutomationEventList.hpp index 9c56185f..f005aa2f 100644 --- a/include/AutomationEventList.hpp +++ b/include/AutomationEventList.hpp @@ -119,7 +119,7 @@ class AutomationEventList : public ::AutomationEventList { } void Play(int index) { - if (index < 0 || index >= this->count) { + if (index < 0 || static_cast(index) >= this->count) { return; } diff --git a/include/Functions.hpp b/include/Functions.hpp index 201066d3..ddae8a50 100644 --- a/include/Functions.hpp +++ b/include/Functions.hpp @@ -21,56 +21,56 @@ namespace raylib { /** * Initialize window and OpenGL context */ -RLCPPAPI inline void InitWindow(int width, int height, const std::string& title = "raylib") { + [[maybe_unused]] RLCPPAPI inline void InitWindow(int width, int height, const std::string& title = "raylib") { ::InitWindow(width, height, title.c_str()); } /** * Set title for window */ -RLCPPAPI inline void SetWindowTitle(const std::string& title) { + [[maybe_unused]] RLCPPAPI inline void SetWindowTitle(const std::string& title) { ::SetWindowTitle(title.c_str()); } /** * Get the human-readable, UTF-8 encoded name of the primary monitor */ -RLCPPAPI inline std::string GetMonitorName(int monitor = 0) { + [[maybe_unused]] RLCPPAPI inline std::string GetMonitorName(int monitor = 0) { return ::GetMonitorName(monitor); } /** * Set clipboard text content */ -RLCPPAPI inline void SetClipboardText(const std::string& text) { + [[maybe_unused]] RLCPPAPI inline void SetClipboardText(const std::string& text) { ::SetClipboardText(text.c_str()); } /** * Get clipboard text content */ -RLCPPAPI inline std::string GetClipboardText() { + [[maybe_unused]] RLCPPAPI inline std::string GetClipboardText() { return ::GetClipboardText(); } /** * Takes a screenshot of current screen (saved a .png) */ -RLCPPAPI inline void TakeScreenshot(const std::string& fileName) { + [[maybe_unused]] RLCPPAPI inline void TakeScreenshot(const std::string& fileName) { ::TakeScreenshot(fileName.c_str()); } /** * Get gamepad internal name id */ -RLCPPAPI inline std::string GetGamepadName(int gamepad) { + [[maybe_unused]] RLCPPAPI inline std::string GetGamepadName(int gamepad) { return ::GetGamepadName(gamepad); } /** * Load text data from file (read) */ -RLCPPAPI std::string LoadFileText(const std::string& fileName) { + [[maybe_unused]] RLCPPAPI std::string LoadFileText(const std::string& fileName) { char* text = ::LoadFileText(fileName.c_str()); std::string output(text); ::UnloadFileText(text); @@ -80,77 +80,77 @@ RLCPPAPI std::string LoadFileText(const std::string& fileName) { /** * Save text data to file (write) */ -RLCPPAPI inline bool SaveFileText(const std::string& fileName, const std::string& text) { + [[maybe_unused]] RLCPPAPI inline bool SaveFileText(const std::string& fileName, const std::string& text) { return ::SaveFileText(fileName.c_str(), const_cast(text.c_str())); } /** * Check if file exists */ -RLCPPAPI inline bool FileExists(const std::string& fileName) { + [[maybe_unused]] RLCPPAPI inline bool FileExists(const std::string& fileName) { return ::FileExists(fileName.c_str()); } /** * Check if directory path exists */ -RLCPPAPI inline bool DirectoryExists(const std::string& dirPath) { + [[maybe_unused]] RLCPPAPI inline bool DirectoryExists(const std::string& dirPath) { return ::DirectoryExists(dirPath.c_str()); } /** * Check file extension (including point: .png, .wav) */ -RLCPPAPI inline bool IsFileExtension(const std::string& fileName, const std::string& ext) { + [[maybe_unused]] RLCPPAPI inline bool IsFileExtension(const std::string& fileName, const std::string& ext) { return ::IsFileExtension(fileName.c_str(), ext.c_str()); } /** * Get pointer to extension for a filename string (including point: ".png") */ -RLCPPAPI inline std::string GetFileExtension(const std::string& fileName) { + [[maybe_unused]] RLCPPAPI inline std::string GetFileExtension(const std::string& fileName) { return ::GetFileExtension(fileName.c_str()); } /** * Get pointer to filename for a path string */ -RLCPPAPI inline std::string GetFileName(const std::string& filePath) { + [[maybe_unused]] RLCPPAPI inline std::string GetFileName(const std::string& filePath) { return ::GetFileName(filePath.c_str()); } /** * Get filename string without extension */ -RLCPPAPI inline std::string GetFileNameWithoutExt(const std::string& filePath) { + [[maybe_unused]] RLCPPAPI inline std::string GetFileNameWithoutExt(const std::string& filePath) { return ::GetFileNameWithoutExt(filePath.c_str()); } /** * Get full path for a given fileName with path */ -RLCPPAPI inline std::string GetDirectoryPath(const std::string& filePath) { + [[maybe_unused]] RLCPPAPI inline std::string GetDirectoryPath(const std::string& filePath) { return ::GetDirectoryPath(filePath.c_str()); } /** * Get previous directory path for a given path */ -RLCPPAPI inline std::string GetPrevDirectoryPath(const std::string& dirPath) { + [[maybe_unused]] RLCPPAPI inline std::string GetPrevDirectoryPath(const std::string& dirPath) { return ::GetPrevDirectoryPath(dirPath.c_str()); } /** * Get current working directory */ -RLCPPAPI inline std::string GetWorkingDirectory() { + [[maybe_unused]] RLCPPAPI inline std::string GetWorkingDirectory() { return ::GetWorkingDirectory(); } /** * Get filenames in a directory path */ -RLCPPAPI std::vector LoadDirectoryFiles(const std::string& dirPath) { + [[maybe_unused]] RLCPPAPI std::vector LoadDirectoryFiles(const std::string& dirPath) { FilePathList files = ::LoadDirectoryFiles(dirPath.c_str()); std::vector output(files.paths, files.paths + files.count); ::UnloadDirectoryFiles(files); @@ -160,14 +160,14 @@ RLCPPAPI std::vector LoadDirectoryFiles(const std::string& dirPath) /** * Change working directory, return true on success */ -RLCPPAPI inline bool ChangeDirectory(const std::string& dir) { + [[maybe_unused]] RLCPPAPI inline bool ChangeDirectory(const std::string& dir) { return ::ChangeDirectory(dir.c_str()); } /** * Get dropped files names */ -RLCPPAPI std::vector LoadDroppedFiles() { + [[maybe_unused]] RLCPPAPI std::vector LoadDroppedFiles() { if (!::IsFileDropped()) { return std::vector(); } @@ -180,28 +180,28 @@ RLCPPAPI std::vector LoadDroppedFiles() { /** * Get file modification time (last write time) */ -RLCPPAPI inline long GetFileModTime(const std::string& fileName) { // NOLINT + [[maybe_unused]] RLCPPAPI inline long GetFileModTime(const std::string& fileName) { // NOLINT return ::GetFileModTime(fileName.c_str()); } /** * Open URL with default system browser (if available) */ -RLCPPAPI inline void OpenURL(const std::string& url) { + [[maybe_unused]] RLCPPAPI inline void OpenURL(const std::string& url) { return ::OpenURL(url.c_str()); } /** * Load an image. */ -RLCPPAPI inline ::Image LoadImage(const std::string& fileName) { + [[maybe_unused]] RLCPPAPI inline ::Image LoadImage(const std::string& fileName) { return ::LoadImage(fileName.c_str()); } /** * Load an image from RAW file data */ -RLCPPAPI inline ::Image LoadImageRaw(const std::string& fileName, + [[maybe_unused]] RLCPPAPI inline ::Image LoadImageRaw(const std::string& fileName, int width, int height, int format, int headerSize) { return ::LoadImageRaw(fileName.c_str(), width, height, format, headerSize); @@ -210,14 +210,14 @@ RLCPPAPI inline ::Image LoadImageRaw(const std::string& fileName, /** * Load animated image data */ -RLCPPAPI inline ::Image LoadImageAnim(const std::string& fileName, int *frames) { + [[maybe_unused]] RLCPPAPI inline ::Image LoadImageAnim(const std::string& fileName, int *frames) { return ::LoadImageAnim(fileName.c_str(), frames); } /** * Load image from memory buffer, fileType refers to extension like "png" */ -RLCPPAPI inline ::Image LoadImageFromMemory(const std::string& fileType, + [[maybe_unused]] RLCPPAPI inline ::Image LoadImageFromMemory(const std::string& fileType, const unsigned char *fileData, int dataSize) { return ::LoadImageFromMemory(fileType.c_str(), fileData, dataSize); @@ -226,28 +226,28 @@ RLCPPAPI inline ::Image LoadImageFromMemory(const std::string& fileType, /** * Export image data to file */ -RLCPPAPI inline bool ExportImage(const Image& image, const std::string& fileName) { + [[maybe_unused]] RLCPPAPI inline bool ExportImage(const Image& image, const std::string& fileName) { return ::ExportImage(image, fileName.c_str()); } /** * Export image as code file (.h) defining an array of bytes */ -RLCPPAPI inline bool ExportImageAsCode(const Image& image, const std::string& fileName) { + [[maybe_unused]] RLCPPAPI inline bool ExportImageAsCode(const Image& image, const std::string& fileName) { return ::ExportImageAsCode(image, fileName.c_str()); } /** * Draw text (using default font) */ -RLCPPAPI inline void DrawText(const std::string& text, int posX, int posY, int fontSize, ::Color color) { + [[maybe_unused]] RLCPPAPI inline void DrawText(const std::string& text, int posX, int posY, int fontSize, ::Color color) { ::DrawText(text.c_str(), posX, posY, fontSize, color); } /** * Draw text using font and additional parameters */ -RLCPPAPI inline void DrawTextEx(const Font& font, const std::string& text, Vector2 position, + [[maybe_unused]] RLCPPAPI inline void DrawTextEx(const Font& font, const std::string& text, Vector2 position, float fontSize, float spacing, ::Color tint) { ::DrawTextEx(font, text.c_str(), position, fontSize, spacing, tint); } @@ -255,7 +255,7 @@ RLCPPAPI inline void DrawTextEx(const Font& font, const std::string& text, Vecto /** * Draw text using Font and pro parameters (rotation) */ -RLCPPAPI inline void DrawTextPro(const Font& font, const std::string& text, Vector2 position, + [[maybe_unused]] RLCPPAPI inline void DrawTextPro(const Font& font, const std::string& text, Vector2 position, Vector2 origin, float rotation, float fontSize, float spacing, ::Color tint) { ::DrawTextPro(font, text.c_str(), position, origin, rotation, fontSize, spacing, tint); } @@ -263,49 +263,49 @@ RLCPPAPI inline void DrawTextPro(const Font& font, const std::string& text, Vect /** * Load font from file (filename must include file extension) */ -RLCPPAPI inline ::Font LoadFont(const std::string& fileName) { + [[maybe_unused]] RLCPPAPI inline ::Font LoadFont(const std::string& fileName) { return ::LoadFont(fileName.c_str()); } /** * Load font from file (filename must include file extension) */ -RLCPPAPI inline ::Font LoadFontEx(const std::string& fileName, int fontSize, int *fontChars, int charsCount) { + [[maybe_unused]] RLCPPAPI inline ::Font LoadFontEx(const std::string& fileName, int fontSize, int *fontChars, int charsCount) { return ::LoadFontEx(fileName.c_str(), fontSize, fontChars, charsCount); } /** * Measure string width for default font */ -RLCPPAPI inline int MeasureText(const std::string& text, int fontSize) { + [[maybe_unused]] RLCPPAPI inline int MeasureText(const std::string& text, int fontSize) { return ::MeasureText(text.c_str(), fontSize); } /** * Check if two text string are equal */ -RLCPPAPI inline bool TextIsEqual(const std::string& text1, const std::string& text2) { +[[maybe_unused]] RLCPPAPI inline bool TextIsEqual(const std::string& text1, const std::string& text2) { return ::TextIsEqual(text1.c_str(), text2.c_str()); } /** * Check if two text string are equal */ -RLCPPAPI inline unsigned int TextLength(const std::string& text) { +[[maybe_unused]] RLCPPAPI inline unsigned int TextLength(const std::string& text) { return ::TextLength(text.c_str()); } /** * Get text length, checks for '\0' ending */ -RLCPPAPI inline std::string TextSubtext(const std::string& text, int position, int length) { + [[maybe_unused]] RLCPPAPI inline std::string TextSubtext(const std::string& text, int position, int length) { return ::TextSubtext(text.c_str(), position, length); } /** * Replace text string */ -RLCPPAPI std::string TextReplace(const std::string& text, const std::string& replace, const std::string& by) { + [[maybe_unused]] RLCPPAPI std::string TextReplace(const std::string& text, const std::string& replace, const std::string& by) { const char* input = text.c_str(); char* output = ::TextReplace(const_cast(input), replace.c_str(), by.c_str()); if (output != NULL) { @@ -319,7 +319,7 @@ RLCPPAPI std::string TextReplace(const std::string& text, const std::string& rep /** * Insert text in a position */ -RLCPPAPI std::string TextInsert(const std::string& text, const std::string& insert, int position) { + [[maybe_unused]] RLCPPAPI std::string TextInsert(const std::string& text, const std::string& insert, int position) { char* output = ::TextInsert(text.c_str(), insert.c_str(), position); if (output != NULL) { std::string stringOutput(output); @@ -332,7 +332,7 @@ RLCPPAPI std::string TextInsert(const std::string& text, const std::string& inse /** * Split text into multiple strings */ -RLCPPAPI std::vector TextSplit(const std::string& text, char delimiter) { + [[maybe_unused]] RLCPPAPI std::vector TextSplit(const std::string& text, char delimiter) { int count; const char** split = ::TextSplit(text.c_str(), delimiter, &count); return std::vector(split, split + count); @@ -341,35 +341,35 @@ RLCPPAPI std::vector TextSplit(const std::string& text, char delimi /** * Find first text occurrence within a string */ -RLCPPAPI inline int TextFindIndex(const std::string& text, const std::string& find) { + [[maybe_unused]] RLCPPAPI inline int TextFindIndex(const std::string& text, const std::string& find) { return ::TextFindIndex(text.c_str(), find.c_str()); } /** * Get upper case version of provided string */ -RLCPPAPI inline std::string TextToUpper(const std::string& text) { + [[maybe_unused]] RLCPPAPI inline std::string TextToUpper(const std::string& text) { return ::TextToUpper(text.c_str()); } /** * Get lower case version of provided string */ -RLCPPAPI inline std::string TextToLower(const std::string& text) { + [[maybe_unused]] RLCPPAPI inline std::string TextToLower(const std::string& text) { return ::TextToLower(text.c_str()); } /** * Get Pascal case notation version of provided string */ -RLCPPAPI inline std::string TextToPascal(const std::string& text) { + [[maybe_unused]] RLCPPAPI inline std::string TextToPascal(const std::string& text) { return ::TextToPascal(text.c_str()); } /** * Get integer value from text (negative values not supported) */ -RLCPPAPI inline int TextToInteger(const std::string& text) { + [[maybe_unused]] RLCPPAPI inline int TextToInteger(const std::string& text) { return ::TextToInteger(text.c_str()); } From ea4ff37824e909a8ce1b745ec25997521e2d19a3 Mon Sep 17 00:00:00 2001 From: kyomawolf Date: Fri, 16 Feb 2024 20:28:43 +0100 Subject: [PATCH 2/2] #244 updated Example --- projects/VSCode/.vscode/launch.json | 6 +- projects/VSCode/.vscode/settings.json | 44 ++++++ projects/VSCode/FirstPerson.cpp | 218 +++++--------------------- projects/VSCode/Makefile | 4 +- 4 files changed, 88 insertions(+), 184 deletions(-) diff --git a/projects/VSCode/.vscode/launch.json b/projects/VSCode/.vscode/launch.json index afb54b7f..b65aa1c1 100644 --- a/projects/VSCode/.vscode/launch.json +++ b/projects/VSCode/.vscode/launch.json @@ -8,7 +8,7 @@ "name": "Debug", "type": "cppdbg", "request": "launch", - "program": "${workspaceFolder}/${fileBasenameNoExtension}", + "program": "${workspaceFolder}/game", "args": [], "stopAtEntry": false, "cwd": "${workspaceFolder}", @@ -42,10 +42,10 @@ "cwd": "${workspaceFolder}", "environment": [], "externalConsole": false, - "program": "${workspaceFolder}/${fileBasenameNoExtension}", + "program": "${workspaceFolder}/game", "MIMode": "gdb", "windows": { - "program": "${workspaceFolder}/${fileBasenameNoExtension}.exe", + "program": "${workspaceFolder}/game.exe", "miDebuggerPath": "C:/raylib/mingw/bin/gdb.exe" }, "osx": { diff --git a/projects/VSCode/.vscode/settings.json b/projects/VSCode/.vscode/settings.json index e98318a0..161cf881 100644 --- a/projects/VSCode/.vscode/settings.json +++ b/projects/VSCode/.vscode/settings.json @@ -7,5 +7,49 @@ "**/.DS_Store": true, "**/*.o": true, "**/*.exe": true, + }, + "files.associations": { + "array": "cpp", + "atomic": "cpp", + "bit": "cpp", + "*.tcc": "cpp", + "cctype": "cpp", + "clocale": "cpp", + "cmath": "cpp", + "compare": "cpp", + "concepts": "cpp", + "cstdarg": "cpp", + "cstddef": "cpp", + "cstdint": "cpp", + "cstdio": "cpp", + "cstdlib": "cpp", + "cwchar": "cpp", + "cwctype": "cpp", + "deque": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "vector": "cpp", + "exception": "cpp", + "algorithm": "cpp", + "functional": "cpp", + "iterator": "cpp", + "memory": "cpp", + "memory_resource": "cpp", + "numeric": "cpp", + "random": "cpp", + "string_view": "cpp", + "system_error": "cpp", + "tuple": "cpp", + "type_traits": "cpp", + "utility": "cpp", + "initializer_list": "cpp", + "iosfwd": "cpp", + "limits": "cpp", + "new": "cpp", + "numbers": "cpp", + "ostream": "cpp", + "stdexcept": "cpp", + "streambuf": "cpp", + "typeinfo": "cpp" } } \ No newline at end of file diff --git a/projects/VSCode/FirstPerson.cpp b/projects/VSCode/FirstPerson.cpp index 39b9865d..2f41b280 100644 --- a/projects/VSCode/FirstPerson.cpp +++ b/projects/VSCode/FirstPerson.cpp @@ -1,191 +1,51 @@ -#include "raylib.h" -#include -#include "raymath.h" -#include "camera.h" -#include "include/raylib-cpp.hpp" -#include - -#define MAX_COLUMNS 100 -#define CollisionDetectionThreshold 15 -const int screenWidth = 1280; -const int screenHeight = 720; -bool debug = false; -bool cameraCollided = false; -bool closeToCollider = false; - -// TODO: WRITE CUSTOM MOVEMENT CODE -// TODO: NEED TO CHECK Y AXIS COLLISIONS -// TODO: NEED TO IMPELEMENT PHYSICS -struct BoxCollider -{ - BoundingBox BBox; - Vector3 *center; - Vector3 extents; - - BoxCollider() {} - - BoxCollider(Vector3 ¢er, raylib::Vector3 extents) - { - this->center = ¢er; - this->extents = extents; - UpdateBoundingBox(); - } - void UpdateBoundingBox() - { - BBox.max.x = center->x + extents.x / 2; - BBox.max.y = center->y + extents.y / 2; - BBox.max.z = center->z + extents.z / 2; - - BBox.min.x = center->x - extents.x / 2; - BBox.min.y = center->y - extents.y / 2; - BBox.min.z = center->z - extents.z / 2; - } -}; - -struct Player -{ - raylib::Camera camera; - BoxCollider collider; - - Player() - { - camera = raylib::Camera(raylib::Vector3(4, 2, 4), raylib::Vector3(0.0f, 1.8f, 0.0f), - raylib::Vector3(0, 1, 0), 90.0f, CAMERA_PERSPECTIVE); - SetCameraMode(camera, CAMERA_FIRST_PERSON); - - collider = BoxCollider(camera.position, raylib::Vector3(1, 1, 1)); - } -}; - -float DistanceSquared(Vector3 *A, Vector3 *B) -{ - float dx = A->x - B->x; - float dy = A->y - B->y; - float dz = A->z - B->z; - return (dx * dx + dy * dy + dz * dz); -} - -void GetInput() -{ - if (IsKeyPressed(KEY_Q)) - debug = !debug; -} - -void Draw3D(Player player, Vector3 positions[], float heights[], Color colors[], BoxCollider BBoxes[]) -{ - BeginMode3D(player.camera); - DrawPlane((Vector3){0.0f, 0.0f, 0.0f}, (Vector2){32.0f, 32.0f}, LIGHTGRAY); - DrawCube((Vector3){-16.0f, 2.5f, 0.0f}, 1.0f, 5.0f, 32.0f, BLUE); - DrawCube((Vector3){16.0f, 2.5f, 0.0f}, 1.0f, 5.0f, 32.0f, LIME); - DrawCube((Vector3){0.0f, 2.5f, 16.0f}, 32.0f, 5.0f, 1.0f, GOLD); - - if (!debug) - { - for (int i = 0; i < MAX_COLUMNS; i++) - { - DrawCube(positions[i], 2.0f, heights[i], 2.0f, colors[i]); - DrawCubeWires(positions[i], 2.0f, heights[i], 2.0f, BLUE); - } - } - else - { - for (int i = 0; i < MAX_COLUMNS; i++) - { - DrawBoundingBox(BBoxes[i].BBox, GREEN); - } - DrawBoundingBox(player.collider.BBox, BLUE); - } - - EndMode3D(); -} - -void Draw2D() -{ - DrawText("First person camera default controls:", 20, 20, 10, BLACK); - DrawText("- Move with keys: W, A, S, D", 40, 40, 10, DARKGRAY); - DrawText("- Mouse move to look around", 40, 60, 10, DARKGRAY); - if(closeToCollider) - { - DrawText("CHECKING COLLISIONS", 40, 100, 20, BLUE); - closeToCollider = false; - } - if (cameraCollided) - DrawText("Colliding", 40, 80, 20, GREEN); -} - -void GenerateLevel(float heights[], BoxCollider BBoxes[], Vector3 positions[], Color colors[]) -{ - for (int i = 0; i < MAX_COLUMNS; i++) - { - heights[i] = (float)GetRandomValue(1, 12); - positions[i] = (Vector3){GetRandomValue(-15, 15), heights[i] / 2, GetRandomValue(-15, 15)}; - BBoxes[i].extents = (Vector3){2.0f, heights[i], 2.0f}; - BBoxes[i].center = &positions[i]; - BBoxes[i].UpdateBoundingBox(); - colors[i] = (Color){GetRandomValue(20, 255), GetRandomValue(10, 55), 30, 255}; - } -} - -void CheckPlayerCollisions(Player *player, BoxCollider BBoxes[]) -{ - for (int i = 0; i < MAX_COLUMNS; i++) - { - if (DistanceSquared(player->collider.center, BBoxes[i].center) < CollisionDetectionThreshold) - { - closeToCollider = true; - if (CheckCollisionBoxes(player->collider.BBox, BBoxes[i].BBox)) - { - cameraCollided = true; - return; - } - } - } - cameraCollided = false; +#include + + +void UpdateFrame(raylib::Window& window, raylib::Camera3D& cam) { + static raylib::Vector3 position; + + window.BeginDrawing(); + + cam.Update(CAMERA_ORBITAL); + + window.ClearBackground(raylib::Color::RayWhite()); + + cam.BeginMode(); + + position.DrawCube({2.0f, 2.0f, 2.0f}, raylib::Color::Red()); + position.DrawCubeWires({2.0f, 2.0f, 2.0f}, raylib::Color::Maroon()); + DrawGrid(10, 1.0f); + + cam.EndMode(); + + raylib::Vector2 textPosition{10, 40}; + raylib::Text sampleText( GetFontDefault(),"This is a raylib-cpp example", 20.0f, 20.0f /10.0f, raylib::Color::DarkGray()); + sampleText.Draw(textPosition); + window.EndDrawing(); + } -void Abbas() -{ - for (int i = 0; i < screenWidth; i++) - { - DrawPixel(i,screenHeight/2,BLACK); - } - for (int i = 0; i < screenHeight; i++) - { - DrawPixel(screenWidth/2,i,BLACK); - } -} +int main() { -int main() -{ - InitWindow(screenWidth, screenHeight, "LET ME HELP YOU SEE, SLAYER"); + const int screenWidth = 800; + const int screenHeight = 450; - Player player; - float heights[MAX_COLUMNS] = {0}; - Vector3 positions[MAX_COLUMNS] = {0}; - Color colors[MAX_COLUMNS] = {0}; - BoxCollider BBoxes[MAX_COLUMNS]; - GenerateLevel(heights, BBoxes, positions, colors); + raylib::Window window(screenWidth, screenHeight); - SetTargetFPS(60); - while (!WindowShouldClose()) - { - BeginDrawing(); - ClearBackground(WHITE); - CheckPlayerCollisions(&player, BBoxes); - Draw3D(player, positions, heights, colors, BBoxes); - Draw2D(); + raylib::Vector3 position(10.0f, 10.0f, 8.0f); + raylib::Vector3 target(0.0f, 0.0f, 0.0f); + raylib::Vector3 up (0.0f, 1.0f, 0.0f); - Abbas(); + float fovy = 60.0f; + raylib::Camera3D cam(position, target, up, fovy, CAMERA_PERSPECTIVE); - GetInput(); - UpdateCamera(&player.camera); - player.collider.UpdateBoundingBox(); + window.SetTargetFPS(60); - EndDrawing(); + while (!window.ShouldClose()) { + UpdateFrame(window, cam); } - CloseWindow(); - - return 0; + window.Close(); + return EXIT_SUCCESS; } \ No newline at end of file diff --git a/projects/VSCode/Makefile b/projects/VSCode/Makefile index 2ca0ead0..3e61f626 100644 --- a/projects/VSCode/Makefile +++ b/projects/VSCode/Makefile @@ -356,9 +356,9 @@ SRC_DIR = src OBJ_DIR = obj # Define all object files from source files -SRC = $(call rwildcard, *.c, *.h) +SRC = $(call rwildcard, *.cpp, *.h) #OBJS = $(SRC:$(SRC_DIR)/%.c=$(OBJ_DIR)/%.o) -OBJS ?= main.c +OBJS ?= FirstPerson.cpp # For Android platform we call a custom Makefile.Android ifeq ($(PLATFORM),PLATFORM_ANDROID)