add activities
This commit is contained in:
parent
6f77fb9008
commit
c957799a81
5 changed files with 50 additions and 7 deletions
7
src/activities/house.rs
Normal file
7
src/activities/house.rs
Normal 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
8
src/activities/mod.rs
Normal file
|
@ -0,0 +1,8 @@
|
|||
pub mod house;
|
||||
pub mod overworld;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Activity {
|
||||
House,
|
||||
Overworld
|
||||
}
|
7
src/activities/overworld.rs
Normal file
7
src/activities/overworld.rs
Normal 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) {}
|
19
src/game.rs
19
src/game.rs
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
16
src/main.rs
16
src/main.rs
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue