refining the sprites
This commit is contained in:
parent
d58614b106
commit
670b365def
6 changed files with 28 additions and 22 deletions
|
|
@ -2,7 +2,7 @@
|
||||||
{
|
{
|
||||||
"id": "door",
|
"id": "door",
|
||||||
"name": "door",
|
"name": "door",
|
||||||
"renderable": { "glyph": "+", "fg": "#00FFFF", "bg": "#000000", "order": 2 },
|
"renderable": { "glyph": "+", "sprite": 17, "fg": "#00FFFF", "bg": "#000000", "order": 2 },
|
||||||
"flags": ["DOOR"]
|
"flags": ["DOOR"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ use bracket_lib::prelude::*;
|
||||||
use specs::prelude::*;
|
use specs::prelude::*;
|
||||||
use std::ops::Mul;
|
use std::ops::Mul;
|
||||||
use super::data::visuals::{ VIEWPORT_W, VIEWPORT_H };
|
use super::data::visuals::{ VIEWPORT_W, VIEWPORT_H };
|
||||||
use super::data::sprites::*;
|
|
||||||
use super::data::prelude::*;
|
use super::data::prelude::*;
|
||||||
|
|
||||||
const SHOW_BOUNDARIES: bool = false;
|
const SHOW_BOUNDARIES: bool = false;
|
||||||
|
|
@ -38,6 +37,19 @@ pub fn render_camera(ecs: &World, ctx: &mut BTerm) {
|
||||||
let map = ecs.fetch::<Map>();
|
let map = ecs.fetch::<Map>();
|
||||||
let (min_x, max_x, min_y, max_y, x_offset, y_offset) = get_screen_bounds(ecs, ctx);
|
let (min_x, max_x, min_y, max_y, x_offset, y_offset) = get_screen_bounds(ecs, ctx);
|
||||||
|
|
||||||
|
ctx.set_active_console(0);
|
||||||
|
for i in 0..16 {
|
||||||
|
for j in 0..19 {
|
||||||
|
ctx.add_sprite(
|
||||||
|
Rect::with_size(i * 16, j * 16, 16, 16),
|
||||||
|
0,
|
||||||
|
RGBA::named(WHITE),
|
||||||
|
i + j * 16
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctx.set_active_console(1);
|
||||||
|
|
||||||
// Render map
|
// Render map
|
||||||
let mut y = 0;
|
let mut y = 0;
|
||||||
for t_y in min_y..max_y {
|
for t_y in min_y..max_y {
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,11 @@
|
||||||
use super::{ State, RunState, tooltip::draw_tooltips, camera::get_screen_bounds };
|
use super::{
|
||||||
|
State,
|
||||||
|
RunState,
|
||||||
|
tooltip::draw_tooltips,
|
||||||
|
camera::get_screen_bounds,
|
||||||
|
VIEWPORT_H,
|
||||||
|
VIEWPORT_W,
|
||||||
|
};
|
||||||
use bracket_lib::prelude::*;
|
use bracket_lib::prelude::*;
|
||||||
|
|
||||||
#[derive(PartialEq, Copy, Clone)]
|
#[derive(PartialEq, Copy, Clone)]
|
||||||
|
|
@ -23,9 +30,8 @@ pub fn show_farlook(gs: &mut State, ctx: &mut BTerm) -> FarlookResult {
|
||||||
);
|
);
|
||||||
|
|
||||||
if let RunState::Farlook { x, y } = *runstate {
|
if let RunState::Farlook { x, y } = *runstate {
|
||||||
let (screen_x, screen_y) = (40, 30);
|
let x = x.clamp(x_offset, x_offset - 1 + VIEWPORT_W);
|
||||||
let x = x.clamp(x_offset, x_offset - 1 + (screen_x as i32));
|
let y = y.clamp(y_offset, y_offset - 1 + VIEWPORT_H);
|
||||||
let y = y.clamp(y_offset, y_offset - 1 + (screen_y as i32));
|
|
||||||
|
|
||||||
ctx.set(x, y, RGB::named(WHITE), RGB::named(BLACK), to_cp437('X'));
|
ctx.set(x, y, RGB::named(WHITE), RGB::named(BLACK), to_cp437('X'));
|
||||||
draw_tooltips(&gs.ecs, ctx, Some((x, y)));
|
draw_tooltips(&gs.ecs, ctx, Some((x, y)));
|
||||||
|
|
|
||||||
|
|
@ -1235,9 +1235,8 @@ pub fn ranged_target(
|
||||||
&gs.ecs,
|
&gs.ecs,
|
||||||
ctx
|
ctx
|
||||||
);
|
);
|
||||||
let (screen_x, screen_y) = (40, 30);
|
let x = x.clamp(x_offset, x_offset - 1 + VIEWPORT_W);
|
||||||
let x = x.clamp(x_offset, x_offset - 1 + (screen_x as i32));
|
let y = y.clamp(y_offset, y_offset - 1 + VIEWPORT_H);
|
||||||
let y = y.clamp(y_offset, y_offset - 1 + (screen_y as i32));
|
|
||||||
|
|
||||||
let mut mouse_pos_adjusted = mouse_pos;
|
let mut mouse_pos_adjusted = mouse_pos;
|
||||||
mouse_pos_adjusted.0 += min_x - x_offset;
|
mouse_pos_adjusted.0 += min_x - x_offset;
|
||||||
|
|
|
||||||
13
src/main.rs
13
src/main.rs
|
|
@ -45,19 +45,6 @@ fn main() -> BError {
|
||||||
context.with_post_scanlines(config::CONFIG.visuals.with_screen_burn);
|
context.with_post_scanlines(config::CONFIG.visuals.with_screen_burn);
|
||||||
}
|
}
|
||||||
|
|
||||||
context.set_active_console(0);
|
|
||||||
for i in 0..16 {
|
|
||||||
for j in 0..19 {
|
|
||||||
context.add_sprite(
|
|
||||||
Rect::with_size(i * 16, j * 16, 16, 16),
|
|
||||||
0,
|
|
||||||
RGBA::named(WHITE),
|
|
||||||
i + j * 16
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
context.set_active_console(1);
|
|
||||||
|
|
||||||
let mut gs = State {
|
let mut gs = State {
|
||||||
ecs: World::new(),
|
ecs: World::new(),
|
||||||
mapgen_next_state: Some(RunState::MainMenu {
|
mapgen_next_state: Some(RunState::MainMenu {
|
||||||
|
|
|
||||||
|
|
@ -134,6 +134,7 @@ pub fn try_door(i: i32, j: i32, ecs: &mut World) -> RunState {
|
||||||
let mut renderables = ecs.write_storage::<Renderable>();
|
let mut renderables = ecs.write_storage::<Renderable>();
|
||||||
let render_data = renderables.get_mut(potential_target).unwrap();
|
let render_data = renderables.get_mut(potential_target).unwrap();
|
||||||
render_data.glyph = to_cp437('+'); // Nethack open door, maybe just use '/' instead.
|
render_data.glyph = to_cp437('+'); // Nethack open door, maybe just use '/' instead.
|
||||||
|
render_data.sprite = Some(17); // TODO: Enum
|
||||||
door_pos = Some(Point::new(pos.x + delta_x, pos.y + delta_y));
|
door_pos = Some(Point::new(pos.x + delta_x, pos.y + delta_y));
|
||||||
}
|
}
|
||||||
result = RunState::Ticking;
|
result = RunState::Ticking;
|
||||||
|
|
@ -231,6 +232,7 @@ pub fn open(i: i32, j: i32, ecs: &mut World) -> RunState {
|
||||||
let mut renderables = ecs.write_storage::<Renderable>();
|
let mut renderables = ecs.write_storage::<Renderable>();
|
||||||
let render_data = renderables.get_mut(potential_target).unwrap();
|
let render_data = renderables.get_mut(potential_target).unwrap();
|
||||||
render_data.glyph = to_cp437('▓'); // Nethack open door, maybe just use '/' instead.
|
render_data.glyph = to_cp437('▓'); // Nethack open door, maybe just use '/' instead.
|
||||||
|
render_data.sprite = Some(18); // TODO: Enum
|
||||||
door_pos = Some(Point::new(pos.x + delta_x, pos.y + delta_y));
|
door_pos = Some(Point::new(pos.x + delta_x, pos.y + delta_y));
|
||||||
}
|
}
|
||||||
result = RunState::Ticking;
|
result = RunState::Ticking;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue