some draw fixs

This commit is contained in:
luckyturtledev 2024-07-06 19:32:17 +02:00
parent caf17aa3e5
commit fdfe1c8333
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; use crate::game::ZLayer;
pub mod worldgen; pub mod worldgen;
pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) { 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 (coords, tile) in state.overworld.iter_tiles() {
for (i, texture) in tile.textures().iter().rev().enumerate() { for (i, texture) in tile.textures().iter().rev().enumerate() {
let i = i as i32; let i = i as i32;
draw_sprite( draw_sprite(
*texture, *texture,
coords.as_vec2(), coords.as_vec2(),
Default::default(), WHITE,
ZLayer::MapMax - i, ZLayer::MapMax - i,
Vec2::ONE 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 crate::assets::ASSETS;
use comfy::{IVec2, TextureHandle, UVec2}; use comfy::{IVec2, TextureHandle, UVec2};
use log::info;
use std::collections::HashMap; use std::collections::HashMap;
pub enum MovementCost { pub enum MovementCost {
@ -115,6 +116,7 @@ pub struct Chunk {
impl Chunk { impl Chunk {
pub fn generate_chunk() -> Self { pub fn generate_chunk() -> Self {
info!("gen chunk");
// TODO real worldgen // TODO real worldgen
// for the time being we just copy this pre-made house block into the chunk // for the time being we just copy this pre-made house block into the chunk