#include "raylib.h"


int main(void)
{

    const int screenHeight = 1280;
    const int screenWidth = 720; 

    InitWindow(screenHeight, screenWidth, "Game");

    Camera3D camera = { 0 };
    camera.position = (Vector3){ 500.0f, 10.0f, 500.0f };
    camera.target = (Vector3){ 100.0f, 10.0f, 100.0f };
    camera.up = (Vector3){ 0.0f, 1.0f, 0.0f };
    camera.fovy = 120.0f;
    camera.projection = CAMERA_PERSPECTIVE;

    Image image = LoadImage("maps/map.png");
    Texture2D texture = LoadTextureFromImage(image);

    Mesh mesh = GenMeshHeightmap(image, (Vector3){ 1079, 20, 1018});
    Model model = LoadModelFromMesh(mesh);

    model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture;
    Vector3 mapPos = { -8.0f, 0.0f, -8.0f };

    UnloadImage(image);

    SetCameraMode(camera, CAMERA_FREE);



    while (!WindowShouldClose())
    {

        UpdateCamera(&camera);

        BeginDrawing();

            ClearBackground(RAYWHITE);

            BeginMode3D(camera);

                DrawModel(model, mapPos, 1.0f, GREEN);

            EndMode3D();

        EndDrawing();
    }

    UnloadTexture(texture);
    UnloadModel(model);

    CloseWindow();

    return 0;
}