Merge remote-tracking branch 'origin/main' into room-creation
This commit is contained in:
commit
38921a7a33
3 changed files with 39 additions and 13 deletions
5
build.rs
5
build.rs
|
@ -207,7 +207,7 @@ fn process_dir<P: AsRef<Path> + Copy>(
|
||||||
} else if path.extension().map(|ext| ext == "svg").unwrap_or(false) {
|
} else if path.extension().map(|ext| ext == "svg").unwrap_or(false) {
|
||||||
process_svg(&path, dir, writer, groups);
|
process_svg(&path, dir, writer, groups);
|
||||||
} else if path.extension().map(|ext| ext == "ogg").unwrap_or(false) {
|
} else if path.extension().map(|ext| ext == "ogg").unwrap_or(false) {
|
||||||
process_ogg(&path, dir, writer, groups);
|
process_ogg(&path, writer, groups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -258,9 +258,8 @@ fn process_svg<P: AsRef<Path> + Copy, Q: AsRef<Path>>(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn process_ogg<P: AsRef<Path> + Copy, Q: AsRef<Path>>(
|
fn process_ogg<P: AsRef<Path> + Copy>(
|
||||||
file: P,
|
file: P,
|
||||||
dir: Q,
|
|
||||||
writer: &mut AssetsWriter,
|
writer: &mut AssetsWriter,
|
||||||
groups: &[String]
|
groups: &[String]
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -19,9 +19,11 @@ pub fn draw(state: &crate::State, _engine: &comfy::EngineContext<'_>) {
|
||||||
ZLayer::MapMax - i,
|
ZLayer::MapMax - i,
|
||||||
Vec2::ONE
|
Vec2::ONE
|
||||||
);
|
);
|
||||||
|
if state.dev {
|
||||||
draw_rect_outline(coords.as_vec2(), Vec2::ONE, 0.1, RED, 10);
|
draw_rect_outline(coords.as_vec2(), Vec2::ONE, 0.1, RED, 10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
draw_circle(state.ghost.overworld_pos, 0.5, RED, ZLayer::Ghost.into());
|
draw_circle(state.ghost.overworld_pos, 0.5, RED, ZLayer::Ghost.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,6 +38,8 @@ fn update_move_player(state: &mut State, ctx: &mut EngineContext<'_>) {
|
||||||
state.ghost.overworld_movement_pending
|
state.ghost.overworld_movement_pending
|
||||||
);
|
);
|
||||||
state.ghost.update_overworld_pos(now);
|
state.ghost.update_overworld_pos(now);
|
||||||
|
}
|
||||||
|
if state.ghost.overworld_movement_pending != Vec2::ZERO {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
37
src/main.rs
37
src/main.rs
|
@ -10,17 +10,31 @@ mod activities;
|
||||||
mod game;
|
mod game;
|
||||||
mod ui;
|
mod ui;
|
||||||
|
|
||||||
|
use std::env::var;
|
||||||
|
|
||||||
use self::{
|
use self::{
|
||||||
activities::{house::HouseState, overworld::worldgen::Overworld, Activity},
|
activities::{house::HouseState, overworld::worldgen::Overworld, Activity},
|
||||||
game::Ghost
|
game::Ghost
|
||||||
};
|
};
|
||||||
use comfy::{
|
use comfy::{
|
||||||
etagere::euclid::default, init_game_config, pollster, run_comfy_main_async,
|
init_game_config, pollster, run_comfy_main_async, DevConfig, EngineContext,
|
||||||
DevConfig, EngineContext, EngineState, GameConfig, GameLoop, HashMap, IVec2
|
EngineState, GameConfig, GameLoop, HashMap, IVec2
|
||||||
};
|
};
|
||||||
|
|
||||||
const GAME_NAME: &str = "Powercreep";
|
const GAME_NAME: &str = "Powercreep";
|
||||||
|
|
||||||
|
/// true if devtools should be enable
|
||||||
|
fn dev_from_env() -> bool {
|
||||||
|
match var("DEV").as_ref().map(|f| f.as_str()) {
|
||||||
|
Ok("false") => false,
|
||||||
|
Ok("true") => true,
|
||||||
|
#[cfg(debug_assertions)]
|
||||||
|
_ => true,
|
||||||
|
#[cfg(not(debug_assertions))]
|
||||||
|
_ => false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct State {
|
struct State {
|
||||||
setup_called: bool,
|
setup_called: bool,
|
||||||
|
@ -28,7 +42,9 @@ struct State {
|
||||||
ghost: Ghost,
|
ghost: Ghost,
|
||||||
overworld: Overworld,
|
overworld: Overworld,
|
||||||
houses: HashMap<IVec2, HouseState>,
|
houses: HashMap<IVec2, HouseState>,
|
||||||
score: f32
|
score: f32,
|
||||||
|
/// show dev tools
|
||||||
|
dev: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
impl State {
|
impl State {
|
||||||
|
@ -52,7 +68,10 @@ impl State {
|
||||||
|
|
||||||
impl GameLoop for State {
|
impl GameLoop for State {
|
||||||
fn new(_c: &mut EngineState) -> Self {
|
fn new(_c: &mut EngineState) -> Self {
|
||||||
Self::default()
|
Self {
|
||||||
|
dev: dev_from_env(),
|
||||||
|
..Default::default()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update(&mut self, ctx: &mut EngineContext<'_>) {
|
fn update(&mut self, ctx: &mut EngineContext<'_>) {
|
||||||
|
@ -70,15 +89,19 @@ impl GameLoop for State {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn config(config: GameConfig) -> GameConfig {
|
fn config(config: GameConfig) -> GameConfig {
|
||||||
let dev = DevConfig {
|
let dev = if dev_from_env() {
|
||||||
#[cfg(debug_assertions)]
|
DevConfig {
|
||||||
show_fps: true,
|
show_fps: true,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Default::default()
|
||||||
};
|
};
|
||||||
GameConfig {
|
GameConfig {
|
||||||
tonemapping_enabled: true,
|
tonemapping_enabled: true,
|
||||||
dev,
|
dev,
|
||||||
..Default::default()
|
target_framerate: 165,
|
||||||
|
..config
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue