AJAX Gaming Server?

Status
Not open for further replies.

Sup3rkirby

New Member
Messages
181
Reaction score
0
Points
0
First, please make sure you know about AJAX and probably a bit about PHP before you attempt to help me.


Ok. So while I don't exactly have the time right now, I will have some time later to work on some new ideas and scripts. Of course one of these is a mode of game play(for a game I'm developing) and I would like to integrate a system that lets you play with other users asynchronously(hints: AJAX). Of course I am no guru or even that good with flash and most games I've seen that let you actively interact with users in more than one place have been done in flash.

So for anyone who really knows about AJAX and PHP, would something like this work well in AJAX? I am just curious about the game being able to run smoothly. There wouldn't be heavy graphics and fast action. I am just not sure how fast AJAX can send and recieve to a PHP script on a server to work as a game server.

If you need a bit more of an explaination, lets say the game simply has little avatar like characters that are moved with mouse clicks(well, hold down the left mouse to move and the avatar follows the mouse). You have a small map(640x480) and you want to run maybe 5 players on that screen. Now how well would AJAX be able to send and recieve data with these 5 clients if it was sending to a PHP file that saved variables(character positions, character stats, etc.) and then sent back out all the information to each client? I wouldn't mind something like a slight delay for other users in the game with you. Such as the other 4 players on your screen might lag 1-2 seconds, but this game does use action so it doesn't matter if they lag a bit.


Just curious about this all. I've done an AJAX chat(W.I.P.) and have managed to be able to send and receive data with quite a few clients. My chat system could probably hold 50 or more and there is only a delay because the chat refresh timer is set to 2 or 3 seconds. So I would assume AJAX could handle well. But for a game I would like to set a timeout for about 100-500 ms.
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
I'd use flash for that then, for realtime gaming (as well as extensive graphics), AJAX wouldn't be your best handler.


If you intend your character to walk, you'd have to use sprites to simulate the motion.

While its doable, why give yourself a hard time when flash can do the job equally well (if not better)
 

nightscream

New Member
Messages
948
Reaction score
0
Points
0
I don't know much about ajax but Slothie is right, you have to use sprites and in flash it would look better and it would be smoother to play!
 

Sup3rkirby

New Member
Messages
181
Reaction score
0
Points
0
Ehhh... but the problem is, I'd have to learn flash(actionscript) and well, I'm not one to have much time right now. I already know a pretty good bit about AJAX to be able to slap together a server script, then of course tweak it to fix bugs and such.

As for walking animations, I have had quite a few ideas just using things like html and either simple js, or using js to completely automate the animation. Some would say it is more work, but I am somewhat of a js expert and I find it easy to code things like that. but one of my ideas actually would only use a small portion of js and should work just as well as flash.

I will have to set up some basic trial code and try to run two clients on the ajax server to see how well ajax can actually handle active clients and data.

I'll post back here after some testing.
 

Micro

Retired staff <i> (11-12-2008)</I>
Messages
1,301
Reaction score
0
Points
36
Really and truly you need a separate server if you want a 100ms->500ms refresh time, even then you would need to "interpolate".

A better idea is a 3d game/2d game with XNA (Windows), and use a PHP server side, with lots of client interpolation.
 

Sup3rkirby

New Member
Messages
181
Reaction score
0
Points
0
Ok. let me start over.

I have a TEXT-BASED browser game. I am looking to soon integrate a system to allow users to interact with other players of the game.

The only graphics used will be for a simple movement system. You see, text-based games do not appeal to everyone. They do have all the essential elements needed for a good game, but without the real-time interaction of graphics, a lot of people will not play.

So to solve this I am developing a 2d graphics system. So if you want to go here in the game to do this(take your band to the studio to work), you walk your little avatar to the area that is the studio. It will give people a better feel for the game and should make it more enjoyable.

There will be no live action/interaction. It is more showing two seperate avatars on the screen at the same time, and when one avatar(on your pc) decides to move to point B, it will show up for me on my pc. It doesn't need to be instant and can lag a bit. The game engine is text-based so if you know about the subject then you will know that there is no user interaction needed for essential game actions.

