initial commit
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
./out
|
||||||
7
Makefile
Normal file
7
Makefile
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
burger-game: main.cpp
|
||||||
|
mkdir -p ./out
|
||||||
|
g++ main.cpp -o ./out/burger-game -lraylib -lm
|
||||||
|
./out/burger-game
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -rf ./out
|
||||||
46
main.cpp
Normal file
46
main.cpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
#include "raylib.h"
|
||||||
|
#include <cmath>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
InitWindow(1920, 1080, "My First 3D Cube");
|
||||||
|
|
||||||
|
Camera3D camera = {0};
|
||||||
|
camera.position = (Vector3){10.0f, 10.0f, 10.0f};
|
||||||
|
camera.target = (Vector3){0.0f, 0.0f, 0.0f};
|
||||||
|
camera.up = (Vector3){0.0f, 2.0f, 0.0f};
|
||||||
|
camera.fovy = 45.0f;
|
||||||
|
//camera.projection = CAMERA_ORTHOGRAPHIC;
|
||||||
|
camera.projection = CAMERA_PERSPECTIVE;
|
||||||
|
|
||||||
|
float cam_angle = 0.0f;
|
||||||
|
float cube_angle = 0.0f;
|
||||||
|
float cam_distance = 10.0f;
|
||||||
|
float cube_distance = 10.0f;
|
||||||
|
|
||||||
|
while (!WindowShouldClose()) {
|
||||||
|
|
||||||
|
cam_angle += 0.000f;
|
||||||
|
cube_angle -= 0.00001f;
|
||||||
|
Vector3 cube_rotation{cube_distance * sinf(cube_angle), 0.0f, cube_distance * cosf( cube_angle)};
|
||||||
|
|
||||||
|
camera.position.x = cube_rotation.x + (cam_distance * sinf(cam_angle));
|
||||||
|
camera.position.z = cube_rotation.z + (cam_distance * cosf(cam_angle));
|
||||||
|
|
||||||
|
camera.target.x = cube_rotation.x;
|
||||||
|
camera.target.z = cube_rotation.z;
|
||||||
|
|
||||||
|
|
||||||
|
BeginDrawing();
|
||||||
|
ClearBackground(BLACK);
|
||||||
|
|
||||||
|
BeginMode3D(camera);
|
||||||
|
DrawCube(cube_rotation, 2.0f, 2.0f, 2.0f, RED);
|
||||||
|
DrawGrid(10, 1.0f);
|
||||||
|
EndMode3D();
|
||||||
|
|
||||||
|
EndDrawing();
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseWindow();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user