summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortom barrett <spalf0@gmail.com>2019-07-23 00:54:35 -0500
committertom barrett <spalf0@gmail.com>2019-07-23 03:48:58 -0500
commit2ee665ef6954f6eab9f0398c19284b3ea4c8246d (patch)
treea64d57f2fecbded780d93f464b36354f432c3033
parentf351a002b66ae8a4b73588b7ffdffc69623181f3 (diff)
state -> world, moved struct members to private
-rw-r--r--src/animations.rs10
-rw-r--r--src/cell.rs2
-rw-r--r--src/entity.rs2
-rw-r--r--src/lib.rs2
-rw-r--r--src/main.rs4
-rw-r--r--src/world.rs (renamed from src/state.rs)10
6 files changed, 15 insertions, 15 deletions
diff --git a/src/animations.rs b/src/animations.rs
index e2cc009..b82b42e 100644
--- a/src/animations.rs
+++ b/src/animations.rs
@@ -10,9 +10,9 @@ use crate::tileset::Tileset;
#[derive(Debug, Clone, PartialEq)]
pub struct Animation {
- pub frames: Vec<Tile>,
- pub timer: Instant,
- pub current: Tile,
+ frames: Vec<Tile>,
+ timer: Instant,
+ current: Tile,
}
impl Animation {
@@ -55,8 +55,8 @@ impl Animation {
#[derive(Debug, Clone, PartialEq)]
pub struct Animations {
- pub available: HashMap<Action, Animation>,
- pub current: Animation,
+ available: HashMap<Action, Animation>,
+ current: Animation,
}
impl Animations {
diff --git a/src/cell.rs b/src/cell.rs
index 9d257ff..bce744b 100644
--- a/src/cell.rs
+++ b/src/cell.rs
@@ -9,8 +9,8 @@ use crate::tileset::Tileset;
#[derive(Debug, Clone)]
pub struct Cell {
pub id: usize,
- pub animation: Animation,
pub destination: Point2<f32>,
+ animation: Animation,
}
impl Operable for Cell {
diff --git a/src/entity.rs b/src/entity.rs
index ae3a236..3489671 100644
--- a/src/entity.rs
+++ b/src/entity.rs
@@ -13,7 +13,7 @@ pub struct Entity {
pub position: Point2<f32>,
pub spawn: Point2<f32>,
pub action: Action,
- pub map_dimensions: (f32, f32),
+ map_dimensions: (f32, f32),
}
impl Entity {
diff --git a/src/lib.rs b/src/lib.rs
index 4ecd991..a95028d 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -7,7 +7,7 @@ pub mod layer;
pub mod map;
pub mod npc;
pub mod player;
-pub mod state;
pub mod tile;
pub mod tileset;
+pub mod world;
pub mod xmlelements;
diff --git a/src/main.rs b/src/main.rs
index 6f16771..78c60f9 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,7 +1,7 @@
use ggez::conf::{NumSamples, WindowSetup};
use ggez::{event, ContextBuilder, GameResult};
-use pax_romana::state::State;
+use pax_romana::world::World;
fn main() -> GameResult {
let (ref mut context, ref mut event_loop) = ContextBuilder::new("pax-romana", "tom barrett")
@@ -13,7 +13,7 @@ fn main() -> GameResult {
.add_resource_path("./resources")
.build()?;
- let state = &mut State::new(context)?;
+ let state = &mut World::new(context)?;
event::run(context, event_loop, state)
}
diff --git a/src/state.rs b/src/world.rs
index 98ad422..0de8726 100644
--- a/src/state.rs
+++ b/src/world.rs
@@ -9,7 +9,7 @@ use crate::npc::NPC;
use crate::player::Player;
use crate::tileset::Tileset;
-pub struct State {
+pub struct World {
map: Map,
spritebatch: SpriteBatch,
camera: Camera,
@@ -17,8 +17,8 @@ pub struct State {
npcs: Vec<NPC>,
}
-impl State {
- pub fn new(context: &mut Context) -> GameResult<State> {
+impl World {
+ pub fn new(context: &mut Context) -> GameResult<World> {
let mut image = Image::new(context, "/tileset.png")?;
image.set_filter(FilterMode::Nearest);
image.set_wrap(WrapMode::Mirror, WrapMode::Mirror);
@@ -27,7 +27,7 @@ impl State {
let map = Map::new(filesystem::open(context, "/map.tmx")?, &tileset);
- Ok(State {
+ Ok(World {
map: map.clone(),
spritebatch: SpriteBatch::new(image),
camera: Camera::new(context, map.get_dimensions()),
@@ -41,7 +41,7 @@ impl State {
}
}
-impl EventHandler for State {
+impl EventHandler for World {
fn update(&mut self, _context: &mut Context) -> GameResult {
self.map.update();
self.player.update();