Simple multiplayer game in Ruby on Rails?

I created a simple card game in Ruby on Rails + ajax with jQuery for animation. It works Well, and I wanted to develop a multi-user version. It doesn't seem as easy as I thought. I also tried to completely transfer the game in JS to the Canvas tag. This is possible for me, and I could make the animation there much better, but I still don’t know how to add the multi-user part to it :( Has anyone tried to use websockets with rails already? This is a rather bizarre new technology. Is it worth sticking to rails? I would like to start from scratch in a flash, but I have no knowledge in this :( Any advice or tutorial would be helpful

thanks

+6
jquery ajax flash ruby-on-rails canvas
source share
2 answers

If you end using websites:

Web descriptors can be implemented using Rails, but not all hosting environments support it. Here are some links to help you get started:

http://m.onkey.org/websockets-made-easy-with-cramp ( Thin or Rainbows required ! )

http://www.pusherapp.com/ (if you use Heroku, this is a good option)

For the client side, some javascript plugins have a flash backup if the browser does not support web sites. Instead of implementing the whole game in flash memory, you might be better off using such a plugin. (Your server will still need websocket support.) Here is one option (jQuery is required):

https://github.com/ffdead/jquery-graceful-websocket

As you stated, websockets are very new and will be quite experimental as a result. If all else fails, there are more common AJAX solutions. It is possible that for a simple card game, you can simply periodically request a server using AJAX requests until the other player makes a move. This is likely to increase the load on the server, so I think it depends on your needs.

Edit:

See also: Juggernaut

+2
source share

What is the simplest thing you can solve to solve a user problem? In this case, probably, "I want to be notified when the person I play with makes a move." In real time, this is not a requirement, only for a second or two, the user is notified.

In this case, it would be easier to keep your Rails application as it is and use Jquery to “poll” for new “moves” every few seconds using jQuery and a plugin like http://plugins.jquery.com/project / smartupdater

I'm talking about this as someone who is currently creating an application that uses Websockets mostly. Although this is great in principle, we will create a version of Flash as a backup for browsers that do not support it.

+2
source share

All Articles