Previously, I wrote an article I played with DragonRuby GTK (Game Toolkit).
I get tired of posting Hello, World on Qiita (!), But this time I'm still touching it.
Suddenly, I wanted to make a typing game, so I made a simple one for the practice.
The text will be displayed and you just need to enter it. There is no time over, that's it.
You can play with your web browser from this link. https://tnantoka.github.io/typing-on-rails/
The source code is on GitHub. https://github.com/tnantoka/typing-on-rails
I borrowed the text to type from the sample code in Rails Guides (https://guides.rubyonrails.org/), so it's named ** Typing on Rails **.
Basically, I can make it with the contents of I played with DragonRuby GTK (Game Toolkit). Some of them were not written, so make a note of them.
You can change it by setting
[R, G, B] to ʻoutputs.background_color`.
#Red! !! !! outputs.background_color = [255, 0, 0]
I can get the input status with ʻinputs.keyboard.key_up.space` that I used last time. This time I tried to implement it by looking at the list of keys.
You can get the entered keys with ʻinputs.keyboard.key_down.truthy_keys`.
#Enter a [:char, :raw_key, :a] # A（Shift +a) Enter [:char, :raw_key, :a, :shift] # Command + Shift +Enter a [:char, :raw_key, :a, :shift, :meta]
You can specify
Label, but even if you specify the same
10, the size will be quite different depending on the font.
For example, if you arrange the following four fonts side by side ...
It will be like this.
It seems that you need to adjust
size_enum depending on the font you use.
When I published the packaged build on GitHub pages, it didn't work.
The cause is
Server reported failure downloading 'app/.main.rb.swp'!
Was the error.
Git will be ignored by
.gitignore, but of course DragonRuby will not ignore it ...
If you look at
builds / typing-on-rails-html5-0.1 / manifest.json, you may notice that it contains unnecessary files.
.swp file this time was also included)
I made it in less than 200 lines. (Although I haven't counted the amount of Primitives.rb I made last time) It's easy.