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
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[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"] }
|
bracket-lib = { git = "https://github.com/amethyst/bracket-lib.git", rev = "851f6f08675444fb6fa088b9e67bee9fd75554c6", features = ["serde"] }
|
||||||
regex = "1.3.6"
|
regex = "1.3.6"
|
||||||
specs = { version = "0.16.1", features = ["serde"] }
|
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 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 NORMAL_SPEED: i32 = 12; // Normal speed for almost all entities.
|
||||||
pub const SPEED_MOD_BURDENED: f32 = 0.75;
|
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_MIN_CLAMP: f32 = 0.85;
|
||||||
pub const SPRITE_OFFSET_MAX_CLAMP: f32 = 1.0;
|
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 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 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 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 SHORT_PARTICLE_LIFETIME: f32 = 100.0; // in ms
|
||||||
pub const DEFAULT_PARTICLE_LIFETIME: f32 = 200.0;
|
pub const DEFAULT_PARTICLE_LIFETIME: f32 = 200.0;
|
||||||
|
|
|
||||||
|
|
@ -255,31 +255,9 @@ pub fn setup_player_ancestry(ecs: &mut World, ancestry: Ancestry) {
|
||||||
match ancestry {
|
match ancestry {
|
||||||
Ancestry::Human => {}
|
Ancestry::Human => {}
|
||||||
Ancestry::Dwarf => {
|
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;
|
*player_skills.skills.entry(Skill::Defence).or_insert(0) += DWARF_DEFENCE_MOD;
|
||||||
}
|
}
|
||||||
Ancestry::Elf => {
|
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>();
|
let mut telepaths = ecs.write_storage::<Telepath>();
|
||||||
telepaths
|
telepaths
|
||||||
.insert(*player, Telepath {
|
.insert(*player, Telepath {
|
||||||
|
|
@ -297,17 +275,6 @@ pub fn setup_player_ancestry(ecs: &mut World, ancestry: Ancestry) {
|
||||||
.expect("Unable to insert energy component");
|
.expect("Unable to insert energy component");
|
||||||
}
|
}
|
||||||
Ancestry::Catfolk => {
|
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>();
|
let mut speeds = ecs.write_storage::<Energy>();
|
||||||
speeds
|
speeds
|
||||||
.insert(*player, Energy {
|
.insert(*player, Energy {
|
||||||
|
|
|
||||||
20
src/main.rs
20
src/main.rs
|
|
@ -26,7 +26,14 @@ fn main() -> Result<(), String> {
|
||||||
.build()
|
.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
|
let texture = gfx
|
||||||
.create_texture()
|
.create_texture()
|
||||||
.from_image(include_bytes!("../resources/atlas.png"))
|
.from_image(include_bytes!("../resources/atlas.png"))
|
||||||
|
|
@ -52,6 +59,7 @@ fn setup(gfx: &mut Graphics) -> State {
|
||||||
);
|
);
|
||||||
let mut gs = State {
|
let mut gs = State {
|
||||||
ecs: World::new(),
|
ecs: World::new(),
|
||||||
|
//audio: sounds,
|
||||||
atlas,
|
atlas,
|
||||||
interface,
|
interface,
|
||||||
font,
|
font,
|
||||||
|
|
@ -263,14 +271,10 @@ fn draw_entities(
|
||||||
} else {
|
} else {
|
||||||
panic!("No entity sprite found for ID: {}", &renderable.sprite);
|
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 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 y_pos = (entry.0.y as f32) * TILESIZE.sprite_y + offset_y;
|
||||||
let mul = themes::darken_by_distance(
|
let mul = themes::darken_by_distance(
|
||||||
Point::new(
|
Point::new(entry.0.x, entry.0.y),
|
||||||
entry.0.x + bounds.min_x - bounds.x_offset,
|
|
||||||
entry.0.y + bounds.min_y - bounds.y_offset
|
|
||||||
),
|
|
||||||
*ecs.fetch::<Point>()
|
*ecs.fetch::<Point>()
|
||||||
);
|
);
|
||||||
let col = Color::from_rgb(
|
let col = Color::from_rgb(
|
||||||
|
|
@ -356,7 +360,7 @@ fn render_map_in_view(
|
||||||
let mut sorted: Vec<_> = memories.iter().collect();
|
let mut sorted: Vec<_> = memories.iter().collect();
|
||||||
sorted.sort_by(|a, b| a.render_order.cmp(&b.render_order));
|
sorted.sort_by(|a, b| a.render_order.cmp(&b.render_order));
|
||||||
for memory in sorted.iter() {
|
for memory in sorted.iter() {
|
||||||
let mult = 0.3;
|
let mult = consts::visuals::NON_VISIBLE_MULTIPLIER;
|
||||||
let col = Color::from_rgb(
|
let col = Color::from_rgb(
|
||||||
memory.fg.r * mult,
|
memory.fg.r * mult,
|
||||||
memory.fg.g * 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);
|
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();
|
let mut draw = gfx.create_draw();
|
||||||
draw.clear(Color::BLACK);
|
draw.clear(Color::BLACK);
|
||||||
let mut log = false;
|
let mut log = false;
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ pub fn player(ecs: &mut World, player_x: i32, player_y: i32) -> Entity {
|
||||||
.create_entity()
|
.create_entity()
|
||||||
.with(Position { x: player_x, y: player_y })
|
.with(Position { x: player_x, y: player_y })
|
||||||
.with(BlocksTile {}) // FIXME: Put in actual player sprite
|
.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(Bleeds { colour: RGB::named(BLOODSTAIN_COLOUR) })
|
||||||
.with(Player {})
|
.with(Player {})
|
||||||
.with(Mind {})
|
.with(Mind {})
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@ impl Fonts {
|
||||||
#[derive(AppState)]
|
#[derive(AppState)]
|
||||||
pub struct State {
|
pub struct State {
|
||||||
pub ecs: World,
|
pub ecs: World,
|
||||||
|
//pub audio: HashMap<String, AudioSource>,
|
||||||
pub atlas: HashMap<String, Texture>,
|
pub atlas: HashMap<String, Texture>,
|
||||||
pub interface: HashMap<String, Texture>,
|
pub interface: HashMap<String, Texture>,
|
||||||
pub font: Fonts,
|
pub font: Fonts,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue