rts camera

center camera
spawn basic water
fix generator config
set camera bounds
This commit is contained in:
2024-05-02 22:11:40 -04:00
parent b2622f2126
commit ed94f77323
5 changed files with 127 additions and 36 deletions

View File

@@ -8,7 +8,7 @@ pub mod tile_manager;
pub mod tile_mapper;
pub mod prelude {
use crate::hex_utils::{HexCoord, INNER_RADIUS, OUTER_RADIUS};
use crate::hex_utils::{tile_to_world_distance, HexCoord, INNER_RADIUS, OUTER_RADIUS};
use bevy::math::{IVec2, UVec2, Vec2, Vec3};
use bevy::prelude::Resource;
use bevy::prelude::*;
@@ -84,6 +84,7 @@ pub mod prelude {
pub chunks: Vec<Chunk>,
pub height: usize,
pub width: usize,
pub sea_level: f32,
}
impl Map {
@@ -105,7 +106,7 @@ pub mod prelude {
return results;
}
pub fn get_height(&self, pos: &HexCoord) -> f32 {
pub fn sample_height(&self, pos: &HexCoord) -> f32 {
let chunk = &self.chunks[pos.to_chunk_index(self.width)];
return chunk.heights[pos.to_chunk_local_index()];
}
@@ -119,6 +120,23 @@ pub mod prelude {
let chunk = &self.chunks[pos.to_chunk_index(self.width)];
return chunk.temperature[pos.to_chunk_local_index()];
}
pub fn get_center(&self) -> Vec3 {
let w = self.width * Chunk::SIZE;
let h = self.height * Chunk::SIZE;
return Vec3::new(
tile_to_world_distance(w as i32 / 2),
self.sea_level,
tile_to_world_distance(h as i32 / 2),
);
}
pub fn get_world_width(&self) -> f32 {
return tile_to_world_distance((self.width * Chunk::SIZE) as i32);
}
pub fn get_world_height(&self) -> f32 {
return tile_to_world_distance((self.height * Chunk::SIZE) as i32);
}
}
pub const ATTRIBUTE_PACKED_VERTEX_DATA: MeshVertexAttribute =
MeshVertexAttribute::new("PackedVertexData", 988540817, VertexFormat::Uint32);