mikecargal

mikecargal

Hands-On Rust: Wrong multiplier for 8x8 console in main.rs

Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display)

It looks like

    ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2,
​	        ​"terminal8x8.png"​)”

should be:

    ​.with_simple_console_no_bg​(SCREEN_WIDTH*4, SCREEN_HEIGHT*4,
​	        ​"terminal8x8.png"​)”

I had thought that my HUD seemed a bit bigger than the screen shots, but it really showed up when I added the tooltips and they were way off (being multiplied by 4)

Also… :slight_smile: another Mac/Big Sur terminal rendering artifact:

It looks like the top row (or 2??) of pixels are being occluded.

Most Liked

herbert

herbert

Author of Hands-on Rust

Not embarrassing - happens to all of us. I once replaced every news article on a production server with the word “quilting” because of an SQL typo…

I think you’re right about renaming the constants and making the multiply/scaling more obvious. I’ll see if I can clean that up for the next beta. Thanks!

That’s a good point about magic numbers. You could include

const MAP_LAYER : usize = 0;`
const DISPLAY_LAYER : usize = 1;`
const HUD_LAYER : usize = 2;

in your prelude, and use those. That would definitely be easier to read - I’ll see if putting that in won’t blow up my page count too badly (the eternal author struggle: fitting everything into a size the publisher wants to print!)

mikecargal

mikecargal

This is embarrassing…

I used DISPLAY_* (instead of SCREEN_) when I set up the simple_console (since the others used DISPLAY_. It appears that, when reporting my “issue” I copied/pasted from the book, instead of my code.

In whatever of my defense I might mount, I think that DISPLAY_WIDTH4 and DISPLAY_HEIGHT4 make a bit more sense, because you’re using DISPLAY* constants on the other consoles and 32/8 = 4. SCREEN_* works (with 2) because there’s already a divide my 2.). And… and… the HUD is more of a DISPLAY thing played over the window into the full screen (THat’s my defense, and I’m sticking to it :wink: )

Of course, all said, your code is correct, and my “issue” was my typo. Deeply sorry about wasting your time.

Arbitrary code critique… I’m at the point now that I bring when I see “magic numbers” in code. (examples are the layer console IDs, the z_order, etc. I’ve been playing a bit with trying to find good ways toggle them names in my version)

herbert

herbert

Author of Hands-on Rust

Thanks again! There’s a Big Sur update in the works for bracket-lib. I’m waiting on a couple of M1 chip fixes to come downstream, but the warnings are fixed. Adding a gutter is in-progress, requires a surprising amount of testing.

I’ll check the multiplier. I’ve added the issue to the tracker, and it should be in beta 3.

Popular Prag Prog topics Top

jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
New
kuroneko
Whilst the author has been careful to provide exact results for the tests elsewhere in the book (such as surds with the transformation te...
New
brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
New
sdmoralesma
Title: Web Development with Clojure, Third Edition - migrations/create not working: p159 When I execute the command: user=> (create-...
New
herminiotorres
Hi @Margaret , On page VII the book tells us the example and snippets will be all using Elixir version 1.11 But on page 3 almost the en...
New
raul
Hi Travis! Thank you for the cool book! :slight_smile: I made a list of issues and thought I could post them chapter by chapter. I’m rev...
New
oaklandgit
Hi, I completed chapter 6 but am getting the following error when running: thread 'main' panicked at 'Failed to load texture: IoError(O...
New
s2k
Hi all, currently I wonder how the Tailwind colours work (or don’t work). For example, in app/views/layouts/application.html.erb I have...
New
tkhobbes
After some hassle, I was able to finally run bin/setup, now I have started the rails server but I get this error message right when I vis...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New

Other popular topics Top

dasdom
No chair. I have a standing desk. This post was split into a dedicated thread from our thread about chairs :slight_smile:
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
New
OvermindDL1
Woooooooo! This is such a huge release for it, and 2 years incoming! In short, the library is now using an updated hyper backend (not j...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
PragmaticBookshelf
Author Spotlight Erin Dees @undees Welcome to our new author spotlight! We had the pleasure of chatting with Erin Dees, co-author of ...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New
First poster: bot
zig/http.zig at 7cf2cbb33ef34c1d211135f56d30fe23b6cacd42 · ziglang/zig. General-purpose programming language and toolchain for maintaini...
New

Latest in PragProg

View all threads ❯