Added moving fence.
This commit is contained in:
40
main.c
40
main.c
@@ -164,7 +164,11 @@ int main(void)
|
|||||||
|
|
||||||
// Load GLTF model (no animations)
|
// Load GLTF model (no animations)
|
||||||
Model wall = LoadModel("resources/3d_models/Tiny_Treats_Homely_House_1.0_FREE/Assets/gltf/fence_straight.gltf");
|
Model wall = LoadModel("resources/3d_models/Tiny_Treats_Homely_House_1.0_FREE/Assets/gltf/fence_straight.gltf");
|
||||||
Vector3 wall_position = { 0.0f, 0.0f, 120.0f };
|
Vector3 wall_position = { 0.0f, 0.0f, 0.0f };
|
||||||
|
float wall_yaw = 0.0f; // rotate around Y
|
||||||
|
float wall_pitch = 0.0f; // rotate around X
|
||||||
|
float wall_roll = 0.0f; // rotate around Z
|
||||||
|
|
||||||
|
|
||||||
// Load a 2D image as texture for the billboard
|
// Load a 2D image as texture for the billboard
|
||||||
//Billboards always point toward the active camera.
|
//Billboards always point toward the active camera.
|
||||||
@@ -380,6 +384,29 @@ int main(void)
|
|||||||
bbPos.x += (g.player.position.x - bbPos.x)*.005;
|
bbPos.x += (g.player.position.x - bbPos.x)*.005;
|
||||||
bbPos.z += (g.player.position.z - bbPos.z)*.005;
|
bbPos.z += (g.player.position.z - bbPos.z)*.005;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// wall editor
|
||||||
|
if (IsKeyDown(KEY_RIGHT) && IsKeyDown(KEY_LEFT_SHIFT)) wall_position.x += 0.5f;
|
||||||
|
else if (IsKeyPressed(KEY_RIGHT)) wall_position.x += 0.5f;
|
||||||
|
|
||||||
|
if (IsKeyDown(KEY_LEFT) && IsKeyDown(KEY_LEFT_SHIFT)) wall_position.x -= 0.5f;
|
||||||
|
else if (IsKeyPressed(KEY_LEFT)) wall_position.x -= 0.5f;
|
||||||
|
|
||||||
|
if (IsKeyDown(KEY_UP) && IsKeyDown(KEY_LEFT_SHIFT)) wall_position.z += 0.5f;
|
||||||
|
else if (IsKeyPressed(KEY_UP)) wall_position.z += 0.5f;
|
||||||
|
|
||||||
|
if (IsKeyDown(KEY_DOWN) && IsKeyDown(KEY_LEFT_SHIFT)) wall_position.z -= 0.5f;
|
||||||
|
else if (IsKeyPressed(KEY_DOWN)) wall_position.z -= 0.5f;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
float rotSpeed = 45.0f * GetFrameTime(); // deg/sec
|
||||||
|
if (IsKeyDown(KEY_Q)) wall_yaw -= rotSpeed;
|
||||||
|
if (IsKeyDown(KEY_E)) wall_yaw += rotSpeed;
|
||||||
|
//
|
||||||
|
|
||||||
UpdateCameraAngle(&g);
|
UpdateCameraAngle(&g);
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
@@ -438,9 +465,10 @@ int main(void)
|
|||||||
|
|
||||||
BeginShaderMode(fog);
|
BeginShaderMode(fog);
|
||||||
|
|
||||||
DrawModel(wall, wall_position, 5.0, WHITE);
|
//DrawModel(wall, wall_position, 5.0, WHITE);
|
||||||
|
DrawModelEx(wall, wall_position, (Vector3){0,1,0}, wall_yaw, (Vector3){5,5,5}, WHITE);
|
||||||
RenderTrees(&g, tree, treepos, treeSize);
|
RenderTrees(&g, tree, treepos, treeSize);
|
||||||
DrawBillboard(g.player.camera, sign, bbPos, bbSize, WHITE);
|
//DrawBillboard(g.player.camera, sign, bbPos, bbSize, WHITE); //zombie
|
||||||
|
|
||||||
EndShaderMode();
|
EndShaderMode();
|
||||||
|
|
||||||
@@ -457,6 +485,10 @@ int main(void)
|
|||||||
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 20, BLACK);
|
DrawText("- Move keys: W, A, S, D, Space, Left-Ctrl", 15, 30, 20, BLACK);
|
||||||
DrawText("- Look around: arrow keys or mouse", 15, 45, 20, BLACK);
|
DrawText("- Look around: arrow keys or mouse", 15, 45, 20, BLACK);
|
||||||
DrawText(TextFormat("- Velocity Len: (%06.3f)", Vector2Length((Vector2){ g.player.velocity.x, g.player.velocity.z })), 15, 60, 20, BLACK);
|
DrawText(TextFormat("- Velocity Len: (%06.3f)", Vector2Length((Vector2){ g.player.velocity.x, g.player.velocity.z })), 15, 60, 20, BLACK);
|
||||||
|
DrawText(
|
||||||
|
TextFormat("x: (%06.3f), y: (%06.3f), z: (%06.3f)", wall_position.x, wall_position.y, wall_position.z),
|
||||||
|
15, 75, 20, BLACK
|
||||||
|
);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -464,7 +496,7 @@ int main(void)
|
|||||||
EndDrawing();
|
EndDrawing();
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user