This commit is contained in:
Arkitu 2024-09-06 19:34:03 +02:00
parent f54ca4ed19
commit 53f521fc62
4 changed files with 7 additions and 13 deletions

View File

@ -1,6 +1,6 @@
use bytemuck::{Pod, Zeroable};
use wgpu::{include_wgsl, util::DeviceExt, BindGroup, Buffer, Device, Queue, RenderPipeline, Surface, SurfaceConfiguration, VertexBufferLayout};
use winit::{event::{Event, WindowEvent}, event_loop::EventLoop, window::Window};
use winit::{event::{Event, WindowEvent}, window::Window};
use crate::{state::State, App};

View File

@ -1,5 +1,5 @@
use std::{collections::{BTreeMap, HashMap}, time::Instant};
use log::info;
use log::trace;
use map::{CellKind, Map};
use rand::prelude::*;
use voronoice::Point;
@ -127,7 +127,7 @@ impl State {
}
}
pub fn render(&mut self) {
info!("render");
trace!("render");
self.vertices = Vec::new();
self.indices = Vec::new();
@ -179,8 +179,7 @@ impl State {
}
}
pub fn update(&mut self) {
dbg!(self.framerate);
info!("update");
trace!("update");
self.last_frame = Instant::now();
let mut rng = thread_rng();
@ -216,7 +215,7 @@ impl State {
// if Option is None remove the entity
let mut entities_to_move: Vec<(usize, Option<usize>)> = Vec::new();
for (eid, e) in self.entities.iter_mut() {
match dbg!(e.update(&mut self.map, self.t, &mut rng)) {
match e.update(&mut self.map, self.t, &mut rng) {
Some(ExternOp::Move(cid)) => {
entities_to_move.push((*eid, Some(cid)));
},

View File

@ -1,11 +1,10 @@
use std::time::Instant;
use rand::{rngs::ThreadRng, seq::IteratorRandom, Rng};
use voronoice::Point;
use crate::graphics::Vertex;
use super::{map::{CellData, CellKind}, Map};
use super::{map::CellKind, Map};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EntityKind {
@ -182,7 +181,7 @@ impl Entity {
}
}
if dbg!(self.health) == 0. {
if self.health == 0. {
return Some(ExternOp::Remove);
}

View File

@ -1,11 +1,7 @@
use std::collections::HashMap;
use noise::{Fbm, MultiFractal, NoiseFn, Perlin};
use rand::{Rng, SeedableRng};
use voronoice::{BoundingBox, Point, Voronoi, VoronoiBuilder};
use super::entity::Entity;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CellKind {
Void,