player avatar - currently bare. need a component for avatar_sprite!
This commit is contained in:
parent
44b0674b5a
commit
af1040b970
10 changed files with 329 additions and 245 deletions
|
|
@ -6,7 +6,7 @@ edition = "2021"
|
|||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
notan = { version = "0.10.0", features = ["text"] }
|
||||
notan = { version = "0.10.0", features = ["text", "audio"] }
|
||||
bracket-lib = { git = "https://github.com/amethyst/bracket-lib.git", rev = "851f6f08675444fb6fa088b9e67bee9fd75554c6", features = ["serde"] }
|
||||
regex = "1.3.6"
|
||||
specs = { version = "0.16.1", features = ["serde"] }
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.3 KiB |
BIN
resources/sounds/hit.wav
Normal file
BIN
resources/sounds/hit.wav
Normal file
Binary file not shown.
|
|
@ -1,4 +1,4 @@
|
|||
pub const DEFAULT_VIEWSHED_STANDARD: i32 = 16; // Standard viewshed radius for almost all entities.
|
||||
pub const DEFAULT_VIEWSHED_STANDARD: i32 = 6; // Standard viewshed radius for almost all entities.
|
||||
pub const CARRY_CAPACITY_PER_STRENGTH: i32 = 5; // How much weight can be carried per point of strength.
|
||||
pub const NORMAL_SPEED: i32 = 12; // Normal speed for almost all entities.
|
||||
pub const SPEED_MOD_BURDENED: f32 = 0.75;
|
||||
|
|
|
|||
|
|
@ -24,11 +24,11 @@ pub const GLOBAL_OFFSET_MAX_CLAMP: f32 = 1.0;
|
|||
pub const SPRITE_OFFSET_MIN_CLAMP: f32 = 0.85;
|
||||
pub const SPRITE_OFFSET_MAX_CLAMP: f32 = 1.0;
|
||||
pub const WITH_SCANLINES_BRIGHTEN_AMOUNT: f32 = 0.1; // 0.0 = no brightening, 1.0 = full brightening.
|
||||
pub const NON_VISIBLE_MULTIPLIER: f32 = 0.3; // 0.0 = black, 1.0 = full colour.
|
||||
pub const NON_VISIBLE_MULTIPLIER: f32 = 0.2; // 0.0 = black, 1.0 = full colour.
|
||||
pub const NON_VISIBLE_MULTIPLIER_IF_SCANLINES: f32 = 0.8; // as above, but when using scanlines. should be higher.
|
||||
pub const MAX_DARKENING: f32 = 0.35; // 0.0 = black, 1.0 = full colour - only used if WITH_DARKEN_BY_DISTANCE is true.
|
||||
pub const MAX_DARKENING: f32 = 0.2; // 0.0 = black, 1.0 = full colour - only used if WITH_DARKEN_BY_DISTANCE is true.
|
||||
pub const MAX_DARKENING_IF_SCANLINES: f32 = 0.9; // as above, but when using scanlines. should be higher.
|
||||
pub const START_DARKEN_AT_N_TILES: f32 = 7.0; // start darkening at this distance (should always be less than entity::DEFAULT_VIEWSHED_STANDARD).
|
||||
pub const START_DARKEN_AT_N_TILES: f32 = 1.0; // start darkening at this distance (should always be less than entity::DEFAULT_VIEWSHED_STANDARD).
|
||||
|
||||
pub const SHORT_PARTICLE_LIFETIME: f32 = 100.0; // in ms
|
||||
pub const DEFAULT_PARTICLE_LIFETIME: f32 = 200.0;
|
||||
|
|
|
|||
|
|
@ -255,31 +255,9 @@ pub fn setup_player_ancestry(ecs: &mut World, ancestry: Ancestry) {
|
|||
match ancestry {
|
||||
Ancestry::Human => {}
|
||||
Ancestry::Dwarf => {
|
||||
renderables
|
||||
.insert(
|
||||
*player,
|
||||
Renderable::new(
|
||||
to_cp437(DWARF_GLYPH),
|
||||
"gnome".to_string(),
|
||||
RGB::named(DWARF_COLOUR),
|
||||
2
|
||||
)
|
||||
)
|
||||
.expect("Unable to insert renderable component");
|
||||
*player_skills.skills.entry(Skill::Defence).or_insert(0) += DWARF_DEFENCE_MOD;
|
||||
}
|
||||
Ancestry::Elf => {
|
||||
renderables
|
||||
.insert(
|
||||
*player,
|
||||
Renderable::new(
|
||||
to_cp437(ELF_GLYPH),
|
||||
"gnome".to_string(),
|
||||
RGB::named(ELF_COLOUR),
|
||||
2
|
||||
)
|
||||
)
|
||||
.expect("Unable to insert renderable component");
|
||||
let mut telepaths = ecs.write_storage::<Telepath>();
|
||||
telepaths
|
||||
.insert(*player, Telepath {
|
||||
|
|
@ -297,17 +275,6 @@ pub fn setup_player_ancestry(ecs: &mut World, ancestry: Ancestry) {
|
|||
.expect("Unable to insert energy component");
|
||||
}
|
||||
Ancestry::Catfolk => {
|
||||
renderables
|
||||
.insert(
|
||||
*player,
|
||||
Renderable::new(
|
||||
to_cp437(CATFOLK_GLYPH),
|
||||
"gnome".to_string(),
|
||||
RGB::named(CATFOLK_COLOUR),
|
||||
2
|
||||
)
|
||||
)
|
||||
.expect("Unable to insert renderable component");
|
||||
let mut speeds = ecs.write_storage::<Energy>();
|
||||
speeds
|
||||
.insert(*player, Energy {
|
||||
|
|
|
|||
20
src/main.rs
20
src/main.rs
|
|
@ -26,7 +26,14 @@ fn main() -> Result<(), String> {
|
|||
.build()
|
||||
}
|
||||
|
||||
fn setup(gfx: &mut Graphics) -> State {
|
||||
fn setup(app: &mut App, gfx: &mut Graphics) -> State {
|
||||
/*
|
||||
let sound = app.audio.create_source(include_bytes!("../resources/sounds/hit.wav")).unwrap();
|
||||
let sounds: HashMap<String, AudioSource> = vec![("hit".to_string(), sound)]
|
||||
.into_iter()
|
||||
.collect();
|
||||
*/
|
||||
|
||||
let texture = gfx
|
||||
.create_texture()
|
||||
.from_image(include_bytes!("../resources/atlas.png"))
|
||||
|
|
@ -52,6 +59,7 @@ fn setup(gfx: &mut Graphics) -> State {
|
|||
);
|
||||
let mut gs = State {
|
||||
ecs: World::new(),
|
||||
//audio: sounds,
|
||||
atlas,
|
||||
interface,
|
||||
font,
|
||||
|
|
@ -263,14 +271,10 @@ fn draw_entities(
|
|||
} else {
|
||||
panic!("No entity sprite found for ID: {}", &renderable.sprite);
|
||||
};
|
||||
console::log(&format!("offset_x: {}, offset_y: {}", offset_x, offset_y));
|
||||
let x_pos = (entry.0.x as f32) * TILESIZE.sprite_x + offset_x;
|
||||
let y_pos = (entry.0.y as f32) * TILESIZE.sprite_y + offset_y;
|
||||
let mul = themes::darken_by_distance(
|
||||
Point::new(
|
||||
entry.0.x + bounds.min_x - bounds.x_offset,
|
||||
entry.0.y + bounds.min_y - bounds.y_offset
|
||||
),
|
||||
Point::new(entry.0.x, entry.0.y),
|
||||
*ecs.fetch::<Point>()
|
||||
);
|
||||
let col = Color::from_rgb(
|
||||
|
|
@ -356,7 +360,7 @@ fn render_map_in_view(
|
|||
let mut sorted: Vec<_> = memories.iter().collect();
|
||||
sorted.sort_by(|a, b| a.render_order.cmp(&b.render_order));
|
||||
for memory in sorted.iter() {
|
||||
let mult = 0.3;
|
||||
let mult = consts::visuals::NON_VISIBLE_MULTIPLIER;
|
||||
let col = Color::from_rgb(
|
||||
memory.fg.r * mult,
|
||||
memory.fg.g * mult,
|
||||
|
|
@ -489,7 +493,7 @@ fn draw_bg(_ecs: &World, draw: &mut Draw, atlas: &HashMap<String, Texture>) {
|
|||
draw_spritebox(sidebox, draw, atlas);
|
||||
}
|
||||
|
||||
fn draw(_app: &mut App, gfx: &mut Graphics, gs: &mut State) {
|
||||
fn draw(app: &mut App, gfx: &mut Graphics, gs: &mut State) {
|
||||
let mut draw = gfx.create_draw();
|
||||
draw.clear(Color::BLACK);
|
||||
let mut log = false;
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
|||
.create_entity()
|
||||
.with(Position { x: player_x, y: player_y })
|
||||
.with(BlocksTile {}) // FIXME: Put in actual player sprite
|
||||
.with(Renderable::new(to_cp437('@'), "gnome".to_string(), RGB::named(YELLOW), 2))
|
||||
.with(Renderable::new(to_cp437('@'), "avatar".to_string(), RGB::named(WHITE), 2))
|
||||
.with(Bleeds { colour: RGB::named(BLOODSTAIN_COLOUR) })
|
||||
.with(Player {})
|
||||
.with(Mind {})
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ impl Fonts {
|
|||
#[derive(AppState)]
|
||||
pub struct State {
|
||||
pub ecs: World,
|
||||
//pub audio: HashMap<String, AudioSource>,
|
||||
pub atlas: HashMap<String, Texture>,
|
||||
pub interface: HashMap<String, Texture>,
|
||||
pub font: Fonts,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue