player now blockstile

This commit is contained in:
Llywelwyn 2023-08-30 06:07:40 +01:00
parent 8eb98b5baa
commit 454c2aab63
2 changed files with 21 additions and 21 deletions

View file

@ -246,29 +246,27 @@ impl GameState for State {
new_runstate = RunState::AwaitingInput; new_runstate = RunState::AwaitingInput;
} }
RunState::AwaitingInput => { RunState::AwaitingInput => {
while particle_system::check_queue(&self.ecs) { // We refresh the index, and run anything that might
// We refresh the index, and run anything that might // still be in the queue, just to make 100% sure that
// still be in the queue, just to make 100% sure that // there are no lingering effects from the last tick.
// there are no lingering effects from the last tick. self.refresh_indexes();
self.refresh_indexes(); effects::run_effects_queue(&mut self.ecs);
effects::run_effects_queue(&mut self.ecs); // Sanity-checking that the player actually *should*
// Sanity-checking that the player actually *should* // be taking a turn before giving them one. If they
// be taking a turn before giving them one. If they // don't have a turn component, go back to ticking.
// don't have a turn component, go back to ticking. let mut can_act = false;
let mut can_act = false; {
{ let player_entity = self.ecs.fetch::<Entity>();
let player_entity = self.ecs.fetch::<Entity>(); let turns = self.ecs.read_storage::<TakingTurn>();
let turns = self.ecs.read_storage::<TakingTurn>(); if let Some(_) = turns.get(*player_entity) {
if let Some(_) = turns.get(*player_entity) { can_act = true;
can_act = true;
}
}
if can_act {
new_runstate = player_input(self, ctx);
} else {
new_runstate = RunState::Ticking;
} }
} }
if can_act {
new_runstate = player_input(self, ctx);
} else {
new_runstate = RunState::Ticking;
}
} }
RunState::Ticking => { RunState::Ticking => {
while new_runstate == RunState::Ticking && particle_system::check_queue(&self.ecs) { while new_runstate == RunState::Ticking && particle_system::check_queue(&self.ecs) {

View file

@ -23,6 +23,7 @@ use super::{
Skills, Skills,
TileType, TileType,
Viewshed, Viewshed,
BlocksTile,
}; };
use crate::data::entity; use crate::data::entity;
use crate::gamesystem::*; use crate::gamesystem::*;
@ -43,6 +44,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
let player = ecs let player = ecs
.create_entity() .create_entity()
.with(Position { x: player_x, y: player_y }) .with(Position { x: player_x, y: player_y })
.with(BlocksTile {})
.with(Renderable { .with(Renderable {
glyph: rltk::to_cp437('@'), glyph: rltk::to_cp437('@'),
fg: RGB::named(rltk::YELLOW), fg: RGB::named(rltk::YELLOW),