Static World Gen and Display for the Overworld #5

Merged
msrd0 merged 21 commits from overworld-house-gen into main 2024-07-06 20:23:25 +00:00
2 changed files with 15 additions and 5 deletions
Showing only changes of commit fdfe1c8333 - Show all commits

View file

@ -1,23 +1,31 @@
use comfy::{draw_circle, draw_sprite, vec2, EngineContext, Vec2, GREEN};
use comfy::{
draw_circle, draw_rect_outline, draw_sprite, main_camera_mut, texture_id, vec2,
EngineContext, IVec2, Vec2, GREEN, RED, WHITE
};
use crate::game::ZLayer;
pub mod worldgen;
pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) {
draw_circle(vec2(0.0, 0.0), 0.5, GREEN, 0);
for (coords, tile) in state.overworld.iter_tiles() {
for (i, texture) in tile.textures().iter().rev().enumerate() {
let i = i as i32;
draw_sprite(
*texture,
coords.as_vec2(),
Default::default(),
WHITE,
ZLayer::MapMax - i,
Vec2::ONE
)
);
draw_rect_outline(coords.as_vec2(), Vec2::ONE, 0.1, RED, 10);
}
}
}
pub fn update(_state: &mut crate::State, _engine: &mut EngineContext<'_>) {}
pub fn update(state: &mut crate::State, _engine: &mut EngineContext<'_>) {
let mut camera = main_camera_mut();
camera.center = Vec2::ZERO;
camera.zoom = 30.0;
state.overworld.get_or_generate_tile(IVec2::ZERO);
}

View file

@ -1,5 +1,6 @@
use crate::assets::ASSETS;
use comfy::{IVec2, TextureHandle, UVec2};
use log::info;
use std::collections::HashMap;
pub enum MovementCost {
@ -115,6 +116,7 @@ pub struct Chunk {
impl Chunk {
pub fn generate_chunk() -> Self {
info!("gen chunk");
// TODO real worldgen
// for the time being we just copy this pre-made house block into the chunk