bracket-lib icon indicating copy to clipboard operation
bracket-lib copied to clipboard

Alignment of text vs hollow_box

Open jackfranklin opened this issue 3 years ago • 0 comments

Hello,

Firstly: thank you so much for this library and for your book! I'm having a really fun time learning Rust whilst hacking on a little game idea :)

I've noticed that when drawing text compared to drawing a hollow box using ctx.draw_hollow_box, the two do not align up and seem to use different grids - or one is offset on the grid.

In the screenshot below, I've drawn a "T" at (x, y) using ctx.print(x, y, "T"). I've then got code that draws a hollow box around the mouse's position:

self.map.render(ctx);                                                                                                                       
let mouse_pos = INPUT.lock().mouse_tile(0);                                                                                                 
ctx.set_active_console(2); // separate tile for mouse highlights                                                                                                                  
ctx.draw_hollow_box(mouse_pos.x, mouse_pos.y, 1, 1, YELLOW, BLACK);

I would (perhaps naively) expect here that I could hover over a "T" that's been drawn, and see a yellow box drawn around it, but instead it seems like the boxes are at a different offset:

Screenshot from 2022-02-15 08-15-22

I think this is probably due to how the cursor is translated into an (x, y) on the grid, but I'm not sure how to resolve or if this is even possible - am I thinking about this in the wrong way?

Thanks again!

jackfranklin avatar Feb 15 '22 08:02 jackfranklin