diff options
Diffstat (limited to 'src/main.cpp')
-rw-r--r-- | src/main.cpp | 79 |
1 files changed, 6 insertions, 73 deletions
diff --git a/src/main.cpp b/src/main.cpp index 8033d5a..491e1c5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -6,10 +6,6 @@ /* ()__)____________))))) :^} */ /*********************************/ -#include <stdlib.h> -#include "raylib.h" -#include "raymath.h" - #include "yabs_core.h" #include "yabs_utils.h" @@ -39,15 +35,6 @@ int main(void) { model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // setup camera - SetCameraMode(sc3d.camera, CAMERA_FIRST_PERSON); // Set camera mode - sc3d.camera.position = (Vector3){50.0f, 1.0f, 50.0f}; - sc3d.camera.target = (Vector3){50.0f, 1.0f, 50.0f}; - sc3d.camera.up = (Vector3){0.0f, 1.0f, 0.0f}; - sc3d.camera.fovy = 90.0f; - sc3d.camera.projection = CAMERA_PERSPECTIVE; - - sc3d.rotation = (Vector3){0.0f, 0.0f, 0.0f}; - sc3d.lastMousePos = GetMousePosition(); SetTargetFPS(60); // game loop while (!WindowShouldClose()) { @@ -85,7 +72,7 @@ int main(void) { } case (yabs::GAMEPLAY): { while (game_state != yabs::NEXT) { - yabs::core::draw(game_state); + yabs::core::draw(game_state, model); } break; } @@ -96,76 +83,22 @@ int main(void) { break; } } - // mouse look - Vector2 mouseMovement = - Vector2Subtract(GetMousePosition(), sc3d.lastMousePos); - sc3d.lastMousePos = GetMousePosition(); - sc3d.rotation.x += - (mouseMovement.x * -YABS_CAMERA_MOUSE_MOVE_SENSITIVITY); - sc3d.rotation.y += - (mouseMovement.y * -YABS_CAMERA_MOUSE_MOVE_SENSITIVITY); - - // direction array - bool direction[4] = {IsKeyDown(KEY_W), IsKeyDown(KEY_S), - IsKeyDown(KEY_D), IsKeyDown(KEY_A)}; - - // compute movement - sc3d.movement = (Vector3){0, 0, 0}; - sc3d.movement.x = (sinf(sc3d.rotation.x) * direction[1] - - sinf(sc3d.rotation.x) * direction[0] - - cosf(sc3d.rotation.x) * direction[3] + - cosf(sc3d.rotation.x) * direction[2]) / - YABS_PLAYER_MOVEMENT_SENSITIVITY; - sc3d.movement.z = (cosf(sc3d.rotation.x) * direction[1] - - cosf(sc3d.rotation.x) * direction[0] + - sinf(sc3d.rotation.x) * direction[3] - - sinf(sc3d.rotation.x) * direction[2]) / - YABS_PLAYER_MOVEMENT_SENSITIVITY; - // elevation - if (IsKeyDown(KEY_SPACE)) - sc3d.movement.y += 0.12f; - if (IsKeyDown(KEY_LEFT_CONTROL)) - sc3d.movement.y -= 0.12f; - - // apply movement - sc3d.camera.position.x += - sc3d.movement.x / YABS_PLAYER_MOVEMENT_SENSITIVITY; - sc3d.camera.position.y += sc3d.movement.y; - sc3d.camera.position.z += - sc3d.movement.z / YABS_PLAYER_MOVEMENT_SENSITIVITY; - - Matrix translation = MatrixTranslate(0, 0, (10)); - Matrix rotation2 = MatrixRotateXYZ((Vector3){ - DOUBLEPI - sc3d.rotation.y, DOUBLEPI - sc3d.rotation.x, 0}); - Matrix transform = MatrixMultiply(translation, rotation2); - // apply camera rotation - sc3d.camera.target.x = sc3d.camera.position.x - transform.m12; - sc3d.camera.target.y = sc3d.camera.position.y - transform.m13; - sc3d.camera.target.z = sc3d.camera.position.z - transform.m14; + // draw BeginDrawing(); ClearBackground(GRAY); BeginMode3D(sc3d.camera); - - // draw checkerboard model - for (int x = 0; x < 50; x++) { - for (int z = 0; z < 50; z++) { - Vector3 position; - position.x = x; - position.y = 0; - position.z = z; - DrawModel(model, position, 1.0f, WHITE); - } - } - + yabs::core::tick(sc3d); + yabs::core::draw(game_state, model); EndMode3D(); DrawFPS(0, 0); DrawText("Controls: Mouse / WASD / SPACE/CTRL.", YABS_SCREENWIDTH - 400, 0, 20, DARKGRAY); + EndDrawing(); } UnloadTexture(texture); UnloadModel(model); CloseWindow(); - return 0; + return (0); } |