Well im Making a PHP webgame with a map where players can walk on. but im very about overall performance of the game. it is a bit like this:
- The page to start saving resources i made a main page with an iframe to the map code and with a chat below like this:
(start page) (iframe with the map.php code) (include chat.php) (end page)
so with this i dont have to reload all the page and the chat stands still while we walk on the map.
- the map code: in the beginning it was very slow and buggy but i managed it to run very simple, like this: the maps are divided by areas, and each row stores a single tile of a 9x9 map. so my db looks like this:
id-map(this defines the area)-pos(this defines the position of the tile)-tile(img of the tile)-block(if tile is walkable or not)
so when i call to create map i ask to select all rows of map X, then the script create a table of 9 rows by 9 collumns and set the background of each cell with the specific tile image.
while that is script executes it also asks for the DB for any other players and objects in the map in the same way but showing them as img inside the cell, not as background.
to save calls for the db, i had the idea of: in each loop of the map creation it create a hidden input which name is the actual map position and value is the img so it stores in the browser and it is resent every time we walk so it calls for the map once we enter it.
for walking i made a big form and the arrows for walking being buttons, every time we walk the page sends a POST and depending for which direction play has walked, it updates the DB and generate the map again.
well thats it. im already using GZip compression. So my questions are:
1- Will the server overload if there is like 50 players walking at same time? 2- there is any tips, improvements or optimizations i should do to this map script? may a way to save DB calls and make it less overloading?
(i dont want to use ajax)