Advertisement

Browser game map best practices + node.js

Started by November 10, 2014 09:07 PM
3 comments, last by fant0m 10 years ago

Hello,

I have a few questions after I have saw the newest versions of browser games like travian(version 5) and tribal wars(version 2).

  1. What are the best practices for generating game for browser game? (draw some big image and then cut it into tiles and save it into db? Or just have some map objects and generate them randomly on map? or something else?
  2. Second thing is map loading. On those 2 games I saw they are loading map tiles throw websockets(probably using node.js?) How to do that? Is it loading throw javascript? I just have no idea about that.. Server side would be still php or?
  3. Is loading throw websocket good solution?
  4. Any good tutorial about map generating/map loading throw websockets?

Thanks.

PHP doesn't typically support websockets, because websockets are typically persistent connections, and PHP typically servers short-lived requests. A very popular server for websockets is node.js (often with socket.io on top,) others include Erlang based systems (using sockjs-erlang or n2o.)

You can load your map any way you want. Download a file through HTTP. Send coordinates for each tile through web sockets. Hard-code the maps in the HTML you send when the user loads the game. Whatever works for you, works.

Have you written a regular game at all yet? If so, how do you generate and load a map for that game?
enum Bool { True, False, FileNotFound };
Advertisement

PHP doesn't typically support websockets, because websockets are typically persistent connections, and PHP typically servers short-lived requests. A very popular server for websockets is node.js (often with socket.io on top,) others include Erlang based systems (using sockjs-erlang or n2o.)

You can load your map any way you want. Download a file through HTTP. Send coordinates for each tile through web sockets. Hard-code the maps in the HTML you send when the user loads the game. Whatever works for you, works.

Have you written a regular game at all yet? If so, how do you generate and load a map for that game?

So actually if I want to use node.js for map loading I am not working with php?

And yes I did. Map was consisting just from "single" elements (e.g. wood was just 1 tile - 64x64 so one element wasn't consisting of more elements like I want it now) and they were randomly placed into array. Then I just saved it into mysql database. Loading was made through the ajax(when a user moved map it loaded some more tiles that was needed)


So actually if I want to use node.js for map loading I am not working with php?

It depends whether you still use PHP. You could only use NodeJS for the real-time stuff and PHP for everything else...

By the way, shouldn't you look up the word "throw" in a dictionary?


So actually if I want to use node.js for map loading I am not working with php?

It depends whether you still use PHP. You could only use NodeJS for the real-time stuff and PHP for everything else...

By the way, shouldn't you look up the word "throw" in a dictionary?

Actually real-time stuff is not necessary in map. I think those 2 browser games have it just because of the speed.

And sorry, of course I wanted to write through :)

This topic is closed to new replies.

Advertisement