BASIC

Author Topic: Online Highscore example  (Read 3166 times)

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1779
    • View Profile
    • Homepage
Online Highscore example
« on: 2008-Oct-27 »
I made a simple online highscore example that uses PHP, MySQL and GLBasic ofcourse :-) It calls a homepage with the path "http://your.homepage.com/index.php/listgame/highscore/game_name/playername/score/64byte_hash"

The PHP side needs an installation of CodeIgniter to work. http://codeigniter.com/

The 64byte_hash is created from all the other data so if those don't add up when the server gets it all, it won't be added. This should be resonably safe until someone REALY wants to hack your highscore table :-)

To get the list of highscores just call the same routine (Highscores) with an empty name and score and you will download an ini-file that the scores will be loaded from and shown to you.

You can find the code on my homepage under "CODE". Ofcourse you have to change the password in the file, you can find it if you search for "secret code" in both the PHP file "listgame.php" and the GLBasic file "SpaceInvaders.gbas"

Good luck!

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: Online Highscore example
« Reply #1 on: 2008-Oct-28 »
Curious...

Why not just send the highscore through the game itself, to a game server via the GLBasic networking commands? Ie: Make the game server record scores into its own datafile, which is in a website port 80 directory, as an HTML. GLBasic is pretty powerful combined with just a webhost, it can even be setup to write a php data instead of building HTML.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1779
    • View Profile
    • Homepage
Re: Online Highscore example
« Reply #2 on: 2008-Oct-28 »
Eh? Because I can do the same thing in PHP with a couple of lines of code? PHP is the simplest way of doing it and it works on almost ALL webservers out there. Not everyone has the possibility to install custom files on the webhost. GLBasic is made for games, not hosting websites. I preffer to just write a few lines of PHP and have others worry about ports and garbage coming into that port randomly from the internet.

In case your post was just a joke, forgive me for the stupid answer...

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: Online Highscore example
« Reply #3 on: 2008-Oct-28 »
I didnt say anything about using glbasic to host a website...only to alter the score datafile.

Is installing CodeIgniter to a website a "custom" thing?

I see your point, its just a workaround tho :P
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)

Offline Moru

  • Administrator
  • Prof. Inline
  • *******
  • Posts: 1779
    • View Profile
    • Homepage
Re: Online Highscore example
« Reply #4 on: 2008-Oct-28 »
Codeigniter is just a PHP library, no custom thing needed. It might even be a good idea to run your whole homepage by using Codeigniter since it catches a lot of the dangers of passing values to an SQL database.

Offline Hemlos

  • To boldy go where no pixel has gone before!
  • Global Moderator
  • Prof. Inline
  • *******
  • Posts: 1635
  • Particle Hawk
    • View Profile
Re: Online Highscore example
« Reply #5 on: 2008-Oct-28 »
Sounds like a good ida Moru. Nice work.
Volume_of_Earth(km^3) = 4/3*3.14*POW(6371.392896,3)