Long story short, this is soley a browser game that isn't heavy on graphics. The graphics are a compliment to the true engine and gameplay. I simply wanted to connect users through some server scripting, and wanted to know how well ajax could handle such things. I wasn't really looking for a replacement.

And Micro, for a 100-500ms response time I doubt I need a new server or anything. How much do you know about JS or AJAX? I can set a timer in JS that can run every 1 ms if I wanted to. And I have successfully run a timer every 1 second(1000ms) for a chat server solely written in AJAX and PHP. I'm pretty sure if I set the timeout to 100-500 then it would probably be a matter of bandwidth with all the constant server communication.
 

Slothie

New Member
Messages
1,429
Reaction score
0
Points
0
As well as resource usage depending on the amount of users you have.
 

Micro

Retired staff <i> (11-12-2008)</I>
Messages
1,301
Reaction score
0
Points
36
Ok. let me start over.

I have a TEXT-BASED browser game. I am looking to soon integrate a system to allow users to interact with other players of the game.

The only graphics used will be for a simple movement system. You see, text-based games do not appeal to everyone. They do have all the essential elements needed for a good game, but without the real-time interaction of graphics, a lot of people will not play.

So to solve this I am developing a 2d graphics system. So if you want to go here in the game to do this(take your band to the studio to work), you walk your little avatar to the area that is the studio. It will give people a better feel for the game and should make it more enjoyable.

There will be no live action/interaction. It is more showing two seperate avatars on the screen at the same time, and when one avatar(on your pc) decides to move to point B, it will show up for me on my pc. It doesn't need to be instant and can lag a bit. The game engine is text-based so if you know about the subject then you will know that there is no user interaction needed for essential game actions.

Long story short, this is soley a browser game that isn't heavy on graphics. The graphics are a compliment to the true engine and gameplay. I simply wanted to connect users through some server scripting, and wanted to know how well ajax could handle such things. I wasn't really looking for a replacement.

And Micro, for a 100-500ms response time I doubt I need a new server or anything. How much do you know about JS or AJAX? I can set a timer in JS that can run every 1 ms if I wanted to. And I have successfully run a timer every 1 second(1000ms) for a chat server solely written in AJAX and PHP. I'm pretty sure if I set the timeout to 100-500 then it would probably be a matter of bandwidth with all the constant server communication.

I'm more with the 3d FPS games area, but i know my stuff.

at a 500ms refresh time, it might not be so bad. but 100ms

10 conns a second * clients = 20 -> 100 connections to the x10 servers a second.
 

Twinkie

Banned
Messages
1,389
Reaction score
12
Points
0
Honestly, it would not run smoothly and it would be twice as difficult to make. You should use Java or flash. When you use ajax the delay is about 2 seconds just for a simple poll, it helps to use something that is more gaming friendly.
 

mitamata

New Member
Messages
81
Reaction score
0
Points
0
I would advise against this, unless you find a really good server to host this on and expect only people with good computers to play the game. I've did quite some work with Ajax, we've designed an application that uses GoogleMaps + Ajax to display the position of cars on a map. It refreshes the car positions once every 5 seconds and the browsers on some computers don't like it, at least not for long. As for the delays, it depends on the query and server. With a good server, Ajax can show results instantly, without a problem. It just depends on what you're having it do.
Anyway, in theory, it should work and it's not too hard to implement, so you could give it a try if you really like the idea. Good luck :)
 

Sup3rkirby

New Member
Messages
181
Reaction score
0
Points
0
Ok, everyone once more keep in mind there is very very little data being transfered. In fact, with my method there isn't really data being transfered. Actually ajax will save client information then basically sync its data with the server.

Twinkie, to most people it would seem to be easier to use a different method, but I beg to differ. It depends on the person and with me being the person ajax is 10 times easier than having to learn and work with flash or java.

Micro, I'm not using the x10 servers. My servers are pretty good actually. They aren't as busy as the x10 servers and probably will never have as many active connections simply because those servers are no longer open to new clients. So basically I am on a professional server that is only serving a small handful of clients.

