macroquad icon indicating copy to clipboard operation
macroquad copied to clipboard

Arkanoid example glitched text

Open brianwp3000 opened this issue 4 years ago • 2 comments

I just ran the Arkanoid example and saw that the "Press space to start" text wasn't working:

image

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.

brianwp3000 avatar Jan 14 '21 06:01 brianwp3000

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).

freiguy1 avatar Jan 13 '22 13:01 freiguy1

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!

freiguy1 avatar Jan 13 '22 13:01 freiguy1