Hey
Im about to start working on an online RPG with a team mate. But we been constantly using for and against arguements on the best efficient method for our isometric maps in browsers.
We are going for a canvas approach with characters walking in pixel measurements so we are aiming to use a solid single image instead of tiles.
Our ideas are :
Using a map maker we create the tiles export that as one image - compress the image, then that image would be the first layer in the array oh the isometric terrain.
OR
Using tiles repeated using multi dimensional arrays (yes reduces server load but means we have to call the database for which tiles goes where).
Naturally we want to reduce the amount of calls to the database to keep the server free from work load as much as possible.
We would also like to see people's view on how we set which tiles are hit dectectors (to stop users walking on the tiles) we thought using boolean in the database, but again alot of work to call and check tons of tiles. But the single image would reduce it because we use an array and just check the array when a tile on the "single image" appears. So its not 24/7.
We then also considered storing it all in text files so none of it involves the database, but we wanted to know if this could be exploited (aka the text files being edited by users if they know their location).
Theres so many ways to approach but knowing which one wins on allowing the most flexibility whilst reducing the server load is not so easy to pick.
Without a doubt we will be using long polling server push ajax to keep connections to a minimum.
Any one got some input for us to help us on which direction we should take ?
Lowering Sever Workload...
Using tiles repeated using multi dimensional arrays (yes reduces server load but means we have to call the database for which tiles goes where).
Sounds sane. Depending on the size of your maps and if there is a z level a simple database with:
id, x, y, landtype
where x and y are coordinates and landtype is the type of isometric tiles at that location. A simple SQL query for the tiles around the players camera could be sent. (If you need help writing it I can find some articles).
To get the tiles you could just return say a json object from your server-side language with the tile information. Then have javascript download the necessary tiles it needs and render them to a canvas object as a cached image. (This would allow you to use putImageData and easily scroll around the map.
Also this method isn't going to strain your server. The SQL query is trivial and the query itself won't be happening very often. (Assuming you send the player the isometric tiles a certain distance around their camera it would take them a while to walk to a place without tiles and then request them).
We would also like to see people's view on how we set which tiles are hit dectectors (to stop users walking on the tiles) we thought using boolean in the database, but again alot of work to call and check tons of tiles. But the single image would reduce it because we use an array and just check the array when a tile on the "single image" appears. So its not 24/7.
In the top example you could define the collision with the landtype table or add a column for "collidable" or something. Pretty trivial.
Without a doubt we will be using long polling server push ajax to keep connections to a minimum.
I prefer WebSockets and would encourage you to make the switch if you have networking experience to create a socket server. It sounds like your movement is real-time since you said pixel based and not tile based. If you perform an ajax query more than once every five seconds it will hold the connection open anyway so you'll still have a continuous socket connection. Another point to be made is that those handshakes when the socket does disconnect can have a latency of 1-5 seconds.
Thanks for the replies, im not familiar with websockets - we are obviously trying to make it appear live so nothing refreshes - would websockets allow this ...were aiming for js/ajax for user interface.
Can tiles be used with a pixel movement like a full image map would? Otherwise wouldn't we be doing a tile to tile movement which lowers the fluidity of the movement of the player ?
Also aren't websockets turned on in FF and opera ? Which limits the user base?
Can tiles be used with a pixel movement like a full image map would? Otherwise wouldn't we be doing a tile to tile movement which lowers the fluidity of the movement of the player ?
Also aren't websockets turned on in FF and opera ? Which limits the user base?
Thanks for the replies, im not familiar with websockets - we are obviously trying to make it appear live so nothing refreshes - would websockets allow this ...were aiming for js/ajax for user interface.
Yes websockets allows that. It's a TCP socket. So you don't need to use long polling or anything. You just open the connection to your socket server and can communicate. You could keep some of the ajax stuff if you wanted or replace it all and have the socket server handle everything. You could go so far as to load the whole map on the socket server and leave the database alone except for synchronizing changes. Very high performance in that respect. This assumes you know network programming. It's not hard to learn, but to do things correctly topics like multithreading come into play with completion ports.
WebSockets
For the client side, WebSocket was to be implemented in Firefox 4, Google Chrome 4, Opera 11 and Safari 5, as well as the mobile version of Safari in iOS 4.2 <a href='"http://en.wikipedia.org/wiki/WebSockets#cite_note-0"'>[1]</a>. However, although present, support is now disabled by default in Firefox and Opera, due to concerns over security vulnerabilities
That was very recent that it was turned off. There was a minor protocol error with cookies or something. It will be fixed very soon. The only reason that IE9 doesn't have WebSockets is because IE didn't want to implement an incomplete standard (It lacks a binary protocol and other things still). Assume though that WebSockets works in all browsers except IE for now. When is your game getting released?
Can tiles be used with a pixel movement like a full image map would? Otherwise wouldn't we be doing a tile to tile movement which lowers the fluidity of the movement of the player ?
You can just render the tiles to create a the full image map on the client-side in javascript. Basically just render to an invisible large canvas then render that canvas' imagedata to your game's canvas with an offset.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement