Merge remote-tracking branch 'origin/overworld-house-gen' into overworld-house-gen
Some checks failed
Rust / rustfmt (pull_request) Successful in 20s
Rust / clippy (pull_request) Failing after 58s
Rust / build (pull_request) Successful in 2m10s

This commit is contained in:
Dominic 2024-07-06 19:40:12 +02:00
commit 86961bd83e
Signed by: msrd0
GPG key ID: AAF7C8430CA3345D
2 changed files with 15 additions and 5 deletions

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