add activities
Some checks failed
Rust / rustfmt (push) Successful in 19s
Rust / clippy (push) Failing after 38s
Rust / build (push) Successful in 2m3s

This commit is contained in:
luckyturtledev 2024-07-06 13:33:58 +02:00
parent 6f77fb9008
commit c957799a81
5 changed files with 50 additions and 7 deletions

7
src/activities/house.rs Normal file
View file

@ -0,0 +1,7 @@
use comfy::*;
pub fn draw(_state: &crate::State, _engine: &comfy::EngineContext) {
draw_circle(vec2(0.0, 0.0), 0.5, RED, 0);
}
pub fn update(_state: &mut crate::State, _engine: &mut comfy::EngineContext) {}

8
src/activities/mod.rs Normal file
View file

@ -0,0 +1,8 @@
pub mod house;
pub mod overworld;
#[derive(Debug)]
pub enum Activity {
House,
Overworld
}

View file

@ -0,0 +1,7 @@
use comfy::*;
pub fn draw(_state: &crate::State, _engine: &comfy::EngineContext) {
draw_circle(vec2(0.0, 0.0), 0.5, GREEN, 0);
}
pub fn update(_state: &mut crate::State, _engine: &mut comfy::EngineContext) {}

View file

@ -1,11 +1,20 @@
use comfy::*; use comfy::*;
use crate::State; use crate::{
activities::{house, overworld, Activity},
State
};
pub fn update(_state: &mut State, _engine: &mut EngineContext) { pub fn update(state: &mut State, engine: &mut EngineContext) {
info!("update"); match state.activity {
Activity::House => house::update(state, engine),
Activity::Overworld => overworld::update(state, engine)
}
} }
pub fn draw(_state: &State, _engine: &EngineContext) { pub fn draw(state: &State, engine: &EngineContext) {
draw_circle(vec2(0.0, 0.0), 0.5, RED, 0); match state.activity {
Activity::House => house::draw(state, engine),
Activity::Overworld => overworld::draw(state, engine)
}
} }

View file

@ -1,15 +1,27 @@
mod activities;
mod game; mod game;
use activities::Activity;
use comfy::*; use comfy::*;
const GAME_NAME: &str = "Powercreep"; const GAME_NAME: &str = "Powercreep";
#[derive(Debug)] #[derive(Debug)]
struct State {} struct State {
activity: Activity
}
impl Default for State {
fn default() -> Self {
Self {
activity: Activity::House
}
}
}
impl GameLoop for State { impl GameLoop for State {
fn new(_c: &mut EngineState) -> Self { fn new(_c: &mut EngineState) -> Self {
State {} Self::default()
} }
fn update(&mut self, engine: &mut EngineContext) { fn update(&mut self, engine: &mut EngineContext) {