I was encouraged back in March when I was able to port my tank control experiments from Flash to HTML5. I had previously attempted to port my spaceship control experiments from Flash to HTML5, but failed. Part of the problem was that it wasn't a strict port; I wanted to use a different algorithm. But it didn't work well.

After the tank control experiments I was excited to work on map generation again. I had high hopes and lots of ideas. I fell into a rabbit hole, fixing many bugs with the map boundary, and then after I got out of the rabbit hole … I had lost the desire to work on map features. Unfortunately this happens to me a lot.

So I've kind of been aimless since then. I decided to try the spaceship flyer again, but this time I wanted to try putting it into a game loop, so I made a little game. This led me to another distraction, learning about modern keyboard events. The keyboard events used to have some incompatibilities between browsers but they seem to be much better now. That gave me an idea: since browsers now provide both keycode and scancode, can I use that to "discover" the WASD equivalent on different keyboards? I tried that. It works, but I can get that data only after someone types a key. Would it be nice to get the layout without requiring typing? Well, Chrome has it but it turns out it can be used for "fingerprinting", which is used to track people on the web. So Firefox and Safari both said no, they don't want to add an API that would get used for fingerprinting. Brave blocked it even thought they use Chrome code underneath. But I think it'd be reasonable in the game setup/tutorial to ask someone to move around with WASD and then see what scancodes come up, and use that as the initial key bindings.

But … the keyboard stuff was all a distraction. I learned a bit, but I didn't make a lot of progress on the spaceship flyer. After I got out of the rabbit hole, I had lost the desire to work on that project.

Fortunately something came along. Every year, the Reddit r/roguelikedev community has an event to make a roguelike. This year I decided to make a colony simulator. I'm using some of the code from the spaceship & keyboard projects, so those didn't go to waste. I'm hoping the structure of the community project will help me stay motivated for the six weeks. But I don't plan to continue after that. I will look for another project.



Lukas wrote at September 03, 2023 11:36 PM

Isn't the point of scancodes that you can hard code the scancode values and it will work across layouts? That way, you wouldn't need to prompt the user.

Amit wrote at September 04, 2023 3:23 PM

Yes, you can hard code the scancode values, but you can't display the key code in the game UI or tutorials. That's what I was hoping to do.