I have a few questions after I have saw the newest versions of browser games like travian(version 5) and tribal wars(version 2).
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?
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?
Is loading throw websocket good solution?
Any good tutorial about map generating/map loading throw websockets?
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?
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)