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

telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
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
jdufour
Hello! On page xix of the preface, it says there is a community forum "… for help if your’re stuck on one of the exercises in this book… ...
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
adamwoolhether
I’m not quite sure what’s going on here, but I’m unable to have to containers successfully complete the Readiness/Liveness checks. I’m im...
New
Charles
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
New
jonmac
The allprojects block listed on page 245 produces the following error when syncing gradle: “org.gradle.api.GradleScriptException: A prob...
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
kolossal
Hi, I need some help, I’m new to rust and was learning through your book. but I got stuck at the last stage of distribution. Whenever I t...
New
EdBorn
Title: Agile Web Development with Rails 7: (page 70) I am running windows 11 pro with rails 7.0.3 and ruby 3.1.2p20 (2022-04-12 revision...
New

Other popular topics Top

PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
New
Exadra37
I am a Linux user since 2012, more or less, and I always use Ubuntu on my computers, and my last 2 laptops have been used Thinkpads, wher...
New
PragmaticBookshelf
“Finding the Boundaries” Hero’s Journey with Noel Rappin @noelrappin Even when you’re ultimately right about what the future ho...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
New
First poster: joeb
The File System Access API with Origin Private File System. WebKit supports new API that makes it possible for web apps to create, open,...
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
PragmaticBookshelf
A Ruby-Centric Chat with Noel Rappin @noelrappin Once you start noodling around with Ruby you quickly figure out, as Noel Rappi...
New

Latest in PragProg

View all threads ❯