At the end of the previse part, I told you I got some crazy idea of using esp. and html for a game – so apparently It was not that crazy – and it works.
using the VR valentine game by the IOT Makers Israel team I made adjustments to use the joystick https://dev.to/azure/how-to-build-a-webvr-game-with-a-frame-4ifg
The game is based on a-frame which is a JavaScript framework for VR and 3D powered by the three.js library. The game is served from an ESP8266 and there is a web socket open between the 2, and each change in the joystick is sent as a web socket message to the game. off course it all just didn’t happen in one go, there were steps. My first step was to set a web server sketch on the esp, that included events, which are a bit similar to socket, but short messages and only from the server to the page. The next step was to connect the joystick buttons, if you want to know how to buttons work, you can watch it all in the first episode
once the buttons where connected I added the small joystick to control the direction of the camera.
The next big thing, which took me the longest, was to figure out how to imitate the click of the mouse which in the original game is how you collect the hearts - so I can use the front trigger joy stick button instead.
I had to dig into the library itself and look how it was done in the courser section, and it’s all down to the canvas object with in the scene object.
As all of you probably know, the esp8266 has only one analog and this is why only the joystick Y-axis is working. On top of that, it seems that reading the analog slowed down the web service of the esp dramatically.
After I was done getting everything to work, the event service was not working well, and kept on disconnecting, and was replace with a web sockets. I still get some errors, but its way more stable this way.
My next big task will be to find the right analog multiplexer, I did ordered a few that were recommended to me. Hoping to get better results than when the esp is doing the analog read.
And I can always go with the known mcp3008.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.