My point is that with my coding and methods I'll only be sending small bits of text to the server, and the clients simply sync(refresh/update) with the server on a timer. the only data I need is positioning, which will be two numbers per client. So at the most two 4 digit numbers per client, and with 20 clients that is 160 bytes of data that needs to be received. It would only be 8 bytes being sent per client. No need to send out data on other clients. So 8 bytes being saved to a file and with 20 active clients that is 160 bytes of data being received. I believe an online conference or chat room actually would be more stressful on a server and require more resources...
 

kajasweb

New Member
Messages
1,723
Reaction score
0
Points
0
I don't think AJAX can be tailored for Gaming. Go for Flash, it has better interactivity & graphics.
 

Sup3rkirby

New Member
Messages
181
Reaction score
0
Points
0
Kajasweb, did you actually read any of the topic, or just the title? I do not intend to run the game itself on AJAX. This is a javascript game and is going to stay that way. But because I am using javascript, AJAX can easily be inserted to allow me to connect to some PHP coding that can save and load server files to allow multiple users to 'interact'. Of course in this particular game the interaction is more or less just seeing other players on your screen. You only need their position, which would be two numbers(x and y). Other than that the only data I might transfer would be chat data because I would like to allow the players to talk.

PLEASE READ THIS NOTE:
I'm sure everyone who knows about internet gaming knows what a text-based browser RPG is. And so as far as I've ever seen in my life, all text-based browser games are usually done with PHP. Well thanks to AJAX javascript can now communicate with PHP and never have to load more than one page. So this is my aim. Run a text-based browser game with AJAX so there is no page loading like if I were to use only PHP.

But what about these graphics he was talking about?! Yes, there will be graphics, but nothing that javascript can't handle with ease. The only graphics I will be using are backgrounds and buttons to play the game(just like most text-based browser games), and to spice up my game I am adding a 'movement' system. It shows a little 2D avatar which is your character, you click here, you move to that spot. An easy javascript that I have already written and works in IE, Firefox, Opera, AOL and Netscape. The graphics are simple and each client has then built in, so you are not loading anything but two numbers per client. There is hardly an data 'transfered' and it is all done behind the scenes with PHP, but I will use AJAX as the 'door' that will connect the two ends.
 

kajasweb

New Member
Messages
1,723
Reaction score
0
Points
0
Kajasweb, did you actually read any of the topic, or just the title?....

Don't get me wrong. I don't reply to any topic without reading the Thread Starter's post.

Anyhow.. I thought that AJAX is not fit to handle these type of traffic to server. I agree that AJAX makes it easier to update part(s) of page without full page reloads, but communicating to get the position of players and sending the Chat Data to server through AJAX may not be as good as you get with Flash.

By the word "Asynchronous" in AJAX it means that it can't be working in Sync with other request/responses. This makes AJAX to be ruled out for this type of application.

If I have said something wrong, please correct me. I like to learn more...
 
Last edited:

epoclaen

Member
Messages
79
Reaction score
0
Points
6
With all due respect, it sounds like you've pretty much sold yourself on the idea that AJAX will work and given that you have little time to learn anything else, it's best just to give it a whirl and see how it goes. ;) It seems that you've gotten recommendations from others about the timeout of 100-500 ms. If you know of other text-based RPGs that use PHP on the backend then it might be worth emailing the administrators for some input. Personally, I'd be interested in checking out some of the games you had in mind.

FYI, the text-based RPG I work for doesn't include graphics within the game window per say or javascript or PHP but it uses C++ on the backend in an asynchronous environment. It expects players to use a downloadable Wizard interface rather than a browser but we do allow the use of a browser interface dubbed as "eScape" in an XML-based front-end interface. With thousands of users online at a time, the transfer of data from the players, processing of the data and return of the response to a player's actions takes far less than 100ms but then again we're not updating the page via a timeout. I'm wondering if your game would respond equally as well. Just bear in mind that we use our own dedicated servers for our games.

You can check out the eScape interface if you want at www.play.net and signing up for a free 30-day trial with any of the Simutronics games. You do need a credit card for the trial but the last I checked, we don't automatically start billing you when the trial is up although it's always possible that our home office might have changed this in recent years. It may be either worth a look-see for yourself or as a game of reference for you to help explain to others what your intent is.

Good luck and let us know when it goes online!
 
Status
Not open for further replies.
Top