Add tile graphic

This commit is contained in:
crumblingstatue 2023-04-01 21:01:14 +02:00
parent d78726eb5b
commit fbc7e35f9e
11 changed files with 812 additions and 20 deletions

View file

@ -1,16 +1,22 @@
use crate::{math::WorldPos, world::World};
use sfml::graphics::{RenderTarget, RenderWindow, Sprite};
use crate::{math::WorldPos, res::Res, world::World};
pub struct GameState {
transient: TransientGameState,
persistent: PersistentGameState,
}
/// Transient game state, not saved to disk
pub struct TransientGameState {
camera_offset: WorldPos,
}
/// Persistent game state, saved to disk
pub struct PersistentGameState {
world: World,
}
impl GameState {
pub(crate) fn draw_world(&mut self, rw: &mut RenderWindow, res: &Res) {
rw.draw(&Sprite::with_texture(&res.tile_atlas));
}
}
impl Default for GameState {
fn default() -> Self {
Self {
camera_offset: WorldPos { x: 0, y: 0 },
world: Default::default(),
}
}
}