particles, and centred camera
This commit is contained in:
parent
e9cace85c6
commit
cdf16aca9d
5 changed files with 50 additions and 15 deletions
|
|
@ -7,7 +7,8 @@ const SHOW_BOUNDARIES: bool = false;
|
|||
|
||||
pub fn get_screen_bounds(ecs: &World, ctx: &mut Rltk) -> (i32, i32, i32, i32) {
|
||||
let player_pos = ecs.fetch::<Point>();
|
||||
let (x_chars, y_chars) = ctx.get_char_size();
|
||||
//let (x_chars, y_chars) = ctx.get_char_size();
|
||||
let (x_chars, y_chars) = (80, 43);
|
||||
|
||||
let centre_x = (x_chars / 2) as i32;
|
||||
let centre_y = (y_chars / 2) as i32;
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ use specs::prelude::*;
|
|||
use std::collections::BTreeMap;
|
||||
|
||||
pub fn draw_ui(ecs: &World, ctx: &mut Rltk) {
|
||||
ctx.draw_hollow_box_double(0, 43, 79, 7, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK));
|
||||
ctx.draw_box_double(0, 43, 79, 7, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK));
|
||||
|
||||
// Render stats
|
||||
let combat_stats = ecs.read_storage::<CombatStats>();
|
||||
|
|
|
|||
|
|
@ -273,14 +273,7 @@ impl<'a> System<'a> for ItemUseSystem {
|
|||
}
|
||||
let pos = positions.get(entity);
|
||||
if let Some(pos) = pos {
|
||||
particle_builder.request(
|
||||
pos.x,
|
||||
pos.y,
|
||||
rltk::RGB::named(rltk::GREEN),
|
||||
rltk::RGB::named(rltk::BLACK),
|
||||
rltk::to_cp437('♥'),
|
||||
DEFAULT_PARTICLE_LIFETIME,
|
||||
);
|
||||
particle_builder.heal(pos.x, pos.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ use super::{ParticleLifetime, Position, Renderable, Rltk};
|
|||
use rltk::RGB;
|
||||
use specs::prelude::*;
|
||||
|
||||
pub const SHORT_PARTICLE_LIFETIME: f32 = 100.0;
|
||||
// For things which will happen frequently - i.e. attacking.
|
||||
pub const DEFAULT_PARTICLE_LIFETIME: f32 = 150.0;
|
||||
pub const DEFAULT_PARTICLE_LIFETIME: f32 = 200.0;
|
||||
// For exceptional things, like large AOEs, to make sure the
|
||||
// player can actually see what's being impacted - i.e. fireball.
|
||||
pub const LONG_PARTICLE_LIFETIME: f32 = 300.0;
|
||||
|
|
@ -56,11 +57,47 @@ impl ParticleBuilder {
|
|||
}
|
||||
|
||||
pub fn damage_taken(&mut self, x: i32, y: i32) {
|
||||
self.request(x, y, rltk::RGB::named(rltk::ORANGE), rltk::RGB::named(rltk::BLACK), rltk::to_cp437('‼'), 200.0);
|
||||
self.request(
|
||||
x,
|
||||
y,
|
||||
rltk::RGB::named(rltk::ORANGE),
|
||||
rltk::RGB::named(rltk::BLACK),
|
||||
rltk::to_cp437('‼'),
|
||||
DEFAULT_PARTICLE_LIFETIME,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn trap_triggered(&mut self, x: i32, y: i32) {
|
||||
self.request(x, y, rltk::RGB::named(rltk::RED), rltk::RGB::named(rltk::RED), rltk::to_cp437('‼'), 200.0);
|
||||
self.request(
|
||||
x,
|
||||
y,
|
||||
rltk::RGB::named(rltk::RED),
|
||||
rltk::RGB::named(rltk::RED),
|
||||
rltk::to_cp437('‼'),
|
||||
DEFAULT_PARTICLE_LIFETIME,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn heal(&mut self, x: i32, y: i32) {
|
||||
self.request(
|
||||
x,
|
||||
y,
|
||||
rltk::RGB::named(rltk::GREEN),
|
||||
rltk::RGB::named(rltk::BLACK),
|
||||
rltk::to_cp437('♥'),
|
||||
DEFAULT_PARTICLE_LIFETIME,
|
||||
);
|
||||
}
|
||||
|
||||
pub fn kick(&mut self, x: i32, y: i32) {
|
||||
self.request(
|
||||
x,
|
||||
y,
|
||||
rltk::RGB::named(rltk::CHOCOLATE),
|
||||
rltk::RGB::named(rltk::BLACK),
|
||||
rltk::to_cp437('‼'),
|
||||
SHORT_PARTICLE_LIFETIME,
|
||||
);
|
||||
}
|
||||
|
||||
// Makes a particle request in the shape of an 'x'. Sort of.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
use super::{
|
||||
gamelog, BlocksTile, BlocksVisibility, CombatStats, Door, EntityMoved, Hidden, HungerClock, HungerState, Item, Map,
|
||||
Monster, Name, Player, Position, Renderable, RunState, State, SufferDamage, Telepath, TileType, Viewshed,
|
||||
WantsToMelee, WantsToPickupItem,
|
||||
Monster, Name, ParticleBuilder, Player, Position, Renderable, RunState, State, SufferDamage, Telepath, TileType,
|
||||
Viewshed, WantsToMelee, WantsToPickupItem,
|
||||
};
|
||||
use rltk::{Point, RandomNumberGenerator, Rltk, VirtualKeyCode};
|
||||
use specs::prelude::*;
|
||||
|
|
@ -208,6 +208,8 @@ pub fn kick(i: i32, j: i32, ecs: &mut World) -> RunState {
|
|||
if let Some(door) = door {
|
||||
// If the door is closed,
|
||||
if door.open == false {
|
||||
let mut particle_builder = ecs.write_resource::<ParticleBuilder>();
|
||||
particle_builder.kick(pos.x + delta_x, pos.y + delta_y);
|
||||
// 33% chance of breaking it down.
|
||||
if rng.roll_dice(1, 3) == 1 {
|
||||
gamelog::Logger::new()
|
||||
|
|
@ -240,6 +242,8 @@ pub fn kick(i: i32, j: i32, ecs: &mut World) -> RunState {
|
|||
}
|
||||
if let Some(_) = last_non_door_target {
|
||||
gamelog::Logger::new().append("You kick the").item_name_n(target_name).period().log();
|
||||
let mut particle_builder = ecs.write_resource::<ParticleBuilder>();
|
||||
particle_builder.kick(pos.x + delta_x, pos.y + delta_y);
|
||||
// Do something here if it's anything other than a door.
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue