im a 13 y/o Moroccan programmer and im in a bit of a sticky situation
so im trying to make a first person game so i used raylib since it is the easiest way to do so without using an engine,i wrote the code and stuff and it worked,one problem tho,it was extremely slow so can anyone help me?
here is the code btw:
#include "raylib.h"
int main()
{
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window");
float cx = 0.0f;
float cy = 10.0f;
float cz = 10.0f;
Camera3D camera = { 0 };
camera.position = (Vector3){ cx,cy,cz }; // Camera position
camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE;
SetCameraMode(camera,CAMERA_FIRST_PERSON); // Camera mode type
Vector3 cubepos = {0.0f,1.0f,0.0f};
SetTargetFPS(60);
while (!WindowShouldClose())
{
UpdateCamera(&camera);
BeginDrawing();
ClearBackground(BLACK);
BeginMode3D(camera);
DrawCube(cubepos,3.0f,3.0f,3.0f,RED);
EndMode3D();
EndDrawing();
}
CloseWindow();
return 0;
}
Looking at the Raylib's
UpdateCamera(Camera*)
function at https://github.com/raysan5/raylib/blob/master/src/rcamera.h, we shall change a bit.#define CAMERA_IMPLEMENTATION
main.cpp
after the line ``#include <raylib.h>`rcamera.h
, change the#define PLAYER_MOVEMENT_SENSITIVITY 2.0f
to how much ever you want.If you face C to C++ conversion issues, particularly in line 220-229, you should replace to:
You can remove some of the uneeded switch cases (Line 306-405 and 495-592) to increase performane.