diff --git a/resources/atlas.json b/resources/atlas.json index 1f10ce2..e6ec36b 100644 --- a/resources/atlas.json +++ b/resources/atlas.json @@ -497,7 +497,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "feet (1)", + "filename": "explode1", "frame": {"x":976,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -505,7 +505,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "feet (2)", + "filename": "explode2", "frame": {"x":992,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -513,7 +513,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "feet (3)", + "filename": "explode3", "frame": {"x":1008,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -521,7 +521,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "feet (4)", + "filename": "feet (1)", "frame": {"x":1024,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -529,7 +529,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "feet (5)", + "filename": "feet (2)", "frame": {"x":1040,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -537,7 +537,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "feet (6)", + "filename": "feet (3)", "frame": {"x":1056,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -545,7 +545,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "feet (7)", + "filename": "feet (4)", "frame": {"x":1072,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -553,7 +553,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "fence", + "filename": "feet (5)", "frame": {"x":1088,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -561,7 +561,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "fluff", + "filename": "feet (6)", "frame": {"x":1104,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -569,7 +569,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "fluff2", + "filename": "feet (7)", "frame": {"x":1120,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -577,7 +577,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "general-0", + "filename": "fence", "frame": {"x":1136,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -585,7 +585,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "general-1", + "filename": "fluff", "frame": {"x":1152,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -593,7 +593,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "general-3", + "filename": "fluff2", "frame": {"x":1168,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -601,13 +601,37 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "general-4", + "filename": "general-0", "frame": {"x":1184,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, "sourceSize": {"w":16,"h":24} }, +{ + "filename": "general-1", + "frame": {"x":1200,"y":0,"w":16,"h":24}, + "rotated": false, + "trimmed": false, + "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, + "sourceSize": {"w":16,"h":24} +}, +{ + "filename": "general-3", + "frame": {"x":1216,"y":0,"w":16,"h":24}, + "rotated": false, + "trimmed": false, + "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, + "sourceSize": {"w":16,"h":24} +}, +{ + "filename": "general-4", + "frame": {"x":1232,"y":0,"w":16,"h":24}, + "rotated": false, + "trimmed": false, + "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, + "sourceSize": {"w":16,"h":24} +}, { "filename": "general-5", "frame": {"x":944,"y":0,"w":16,"h":24}, @@ -618,7 +642,7 @@ }, { "filename": "general-6", - "frame": {"x":1200,"y":0,"w":16,"h":24}, + "frame": {"x":1248,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, @@ -626,7 +650,7 @@ }, { "filename": "general-7", - "frame": {"x":1216,"y":0,"w":16,"h":24}, + "frame": {"x":1264,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, @@ -642,7 +666,7 @@ }, { "filename": "general-9", - "frame": {"x":1232,"y":0,"w":16,"h":24}, + "frame": {"x":1280,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, @@ -650,7 +674,7 @@ }, { "filename": "general-10", - "frame": {"x":1248,"y":0,"w":16,"h":24}, + "frame": {"x":1296,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, @@ -666,30 +690,6 @@ }, { "filename": "general-12", - "frame": {"x":1264,"y":0,"w":16,"h":24}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, - "sourceSize": {"w":16,"h":24} -}, -{ - "filename": "general-13", - "frame": {"x":1280,"y":0,"w":16,"h":24}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, - "sourceSize": {"w":16,"h":24} -}, -{ - "filename": "general-14", - "frame": {"x":1296,"y":0,"w":16,"h":24}, - "rotated": false, - "trimmed": false, - "spriteSourceSize": {"x":0,"y":0,"w":16,"h":24}, - "sourceSize": {"w":16,"h":24} -}, -{ - "filename": "general-18", "frame": {"x":1312,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -697,7 +697,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "general-19", + "filename": "general-13", "frame": {"x":1328,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -705,7 +705,7 @@ "sourceSize": {"w":16,"h":24} }, { - "filename": "general-20", + "filename": "general-14", "frame": {"x":1344,"y":0,"w":16,"h":24}, "rotated": false, "trimmed": false, @@ -1879,6 +1879,6 @@ "format": "RGBA8888", "size": {"w":1776,"h":48}, "scale": "1", - "smartupdate": "$TexturePacker:SmartUpdate:fd16d00f63ad5efff2a8369d469daa64:6efd3d3d31e2ef7389221fe30073fbfb:cbce6b53f0f49e0bf15173c25c41f876$" + "smartupdate": "$TexturePacker:SmartUpdate:b1eb58473092737ca14b8a94d167c56e:73ad4edad30f8b775d99c5028a8b814c:cbce6b53f0f49e0bf15173c25c41f876$" } } diff --git a/resources/atlas.png b/resources/atlas.png index 5956df8..6dedc28 100644 Binary files a/resources/atlas.png and b/resources/atlas.png differ diff --git a/src/consts/mod.rs b/src/consts/mod.rs index cb80d4d..7da4c53 100644 --- a/src/consts/mod.rs +++ b/src/consts/mod.rs @@ -28,5 +28,5 @@ pub const TILESIZE: Spritesize = Spritesize { pub const ZOOM_FACTOR: f32 = 2.0; pub const FONTSIZE: f32 = 16.0; -pub const DISPLAYWIDTH: u32 = 100; -pub const DISPLAYHEIGHT: u32 = 58; +pub const DISPLAYWIDTH: u32 = 120; +pub const DISPLAYHEIGHT: u32 = 67; diff --git a/src/consts/visuals.rs b/src/consts/visuals.rs index 3638c05..8b66e95 100644 --- a/src/consts/visuals.rs +++ b/src/consts/visuals.rs @@ -8,10 +8,10 @@ pub const WITH_DARKEN_BY_DISTANCE: bool = true; // If further away tiles should // the viewport itself uses 16x24 sprites - so this translates to 70x28 tiles drawn. // It also works nicely for zooming in, displaying 35x14 tiles cleanly onscreen. pub const VIEWPORT_W: i32 = 70; -pub const VIEWPORT_H: i32 = 45; +pub const VIEWPORT_H: i32 = 54; pub const TILES_IN_VIEWPORT_W: i32 = 70 / (ZOOM_FACTOR as i32); -pub const TILES_IN_VIEWPORT_H: i32 = 30 / (ZOOM_FACTOR as i32); +pub const TILES_IN_VIEWPORT_H: i32 = 36 / (ZOOM_FACTOR as i32); pub const TILE_LAYER: usize = 1; pub const ENTITY_LAYER: usize = 2; diff --git a/src/effects/damage.rs b/src/effects/damage.rs index 593dd74..02be7c9 100644 --- a/src/effects/damage.rs +++ b/src/effects/damage.rs @@ -38,27 +38,56 @@ pub fn inflict_damage(ecs: &mut World, damage: &EffectSpawner, target: Entity) { }; target_pool.hit_points.current -= ((amount as f32) * mult) as i32; let bleeders = ecs.read_storage::(); - if let Some(bleeds) = bleeders.get(target) { - add_effect( - None, - EffectType::Bloodstain { colour: bleeds.colour }, - Targets::Entity { target } - ); - } - add_effect( - None, - EffectType::Particle { - glyph: to_cp437('‼'), - sprite: "gnome".to_string(), // FIXME: REMOVE THE GNOMES - fg: RGB::named(ORANGE), - lifespan: DEFAULT_PARTICLE_LIFETIME, - delay: 0.0, - }, - Targets::Entity { target } - ); if target_pool.hit_points.current < 1 { super::DEAD_ENTITIES.lock().unwrap().push_back(target); add_effect(damage.source, EffectType::EntityDeath, Targets::Entity { target }); + for i in 0..3 { + let sprite = ( + match i { + 0 => "explode1", + 1 => "explode2", + _ => "explode3", + } + ).to_string(); + add_effect( + None, + EffectType::Particle { + glyph: to_cp437('‼'), + sprite, + fg: RGB::named(RED), + lifespan: 75.0, + delay: 75.0 * (i as f32), + }, + Targets::Entity { target } + ); + if let Some(bleeds) = bleeders.get(target) { + add_effect( + None, + EffectType::Bloodstain { colour: bleeds.colour }, + Targets::Entity { target } + ); + } + } + } else { + // Regular damage taken effect - use damagetype to determine which one to play. + add_effect( + None, + EffectType::Particle { + glyph: to_cp437('‼'), + sprite: "gnome".to_string(), // FIXME: REMOVE THE GNOMES + fg: RGB::named(ORANGE), + lifespan: DEFAULT_PARTICLE_LIFETIME, + delay: 0.0, + }, + Targets::Entity { target } + ); + if let Some(bleeds) = bleeders.get(target) { + add_effect( + None, + EffectType::Bloodstain { colour: bleeds.colour }, + Targets::Entity { target } + ); + } } } } diff --git a/src/gui/mod.rs b/src/gui/mod.rs index 316ff9c..79e109c 100644 --- a/src/gui/mod.rs +++ b/src/gui/mod.rs @@ -47,7 +47,7 @@ use crate::consts::visuals::{ VIEWPORT_W, VIEWPORT_H, }; -use crate::consts::{ TILESIZE, FONTSIZE, DISPLAYWIDTH }; +use crate::consts::{ TILESIZE, FONTSIZE, DISPLAYWIDTH, DISPLAYHEIGHT }; use crate::Fonts; use notan::prelude::*; use notan::draw::{ Draw, DrawTextSection, DrawImages, DrawShapes }; @@ -159,11 +159,12 @@ pub fn draw_bar( full: Color, empty: Color ) { - let fill: f32 = (f32::max(current as f32, 0.0) / (max as f32)) * width; - draw.line((x * TILESIZE.x, y * TILESIZE.x), ((x + fill) * TILESIZE.x, y * TILESIZE.x)) + // % full * maximum width in tiles * tile size, to get width in px + let fill: f32 = (f32::max(current as f32, 0.0) / (max as f32)) * width * TILESIZE.x; + draw.line((x, y), (x + fill, y)) .color(full) .width(height); - draw.line(((x + fill) * TILESIZE.x, y * TILESIZE.x), ((x + width) * TILESIZE.x, y * TILESIZE.x)) + draw.line((x + fill, y), (x + width * TILESIZE.x, y)) .color(empty) .width(height); } @@ -182,34 +183,34 @@ pub fn draw_ui2(ecs: &World, draw: &mut Draw, atlas: &HashMap, &hunger, &skills, ).join() { - const BAR_X: f32 = 1.0; + let initial_x = 24.0 * TILESIZE.x; + let mut x = initial_x; + let row1 = ((DISPLAYHEIGHT as f32) - 3.0) * TILESIZE.x; // 2 tiles from the bottom, in px. + let row2 = row1 + TILESIZE.x; // 1 tile below row2. + const BAR_X: f32 = 1.0 * TILESIZE.x; const BAR_WIDTH: f32 = 22.0; draw_bar( draw, BAR_X, - 55.5, + row1 + 8.0, BAR_WIDTH, TILESIZE.x, stats.hit_points.current, stats.hit_points.max, Color::GREEN, - Color::BLACK + Color::RED ); draw_bar( draw, BAR_X, - 56.5, + row2 + 8.0, BAR_WIDTH, TILESIZE.x, stats.mana.current, stats.mana.max, Color::BLUE, - Color::BLACK + Color::RED ); - let initial_x = 24.0 * TILESIZE.x; - let mut x = initial_x; - let row1 = 55.0 * TILESIZE.x; - let row2 = row1 + TILESIZE.x; let hp_colours: (RGB, RGB, RGB) = ( RGB::named(GREEN), RGB::named(RED), diff --git a/src/main.rs b/src/main.rs index 7d94437..a4814b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -20,8 +20,8 @@ fn main() -> Result<(), String> { let win_config = WindowConfig::new() .set_size(DISPLAYWIDTH * (TILESIZE.x as u32), DISPLAYHEIGHT * (TILESIZE.x as u32)) .set_title("RUST-RL") - .set_resizable(false) - //.set_fullscreen(true) -- this can be uncommented once the log scales too. Ditto for set_resizable(true). + .set_resizable(true) + .set_fullscreen(true) .set_taskbar_icon_data(Some(include_bytes!("../resources/icon.png"))) .set_vsync(true); notan diff --git a/src/melee_combat_system.rs b/src/melee_combat_system.rs index eb7ebc4..487feba 100644 --- a/src/melee_combat_system.rs +++ b/src/melee_combat_system.rs @@ -295,13 +295,6 @@ impl<'a> System<'a> for MeleeCombatSystem { ); } } - // TODO: Take out these animations (and for missing too), and turn - // them into effects - can use the damage type that gets passed in - // to determine the effect, colour, etc. - let pos = positions.get(wants_melee.target); - if let Some(pos) = pos { - particle_builder.damage_taken(pos.x, pos.y); - } add_effect( Some(entity), EffectType::Damage { amount: damage, damage_type: weapon_info.damage_type },