Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

text browser game

Name: Anonymous 2010-05-08 13:41

I'm pretty noobish at web coding / webdev.  I'm trying to figure out how I could write a browser game using only JavaScript on the client-side (ie. no browser plug-ins).  But I'm stuck on figuring out how to handle everything server-side.

The only thing I've thought of is to store everything in a SQL database, and just have the AJAX post some information to a PHP file that will take care of everything.  However, I'm wondering if there are other, better ways of doing this that I can't think of.  I'm also not sure about handling concurrent players because I haven't done very much with databases before, so I'm not sure whether I'll have to worry about race conditions or something.

Any ideas or advice would be appreciated.

Name: Anonymous 2010-05-08 13:55

It's not much different than any other kind of client-server game, so just define the requests, write the client, write the server which maintains the internal world state, maybe persist it somehow (you mention MySQL, but any kind of persistence can be used). The server-side language can be anything as well, why choose PHP?

Name: Anonymous 2010-05-08 14:01

>>2
big libraries

Name: Anonymous 2010-05-08 14:03

>>3
In PHP? You lie.

Name: Anonymous 2010-05-08 14:05

Have you played Xarn's game? http://muffins.rotahall.org/

Insisting on doing everything on a single page with AJAX is probably misguided. It depends on the kind of game, though.

Name: Anonymous 2010-05-08 14:16

SQL [...] AJAX [...] PHP
You do not need any of those things. Data can be stored in any format, not just in an SQL database; AJAX is not necessary if you do things correctly; any scripting language can be used (not just a bastardised macro language). Consider a javascript platform game:

