turtlegame/src/main.rs
luckyturtledev f1af8c80a3
All checks were successful
Rust / rustfmt (pull_request) Successful in 25s
Rust / clippy (pull_request) Successful in 1m26s
Rust / build (pull_request) Successful in 3m2s
fix merge; rename ghost
2024-07-06 22:34:31 +02:00

67 lines
1.2 KiB
Rust

#![warn(rust_2018_idioms)]
#![deny(clippy::wildcard_imports)]
#![forbid(elided_lifetimes_in_paths, unsafe_code)]
mod assets {
include!(env!("ASSETS_RS"));
}
mod activities;
mod game;
mod ui;
use self::{
activities::{house::HouseState, overworld::worldgen::Overworld, Activity},
assets::Assets,
game::Ghost
};
use comfy::{
init_game_config, pollster, run_comfy_main_async, EngineContext, EngineState,
GameConfig, GameLoop
};
const GAME_NAME: &str = "Powercreep";
#[derive(Debug, Default)]
struct State {
setup_called: bool,
activity: Activity,
ghost: Ghost,
overworld: Overworld,
house: HouseState
}
impl GameLoop for State {
fn new(_c: &mut EngineState) -> Self {
Self::default()
}
fn update(&mut self, engine: &mut EngineContext<'_>) {
if !self.setup_called {
setup(engine);
self.setup_called = true;
}
game::update(self, engine);
game::draw(self, engine);
}
}
fn config(config: GameConfig) -> GameConfig {
config
}
fn setup(ctx: &mut EngineContext<'_>) {
Assets::load(ctx);
}
async fn run() {
init_game_config(GAME_NAME.to_string(), env!("CARGO_PKG_VERSION"), config);
let mut engine = EngineState::new();
let game = State::new(&mut engine);
run_comfy_main_async(game, engine).await;
}
fn main() {
pollster::block_on(run());
}