浏览代码

REVIEWED: `models_basic_voxel` example

pull/5574/head
Ray 2 周前
父节点
当前提交
98c7734911
共有 2 个文件被更改,包括 9 次插入4 次删除
  1. +9
    -4
      examples/models/models_basic_voxel.c
  2. 二进制
      examples/models/models_basic_voxel.png

+ 9
- 4
examples/models/models_basic_voxel.c 查看文件

@ -16,6 +16,7 @@
********************************************************************************************/
#include "raylib.h"
#include "raymath.h"
#define WORLD_SIZE 8 // Size of our voxel world (8x8x8 cubes)
@ -32,7 +33,7 @@ int main(void)
InitWindow(screenWidth, screenHeight, "raylib [models] example - basic voxel");
DisableCursor(); // Lock mouse to window center
DisableCursor(); // Lock mouse to window center
// Define the camera to look into our 3d world (first person)
Camera3D camera = { 0 };
@ -59,7 +60,7 @@ int main(void)
}
}
}
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -74,7 +75,7 @@ int main(void)
if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON))
{
// Cast a ray from the screen center (where crosshair would be)
Vector2 screenCenter = { screenWidth/2.0f, screenHeight/2.0f };
Vector2 screenCenter = { GetScreenWidth()/2.0f, GetScreenHeight()/2.0f };
Ray ray = GetMouseRay(screenCenter, camera);
// Check ray collision with all voxels
@ -132,8 +133,11 @@ int main(void)
}
}
}
EndMode3D();
// Draw reference point for raycasting to delete blocks
DrawCircle(GetRenderWidth()/2, GetScreenHeight()/2, 4, RED);
DrawText("Left-click a voxel to remove it!", 10, 10, 20, DARKGRAY);
DrawText("WASD to move, mouse to look around", 10, 35, 10, GRAY);
@ -145,6 +149,7 @@ int main(void)
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadModel(cubeModel);
CloseWindow();
//--------------------------------------------------------------------------------------

二进制
examples/models/models_basic_voxel.png 查看文件

之前 之后
宽度: 1824  |  高度: 1180  |  大小: 341 KiB 宽度: 800  |  高度: 450  |  大小: 28 KiB

正在加载...
取消
保存