- The entire thing could be one (let's say Perl) script that generates the page, including (dynamically) all <script ... /> tags necessary
- Global / engine code can be kept in static .js files.
- Level data can be kept in plain text files, or however you need. They could perhaps be parsed to generate javascript containing global variables, like tiledata
- Per-user persistent data can be kept in the same way, and accessed with GET parameters or something.
- Levels are specified in GET also.
- On completion of a level, a simple hypertext link appears (through javascript) that simply links to "game.cgi?level=" + (level + 1)

It's not difficult to avoid using ENTERPRISE stuff like AJAX when you don't need to.

Name: OP 2010-05-08 15:44

>>6
- On completion of a level, a simple hypertext link appears (through javascript) that simply links to "game.cgi?level=" + (level + 1)

Not sure if I can explain this right. Essentially I want all of the game text (messages from the game, such as information about where you are, chat from other players, etc.) to appear in one edit box, streaming in real-time like IRC rather than just refreshing the page once every minute (like a shoutbox) or making the user click a link to go to the next page as you suggested.  Which is why I came up with AJAX, because I know I could do that with AJAX.  I don't know that I could do it any other way, but I'll take any suggestions.

>>2
The server-side language can be anything as well, why choose PHP?

Because I'm familiar with it.  Crappy reason, I know.  I should probably figure out a different language I could use for server-side scripting before I get into this.

Name: Anonymous 2010-05-08 15:55

If you already have a concrete thing in mind, maybe you should be describing that first instead of having us read your mind.

Name: Anonymous 2010-05-08 15:58

>>8
He did.  See >>1.

Name: Anonymous 2010-05-08 16:01

Render the game view in the server, use websockets to fecth it and draw it to a <canvas> element.

Name: Anonymous 2010-05-08 16:08

>>7
make a textarea and then just set its .value property, with ECMA script.

Name: Xarn !MhMRSATORI!xGIX62dlJesBTK+ 2010-05-08 16:45

Anyone using my game to get ideas about how to write online games has no business being a programmer.

>>10
That last update wasn't me. There's a few other admins who like to confuse the players.

Name: Anonymous 2010-05-08 17:39

nyn sng my gm t gt ds bt hw t wrt nln gms hs n bsnss bng  prgrmmr.

>>10
Tht lst pdt wsn't m. Thr's  fw thr dmins wh lk t cnfs th plyrs.

Name: Anonymous 2010-05-08 17:43

>>7
Oh, I see.
If you want real-time, AJAX still won't do that (you will have to poll at intervals); if you want true-ish realtime, look into server push stuff, especially the Web Sockets API which will be part of HTML5.
Input will be trivial, perhaps an input box that submits to a script that returns 204 or with an onSubmit that does some shit or something.

Name: Anonymous 2010-05-08 17:50

>>13
You forgot ``dmins''.

Name: Anonymous 2010-05-08 17:51

>>14
AJAX still won't do that (you will have to poll at intervals)
Yes it will, and no you won't. This is the second time this week I see this fucking stupid misconception thrown around in /prog/.

Name: Anonymous 2010-05-08 18:06

>>16
Yes it will, and no you won't.

Then please explain

Name: Anonymous 2010-05-08 18:11

>>13
Are you saying people who advocate Eclipse don't deserve to be disemvoweled?

Name: Anonymous 2010-05-08 18:32

>>16
Oh no, somebody gets angry at ``misconceptions'' of a piece of shit!

Name: Anonymous 2010-05-08 20:26

>>16
Idiot. Persistent connections don't fall under AJAX. Generally, the technique is called Comet. This is what Gmail uses.

Name: Anonymous 2010-05-08 20:57

>>20
Hello Leah!

Name: Anonymous 2010-05-08 21:35

>>20
Oh goddamnit.  I thought you were joking.

Name: Anonymous 2010-05-08 22:56

>>20
Crowdsourcing 2.0 - Giving fancy names to HTTP/HTML hacks/workarounds

Name: Anonymous 2010-05-09 6:42

Not your personal army.

Name: Anonymous 2010-05-09 7:11

>>16
You're saying that server-side persistence can be implemented on the client side?

Name: Anonymous 2010-05-09 7:19

>>25
PERSIST MY ANUS

Name: Anonymous 2010-05-09 11:21

>>25
What does that have to do with AJAX and polling?

Name: Anonymous 2010-05-09 12:16

>>27
Have you even paid attention?[1]


References
1. >>20,14

Name: Anonymous 2010-05-09 13:49

>>28
Yes I have, but >>25 still doesn't have anything to do with the content of >>16.

Name: Anonymous 2010-05-09 17:34

>>29
That's because >>16 ignores the context of the quote it contains.

Name: Anonymous 2010-05-09 19:04

someone from /jp/ made this:
http://www.kikya.com/danmaku/

Name: Anonymous 2010-05-09 22:05

>>30
You mean because >>16 is concerned with a particular fact independent of the surrounding context?

Name: Anonymous 2010-05-10 15:30

ivfivjnfdjv



flmbamfbamfdbfbfdb
b












bfbafbfa',bfa,'b,


















b';fb'pfb',gfbm,fb'





















b';pfd',b,b,f,b,fl,blf,b






























bfmb'mf'bm'flbam,bmf






















lb,';gtf,b't,f'b,'f,b,fda'b,a'f,bv,fbr





































#;gf,g'b,,b;b,f,bm,fbm

























mamfbgmlbvmfmblogtkmhbgltomb

































;lgfmb;lmfl;mb;gflbmgf;lbmfgb;gmb;gf;bmgf



























gmfblagmfrmgmmaglkmagmkmgkajmgakmgklaklgjkFNELKGFRKLMG;LKRGJM



















































































http://www.siteluck.com/en/digitalnasties.com

Name: Anonymous 2010-05-11 1:58

An intelligent OP, and useless but non-trolling replies. This thread is like bizarro /prog/.

I'm also not sure about handling concurrent players because I haven't done very much with databases before, so I'm not sure whether I'll have to worry about race conditions or something.
Ignore the folks saying to use alternative data stores. You do want SQL because you will want ACID compliance. You can handle concurrent connections through simple transactions and table locking.

If your game gets so popular that you need to migrate away from SQL, then congratulations, you're Facebook; sell it for a hundred million bucks and let someone else deal with it.

Also ignore the folks who say you don't need AJAX. You want real-time Javascript gameplay, not page reloads.

In fact, just ignore everyone here. We're all idiots. It sounds like you already know what you want, so go do it.

Name: Anonymous 2010-05-11 2:34

>>34
This thread is like bizarro /prog/.
bizarro

http://www.youtube.com/watch?v=JvW-ZGNjBYc

Name: Anonymous 2010-11-25 11:44

Name: Anonymous 2010-12-17 1:30

Xarn is a bad boyfriend

Don't change these.
Name: Email:
Entire Thread Thread List