weighted spawns, magic mapping, and curses

This commit is contained in:
Llywelwyn 2023-07-10 06:49:31 +01:00
parent b8f8691e90
commit c6639b7616
8 changed files with 318 additions and 133 deletions

View file

@ -57,64 +57,54 @@ fn draw_tooltips(ecs: &World, ctx: &mut Rltk) {
}
if !tooltip.is_empty() {
let mut width: i32 = 0;
for s in tooltip.iter() {
if width < s.len() as i32 {
width = s.len() as i32;
}
width += 3;
if mouse_pos.0 > 40 {
let arrow_pos = Point::new(mouse_pos.0 - 2, mouse_pos.1);
let left_x = mouse_pos.0 - width;
let mut y = mouse_pos.1;
for s in tooltip.iter() {
ctx.print_color(left_x, y, RGB::named(rltk::WHITE), RGB::named(rltk::GREY), s);
let padding = (width - s.len() as i32) - 1;
for i in 0..padding {
ctx.print_color(
arrow_pos.x - i,
y,
RGB::named(rltk::WHITE),
RGB::named(rltk::GREY),
&" ".to_string(),
);
}
y += 1;
if mouse_pos.0 > 40 {
let arrow_pos = Point::new(mouse_pos.0 - 2, mouse_pos.1);
let left_x = mouse_pos.0 - 3;
let mut y = mouse_pos.1;
for s in tooltip.iter() {
for i in 0..2 {
ctx.print_color(
arrow_pos.x - i,
y,
RGB::named(rltk::WHITE),
RGB::named(rltk::GREY),
&" ".to_string(),
);
}
ctx.print_color(
arrow_pos.x,
arrow_pos.y,
RGB::named(rltk::WHITE),
RGB::named(rltk::GREY),
&"->".to_string(),
);
} else {
let arrow_pos = Point::new(mouse_pos.0 + 1, mouse_pos.1);
let left_x = mouse_pos.0 + 3;
let mut y = mouse_pos.1;
for s in tooltip.iter() {
ctx.print_color(left_x + 1, y, RGB::named(rltk::WHITE), RGB::named(rltk::GREY), s);
let padding = (width - s.len() as i32) - 1;
for i in 0..padding {
ctx.print_color(
arrow_pos.x + 1 + i,
y,
RGB::named(rltk::WHITE),
RGB::named(rltk::GREY),
&" ".to_string(),
);
}
y += 1;
}
ctx.print_color(
arrow_pos.x,
arrow_pos.y,
RGB::named(rltk::WHITE),
RGB::named(rltk::GREY),
&"<-".to_string(),
);
ctx.print_color_right(left_x, y, RGB::named(rltk::WHITE), RGB::named(rltk::GREY), s);
y += 1;
}
ctx.print_color(
arrow_pos.x,
arrow_pos.y,
RGB::named(rltk::WHITE),
RGB::named(rltk::GREY),
&"->".to_string(),
);
} else {
let arrow_pos = Point::new(mouse_pos.0 + 1, mouse_pos.1);
let left_x = mouse_pos.0 + 3;
let mut y = mouse_pos.1;
for s in tooltip.iter() {
for i in 0..2 {
ctx.print_color(
arrow_pos.x + 1 + i,
y,
RGB::named(rltk::WHITE),
RGB::named(rltk::GREY),
&" ".to_string(),
);
}
ctx.print_color(left_x + 1, y, RGB::named(rltk::WHITE), RGB::named(rltk::DARKGREY), s);
y += 1;
}
ctx.print_color(
arrow_pos.x,
arrow_pos.y,
RGB::named(rltk::WHITE),
RGB::named(rltk::GREY),
&"<-".to_string(),
);
}
}
}
@ -136,7 +126,7 @@ pub fn show_inventory(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
let count = inventory.count();
let mut y = (25 - (count / 2)) as i32;
ctx.draw_box(15, y - 2, 31, (count + 3) as i32, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK));
ctx.draw_box(15, y - 2, 37, (count + 3) as i32, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK));
ctx.print_color(18, y - 2, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "Inventory");
ctx.print_color(18, y + count as i32 + 1, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "ESC to cancel");
@ -178,7 +168,7 @@ pub fn drop_item_menu(gs: &mut State, ctx: &mut Rltk) -> (ItemMenuResult, Option
let count = inventory.count();
let mut y = (25 - (count / 2)) as i32;
ctx.draw_box(15, y - 2, 31, (count + 3) as i32, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK));
ctx.draw_box(15, y - 2, 37, (count + 3) as i32, RGB::named(rltk::WHITE), RGB::named(rltk::BLACK));
ctx.print_color(18, y - 2, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "Drop what?");
ctx.print_color(18, y + count as i32 + 1, RGB::named(rltk::YELLOW), RGB::named(rltk::BLACK), "ESC to cancel");