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 crate::State;
use crate::{
activities::{house, overworld, Activity},
State
};
pub fn update(_state: &mut State, _engine: &mut EngineContext) {
info!("update");
pub fn update(state: &mut State, engine: &mut EngineContext) {
match state.activity {
Activity::House => house::update(state, engine),
Activity::Overworld => overworld::update(state, engine)
}
}
pub fn draw(_state: &State, _engine: &EngineContext) {
draw_circle(vec2(0.0, 0.0), 0.5, RED, 0);
pub fn draw(state: &State, engine: &EngineContext) {
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;
use activities::Activity;
use comfy::*;
const GAME_NAME: &str = "Powercreep";
#[derive(Debug)]
struct State {}
struct State {
activity: Activity
}
impl Default for State {
fn default() -> Self {
Self {
activity: Activity::House
}
}
}
impl GameLoop for State {
fn new(_c: &mut EngineState) -> Self {
State {}
Self::default()
}
fn update(&mut self, engine: &mut EngineContext) {