macroquad
macroquad copied to clipboard
Arkanoid example glitched text
I just ran the Arkanoid example and saw that the "Press space to start" text wasn't working:
I have narrowed down the cause to be somewhere between 0.3.0-alpha.2 and 0.3.0-alpha.4:
- 0.3.0-alpha.2: the example displays the text correctly
- 0.3.0-alpha.3: the text is completely gone
- 0.3.0-alpha.4 onward: the example looks like the above image
I compiled using rustc 1.49.0 on a Windows 10 laptop with an Intel UHD 620.
I see the same problem almost exactly a year later. I'm running Linux using macroquad 0.3. I think it might be because the text is rendered at font size 1 which makes sense for the size of the canvas (20.0x20.0), but the camera zoom is set to 1/40, 1/40 which makes 1 unit on the canvas really big (depending on window size).
Ah, fixed it by using draw_font_ex
with params which address scaling. First, create a TextParams
:
let (font_size, font_scale, font_aspect) = camera_font_scale(1.);
let text_params = TextParams {
font_size,
font_scale,
font_scale_aspect: font_aspect,
..Default::default()
};
Then draw text with these TextParams
:
draw_text_ex(
"Press space to start",
SCR_W / 2. - 5.,
SCR_H / 2.,
text_params
);
Someone could make a PR with these changes!