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
4 changed files with 46 additions and 4 deletions
Showing only changes of commit 284163b428 - Show all commits

View file

@ -1,9 +1,23 @@
use comfy::{draw_circle, vec2, EngineContext, GREEN}; use comfy::{draw_circle, vec2, EngineContext, GREEN};
use crate::game::ZLayer;
pub mod worldgen; pub mod worldgen;
pub fn draw(_state: &crate::State, _engine: &EngineContext<'_>) { pub fn draw(state: &crate::State, _engine: &comfy::EngineContext) {
draw_circle(vec2(0.0, 0.0), 0.5, GREEN, 0); 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(),
ZLayer::MapMax - i,
Vec2::ONE
)
}
}
} }
pub fn update(_state: &mut crate::State, _engine: &mut EngineContext<'_>) {} pub fn update(_state: &mut crate::State, _engine: &mut EngineContext<'_>) {}

View file

@ -1,7 +1,8 @@
use comfy::{IVec2, UVec2}; use comfy::{IVec2, TextureHandle, UVec2};
use std::collections::HashMap; use std::collections::HashMap;
enum MovementCost { pub enum MovementCost {
/// No movement possible - cost infinitely high. /// No movement possible - cost infinitely high.
Infinite, Infinite,
/// There is a path for this movement - movement is cheap. /// There is a path for this movement - movement is cheap.
@ -13,7 +14,9 @@ enum MovementCost {
} }
#[derive(Debug)] #[derive(Debug)]
struct Tile; pub struct Tile {
pub textures: Vec<TextureHandle>
}
impl Tile { impl Tile {
pub fn can_stand_inside(&self) -> bool { pub fn can_stand_inside(&self) -> bool {

View file

@ -1,3 +1,5 @@
use std::ops::Sub;
use comfy::*; use comfy::*;
use crate::{ use crate::{
@ -5,6 +7,28 @@ use crate::{
State State
}; };
#[repr(i32)]
pub enum ZLayer {
MapMax = -1,
Human = 0,
Ghost = 1
}
impl From<ZLayer> for i32 {
fn from(value: ZLayer) -> Self {
// safe because #[repr(i32)]
value as i32
}
}
impl Sub<i32> for ZLayer {
type Output = i32;
fn sub(self, other: i32) -> Self::Output {
i32::from(self) - other
}
}
pub fn update(state: &mut State, engine: &mut EngineContext<'_>) { pub fn update(state: &mut State, engine: &mut EngineContext<'_>) {
match state.activity { match state.activity {
Activity::House => house::update(state, engine), Activity::House => house::update(state, engine),

View file

@ -1,3 +1,4 @@
#[allow(dead_code, unused_variables)]
#![warn(rust_2018_idioms)] #![warn(rust_2018_idioms)]
#![forbid(clippy::wildcard_imports, elided_lifetimes_in_paths, unsafe_code)] #![forbid(clippy::wildcard_imports, elided_lifetimes_in_paths, unsafe_code)]