Closed jamespeilunli closed 3 years ago
Should be good.
Not sure what's happening, I'm getting this shortly after the game over screen renders:
Error: (TTF_OpenFont) Couldn't open AzeretMono-Light.ttf
Traceback (most recent call last):
10: from tetris.rb:249:in `<main>'
9: from /Users/danielmiller/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/ruby2d-0.10.0/lib/ruby2d/dsl.rb:39:in `show'
8: from /Users/danielmiller/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/ruby2d-0.10.0/lib/ruby2d/window.rb:619:in `show'
7: from /Users/danielmiller/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/ruby2d-0.10.0/lib/ruby2d/window.rb:619:in `ext_show'
6: from /Users/danielmiller/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/ruby2d-0.10.0/lib/ruby2d/window.rb:563:in `update_callback'
5: from tetris.rb:198:in `block in <main>'
4: from tetris.rb:66:in `display_leaderboard'
3: from tetris.rb:66:in `each'
2: from tetris.rb:67:in `block in display_leaderboard'
1: from tetris.rb:67:in `new'
/Users/danielmiller/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/ruby2d-0.10.0/lib/ruby2d/text.rb:24:in `initialize': Text `DWM 200 1` cannot be created (Ruby2D::Error)
My only thought was the permissions on the actual font file weren't right, but they're ok. We might have to just try another font.
If you can, find a monospace (because then space characters wouldn't be the same width as other characters and my string formatting wouldn't work) font that you like and works for you. I found that Google Fonts is quite useful.
Ok I worked a little bit more on this tonight. I changed the font to a different one I downloaded from Google Fonts. At first I misspelled the file name and I got an error immediately when I tried to run the program. So it's looking for the font file immediately. But I still got the Error: (TTF_OpenFont) Couldn't open ShareTechMono-Regular.ttf
error when it attempted to write the leaderboard.
Then I changed the scoreboard font to that same font and it works fine. So it's something specific about the use of the font in the spot added in this PR.
It's probably something to do with how the Text object is used here:
leaderboard_text << Text.new
Hmm, maybe not, that's used on the landing screen leaderboard without issue.
closes #67 closes #69
By passing a formatted string with the leaderboard text to Text.new from Ruby2D, we can display the leaderboard on the start screen and game over screen. To avoid repetition, this code is put into the
display_leaderboard
method.