JS13K 2020 Game Jam Day 23
*Sigh* It happened again! Oh, well. Let's just see how much I can get done before the deadline. If I don't finish this one, I'll add it to the pile of games to finish: right next to Shield Bearer.
I've been brainstorming a bit on how I could do a menu. I feel like I should treat a menu like Levels themselves: the graphics will be drawn on the world, Ratio-Vision will capture that one section and render it, and all the inputs will be driven by a menu controller object. In fact, I've been brainstorming of a way to handle controls as well: I feel like there needs to be some sort of abstraction layer so I'm not checking the Unicode for each key, I just have to make sure that a player or controllable object implements certain actions from this controller object. I'll call this Master Controller! Yeah, it's not as original as Ratio-Vision, but I wanted a simple name that perfectly describes its functions.
I want Master Controller to be an object that is basically in charge of a big Hash Map of Keys to Actions. This way, it should be quick to respond and tell an object to perform a certain action. The last thing I want is to somehow create lag in my controls, but I want to enhance the way we assign buttons to actions. Plus, I'm hoping that this will allow me to build Cross-Platform titles as well: I can assign keyboard keys to certain actions, add joypad controllers that call those same actions, and create inputs on the screen that call the same actions on smartphones. Also, I can use Master Controller later to have the Player themselves reassign keys to certain actions. Here's my logic:
The Master Controller will maintain a Hash Map where the keyboard keys are indexes or keys to the actual Action value. After the Master Controller gets the Action value, it then calls the "do action" function of the current Controllable Object assigned to it. That way, we no longer have to think about how we should set the keys for the WHOLE GAME. Now we can just think about the actions that a Controllable Object needs to perform and then just assign different Controllable Objects to Master Controller depending on the "level" (since Main Menu will be a level and it will have a menu Controllable Object). I'll build a simple version in Whole Door and I'll expand it later in Daemon.
I managed to build out the base for Master Controller in Whole Door. It has the WASD keys, J, and K keys set to their own action numbers. I found out that JavaScript just allows you to create holes in it, so all I needed to do was set the action numbers for certain keys. I found this nice list of keycodes, which helped out a lot! I decided to split the doAction function into doKeyUp and doKeyDown so that the Controllable Object can implement doActionUp and doActionDown. I remember in Shield Bearer that I had to implement something similar so the character could start or stop moving depending on keyup or keydown. I don't have an object to assign to it yet, but you can see it working in the JavaScript console.
That was all I could do for tonight! You can go and play around with Whole Door or view the source for Whole Door. It should have my latest changes! Hopefully, I won't wait another nine days before working on this thing again!
Comments
Post a Comment