diff options
Diffstat (limited to '')
-rw-r--r-- | src/main.cpp | 114 |
1 files changed, 72 insertions, 42 deletions
diff --git a/src/main.cpp b/src/main.cpp index d3481ad..8033d5a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,26 +1,32 @@ +/*********************************/ +/* YABS ( // */ +/* main ( )/ */ +/* by salade )(/ */ +/* ________________ ( /) */ +/* ()__)____________))))) :^} */ +/*********************************/ + #include <stdlib.h> #include "raylib.h" #include "raymath.h" -#include "yabs_defines.h" +#include "yabs_core.h" #include "yabs_utils.h" -#include "yabs_gameplay.h" static yabs::gameState game_state; -static yabs::Scene3D sc3d { -// camera -{{5.0f, 5.0f, 5.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, 45.0f, 0}, -// movement -{0.0f, 0.0f}, -// rotation -{0.0f, -0.2f, 0.0f}, -// mouse -{0.0f, 0.0f} -}; +static yabs::Scene3D sc3d{ + // camera + {{5.0f, 5.0f, 5.0f}, {0.0f, 0.0f, 0.0f}, {0.0f, 1.0f, 0.0f}, 45.0f, 0}, + // movement + {0.0f, 0.0f}, + // rotation + {0.0f, -0.2f, 0.0f}, + // mouse + {0.0f, 0.0f}}; int main(void) { // create window - InitWindow(G_SCREENWIDTH, G_SCREENHEIGHT, G_TITLE); + InitWindow(YABS_SCREENWIDTH, YABS_SCREENHEIGHT, YABS_TITLE); // create image Image checked = GenImageChecked(2, 2, 1, 1, BLACK, GRAY); @@ -46,28 +52,47 @@ int main(void) { // game loop while (!WindowShouldClose()) { switch (game_state) { - case (yabs::TITLE): - { + case (yabs::TITLE): { + break; + } + case (yabs::PICK): { + break; + } + case (yabs::DEATH): { + break; + } + case (yabs::GAMEPLAY): { + yabs::core::reset_camera(sc3d); + break; + } + case (yabs::NEXT): { + break; + } + case (yabs::ENDING): { + break; + } + } + + switch (game_state) { + case (yabs::TITLE): { break; } - case (yabs::PICK): - { + case (yabs::PICK): { break; } - case (yabs::DEATH): - { + case (yabs::DEATH): { break; } - case (yabs::GAMEPLAY): - { + case (yabs::GAMEPLAY): { + while (game_state != yabs::NEXT) { + yabs::core::draw(game_state); + } break; } - case (yabs::NEXT): - { + case (yabs::NEXT): { break; } - case (yabs::ENDING): - { + case (yabs::ENDING): { break; } } @@ -75,8 +100,10 @@ int main(void) { Vector2 mouseMovement = Vector2Subtract(GetMousePosition(), sc3d.lastMousePos); sc3d.lastMousePos = GetMousePosition(); - sc3d.rotation.x += (mouseMovement.x * -G_CAMERA_MOUSE_MOVE_SENSITIVITY); - sc3d.rotation.y += (mouseMovement.y * -G_CAMERA_MOUSE_MOVE_SENSITIVITY); + 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), @@ -84,16 +111,16 @@ int main(void) { // 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]) / - G_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]) / - G_PLAYER_MOVEMENT_SENSITIVITY; + 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; @@ -101,13 +128,15 @@ int main(void) { sc3d.movement.y -= 0.12f; // apply movement - sc3d.camera.position.x += sc3d.movement.x / G_PLAYER_MOVEMENT_SENSITIVITY; + 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 / G_PLAYER_MOVEMENT_SENSITIVITY; + 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 rotation2 = MatrixRotateXYZ((Vector3){ + DOUBLEPI - sc3d.rotation.y, DOUBLEPI - sc3d.rotation.x, 0}); Matrix transform = MatrixMultiply(translation, rotation2); // apply camera rotation @@ -131,7 +160,8 @@ int main(void) { EndMode3D(); DrawFPS(0, 0); - DrawText("Controls - Mouse / WASD / R/F.", 400, 0, 20, DARKGRAY); + DrawText("Controls: Mouse / WASD / SPACE/CTRL.", YABS_SCREENWIDTH - 400, + 0, 20, DARKGRAY); EndDrawing(); } UnloadTexture(texture); |