Arkanoid with a joystick on the phone

Recently, my colleagues reminded me of the wonderful MortalKombat game, which, well, is simply not possible to play without joysticks, and if it is possible, then there is no pleasure.

And I remembered the technology for controlling any screens from a mobile phone, which I described in a previous article . The goal in that article was achieved but the practical application of zero.

And without hesitation, a game was created that, according to my feelings, can be played if your network does not have wild brakes and proxies that cut down the connections of web sockets.



The game itself now lies on the main page of the library .

Actually, the entire code, as always, lies on the github .

All the main control code (of which you do not understand much) is concentrated in the js fileexample / js / main.js , everything that’s not related to control, but only refers to the game, is in the example / js / game.js file.

In short, using the remoteall library API, we simply receive signals from the joystick and transfer them to the game in the form changes in the status of global variables (the game is taken on the Internet, and the link is lost, so I can’t answer for the code and logic of the game)
The entire configuration code for this interaction fits in 30 lines
ra.on('recive_code', function (data, session_id) {
    if( (data.button_code=='LENTER' || data.button_code=='RENTER') && data.event_name =='button_down'){ //reset game
        restartGame()
        return
    }
    switch (data.event_name) {
        case 'button_down':
            switch (data.button_code) {
                case 'LEFT': // 'Left' key
                    bLeftBut = true;
                    break;
                case 'RIGHT': // 'Right' key
                    bRightBut = true;
                    break;
            }
            break;
        case 'button_up':
            switch (data.button_code) {
                case 'LEFT': // 'Left' key
                    bLeftBut = false;
                    break;
                case 'RIGHT': // 'Right' key
                    bRightBut = false;
                    break;
            }
            break;
    }
})


With this game, I would like to demonstrate that games with instant response can work in open networks based on the principles of this technology. Further, with the presence of enthusiasm and enthusiasts, I would like to fuck up a more interesting thing (for example, the same tanks)

And immediately there are questions for the habra-people:

  • In your opinion, is there any potential at all and can this technology be applied in real game / application development?
  • How else can you apply this kind of essence to a mobile-joystick with the condition that there is no feedback (there are no buttons felt with your fingers)?


Thank you all, have a nice weekend.

UDP:
The server should handle a bunch of requests and web sockets, but still the probability that node.js will fail about 5% :)

Also popular now: