aboutsummaryrefslogtreecommitdiffstats
path: root/src/main.cpp
blob: 94e3f972836606f457b6af218d08c5d1841cc8c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/*********************************/
/*   YABS             (  //      */
/*   main              ( )/      */
/*   by salade         )(/       */
/*  ________________  ( /)       */
/* ()__)____________)))))   :^}  */
/*********************************/

#include "yabs_core.h"
#include "yabs_utils.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}};

int main(void) {
    // create window
    InitWindow(YABS_SCREENWIDTH, YABS_SCREENHEIGHT, YABS_TITLE);

    // create image
    Image checked = GenImageChecked(2, 2, 1, 1, BLACK, GRAY);
    Texture2D texture = LoadTextureFromImage(checked);
    UnloadImage(checked);

    // create model with image as texture
    Model model = {};
    model = LoadModelFromMesh(GenMeshCube(1.0f, 1.0f, 1.0f));
    model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;

    // setup camera
    SetTargetFPS(60);
    // game loop
    while (!WindowShouldClose()) {
        switch (game_state) {
            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): {
                break;
            }
            case (yabs::DEATH): {
                break;
            }
            case (yabs::GAMEPLAY): {
                while (game_state != yabs::NEXT) {
                    yabs::core::draw(game_state, model);
                }
                break;
            }
            case (yabs::NEXT): {
                break;
            }
            case (yabs::ENDING): {
                break;
            }
        }

        // draw
        BeginDrawing();
        ClearBackground(GRAY);
        BeginMode3D(sc3d.camera);
        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);
}