Struct memory_management::world::Generator
source · pub struct Generator { /* private fields */ }Expand description
A struct representing a terrain generator.
The Generator struct uses a seed to generate terrain heights based on
a seed
Implementations§
source§impl Generator
impl Generator
sourcepub fn get_height(&self, x: i64, z: i64) -> i64
pub fn get_height(&self, x: i64, z: i64) -> i64
Calculates the height of the terrain at the specified coordinates (x, z).
This function uses sinusoidal functions to simulate terrain height.
§Arguments
x- The x-coordinate.z- The z-coordinate.
§Returns
- The height of the terrain at the specified coordinates.
§Example
use memory_management::world::Generator;
let generator = Generator::new();
let height = generator.get_height(10, 20);
println!("Height at (10, 20): {}", height);sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new Generator instance with a seed based on the current time.
The seed is derived from the current time in nanoseconds since the UNIX epoch.
§Returns
- A new instance of
Generator.
§Example
use memory_management::world::Generator;
let generator = Generator::new();
assert!(matches!(generator, Generator { .. }));Auto Trait Implementations§
impl Freeze for Generator
impl RefUnwindSafe for Generator
impl Send for Generator
impl Sync for Generator
impl Unpin for Generator
impl UnwindSafe for Generator
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more