Computer Science Canada [Tutorial] Online HighScore Module |
Author: | ecliptical [ Mon Jan 02, 2006 10:18 pm ] | ||||||||||||
Post subject: | [Tutorial] Online HighScore Module | ||||||||||||
Before we start coding you need to ask yourself if it would be better to use just local storage for scores if thats the case then follow this tutorial by hacker dan http://www.compsci.ca/v2/viewtopic.php?t=5340 Otherwise lets get started. Ok first things first lets plan out how this is going to work Step 1. Make a fun game. (This is hard) Step 2. Make it challenging enough that the player dies (easier then step 1) Step 3. Send his score, name and e-mail to the server (all encrypted). Step 4. Make the server save,handle, sort and then send the results back to Turing. Step 5. Check to see how many people are playing your game (or at least how many sent their highscores). What you'll need for this to work: -PHP 4x on any server -Domain Name/WebSpace (or possibly some free hosting subdomain service haven't tried it) -Turing 4.04d -A Game (The game i've included if it isn't obvious is a pseudo code compacted game") The Game: This is just an example of how this works.
So it's pretty simply so far, once the player dies we send his/her info to the server. Not My Job: Create the required code to check when the player has died and store the playerID and finalScore in a variable.
What do we have? We've created a module that opens a connection to URL and reads the file of that URL but doesn't display anything yet. Net.OpenURLConnection: This is pretty much the same as opening a file, except that we're reading a file located remotely on a server somewhere instead of on our computer. Ok now lets make it actually do something!
So all we added is the location of the file on our server that will handle our highscore as well as the code that will output our results (the player's score with other peoples scores) back to turing. Now for where the real magic happens ONLINE! Ok so in your code editor of choice (NotePad++ if you're cool) create the following simple php script.
Upload the file to your server and name it highScoreHandler.php Ok so we lied to the played we haven't actually added his score to the server but this will let us know if our code works so far.
Ohh and the usage of course is
There I guess that wasn't so hard we've actually added the players score to our database (just a normal text file) and included that file so his result will be displayed. Turing seems to like properly formated HTML pages so the next part of this tutorial will include how to strip out that html and sort the results. Also the next part of the tutorial will include how you encrypt the code. Because as if you are distributing your game with the source then someone could just easily send whatever score they wanted to your highScoreHandler.php Currently my server just upped its security so I wasn't able to test this code but a couple of weeks ago before the upgrade it worked fine so I"m going to assume it's still working however while rewriting it I may have messed some stuff up let me know if anything looks out of place or if you have any questions in general. Future gameServer Tutorials gameServer.GetMove gameServer.SendMove gameServer.BanUser gameServer.Login gameServer.Logout gameServer.GameUpdate :Does the player have the latest build of your game? If not download an update. -this isn't working totally yet. gameServer.getHighScore That's pretty much all I've worked on but development has been put off until my server stuff is resolved. Anyway this works pretty great for Turn based games...and with some AJAX hotsause you might even get some decent proformance for real time games...but thats a whole other Tutorial enjoy. |
Author: | ecliptical [ Mon Jan 02, 2006 10:32 pm ] |
Post subject: | |
scratch that I just remembed AJAX includes javascript (duh!) which is executed on the client and in this case the client is Turing which does NOT have a javascript engine. So realistically the only "real" time game would be one where part of the game play has a time limit so you can send moves back and forth without lag. |
Author: | Taur [ Wed Jan 04, 2006 7:02 pm ] |
Post subject: | |
okay but I got a bit confused with the web part. Where do we put the "usage" could you just attach the files we have to upload to our server? and what if we want to send a string, is that aldready converted to a string and we're not sending an interger variable? |
Author: | ecliptical [ Thu Jan 05, 2006 12:11 pm ] |
Post subject: | |
opps I had the in an earlier version that caugh int's must of got lost in the rewrite - anyway once my issues with my server are resolved I'll post all of the gameServer modules |
Author: | Taur [ Thu Jan 05, 2006 9:07 pm ] |
Post subject: | |
k thx |
Author: | ecliptical [ Thu Jan 05, 2006 9:20 pm ] |
Post subject: | |
Taur do you have a host that runs php scripts? |
Author: | Taur [ Fri Jan 06, 2006 9:20 am ] |
Post subject: | |
I think so, try www.freewebs.com |
Author: | unknowngiver [ Fri May 12, 2006 10:28 am ] |
Post subject: | |
hey now since you can submit stuff from turing to php...can you make a Program that sends stuff from turing to PHP which inputs it to a database...and then when user wants to recieve the information thats in the database..the program runs another php script which gets the stuff from the database and puts it on the turing screen? can i do something like that in another way? i really need this! thanks |