Online Jewel Drop + Highscore

Posted By: Damocles_

Online Jewel Drop + Highscore - 09/15/09 17:49

Hi, i have revamped my old JewelDrop Game to A7.

http://www.wasteland.at/JewelDrop.zip
(ca 5MB)


The main focus was not the game, but the online Highscore,
using a HTTP plugin and PHP.

The game itself is a simple Match-3 game.
You can have a look at the code (warning its quite old-scholl c-script)


Wait a few seconds at the beginning, to let the game load the onlinescore.

Once you reached a new score you will be added to the TOP-10 list,
for everone to be celebrated.

ALSO: You can see the 10 most recend games played by other players.


Please have a try, for me to see if it runs stable yet.




Posted By: Meerkat

Re: Online Jewel Drop + Highscore - 09/15/09 18:05

7870 Points. laugh That game is funny. ^^
Posted By: Damocles_

Re: Online Jewel Drop + Highscore - 09/15/09 18:18

Good,

if anoone has problems with the Highscore, please post.
There might be problems when posting a new score.

(I will remove my high testscores later from the
top-10, was from debugging)
Posted By: Damocles_

Re: Online Jewel Drop + Highscore - 09/15/09 18:41

Oh, found a bug when submitting scores, uploading new version
Posted By: Michael_Schwarz

Re: Online Jewel Drop + Highscore - 09/15/09 19:26

yeah i like it, highscore!
Posted By: Damocles_

Re: Online Jewel Drop + Highscore - 09/15/09 19:45

good to see that it works wink
Posted By: Joozey

Re: Online Jewel Drop + Highscore - 09/15/09 20:59

Good game Damocles laugh
Nothing wrong with the highscore so far.
Posted By: MichaelGale

Re: Online Jewel Drop + Highscore - 09/15/09 21:34

The highscore system isn't working very well. It took me less than 5 minutes to find the relevant part of your code that submits the data to the server and to abuse it to submit any score (I submitted the "Test 99999" one). The checknum algorithm is way too simple, especially considering that you can access the source code that easily.
Posted By: Damocles_

Re: Online Jewel Drop + Highscore - 09/15/09 21:55

Well its open code, so not much of a challange...
Its mainly to show how to realize such a system with
the HTTP plugin.

For a more serious version, I could generate other checksum datas
and have it in a closed code of course.

I will post the php code later in the multiplayer sechtion.

---

There are many nice applications for php based games.
More than just a highscore.


Peacekeepers HTTP plugin is a really nice basis for that.

The ANet creator will probably post a demo of the paid version.(that also has HTTP support)
The current GSTNet plugin unfortunately crashes on my computer.
(nfs42, could you have a look?)

Posted By: MichaelGale

Re: Online Jewel Drop + Highscore - 09/15/09 22:17

Ah ok, fair enough then I guess. I just wanted to point that out though in case it was meant to be more serious. Although I suppose it would still be quite interesting to see some more sophisticated approaches.
Posted By: Damocles_

Re: Online Jewel Drop + Highscore - 09/15/09 22:22

The game was just a falloff actually.
I was looking today for one of my old games to use for this
Highscore. Trying to lean php right now.

---

A more advanced way would be to let the player first create
an online "player Account". (a simple one directly in the game,
without email or such)

Then I could directly clean out wrong inputs.

The submitted data can also be analysed with a more
advanced key.
For example by submitting a key to the account at startup,
then using this key to generate a checkkey.

I did not test if the HTTP plugin runs in Lite-C.
Where it is saver to implement.
Posted By: DC9

Re: Online Jewel Drop + Highscore - 09/16/09 02:17

Nice job Damocles. Scores are posted without any issue. The game is pretty cool too.
Posted By: Damocles_

Re: Online Jewel Drop + Highscore - 09/16/09 22:48

Chris obviously wants someone to beat his score wink
Posted By: Joozey

Re: Online Jewel Drop + Highscore - 09/17/09 09:19

Haha, well I came close yesterday.
Posted By: Damocles_

Re: Online Jewel Drop + Highscore - 09/17/09 09:34

Yes, ists kind of hard to reach 20.000 wink
I can only get up to 11.000

good to see that the highscore runs without a problem over
several days.


BTW: placing the bonus-stones is a it buggy.
Dont drag the stones, click them to pick them up, then place
them.
Dragging them would insert them in the first field, the cursor touches.
Posted By: nfs42

Online Jewel Drop + Highscore + GSTNet - 12/12/09 00:05

Hi Damocles,
I've finally converted your game to GSTNet.
There were some bugs with redirecting pages. But they are fixed in GSTNet 0.7.6.
Download JewelDrop - GSTNET

BTW: A nice game, but I can't get over 14000. Damn...
Posted By: Damocles_

Re: Online Jewel Drop + Highscore + GSTNet - 01/15/10 13:11

Oh, I see this this late, was away at that time.

Thanks for the conversion.
Posted By: Robso661

Re: Online Jewel Drop + Highscore + GSTNet - 02/12/10 13:22

Hallo,
muss schon sagen, dass Spiel ist echt gut. Habe aber eine Frage hierzu:

//austauschen eines Steines - Bonussteine
function change_stone(posx,posy,steintyp)
{
var feldposition;
feldposition=(10*posy)+posx;
temp_stone=ptr_for_handle(spielfeld[feldposition]);

temp_stone.s_destroyed=1;
spielfeld[feldposition]=0;

//neuen erstellen

temp.x=posx*64;
temp.y=0;
temp.z=posy*64;


if(steintyp==1)
{temp_stone=ent_create("smarakt.mdl",temp.x,edelstein);}
if(steintyp==2)
{temp_stone=ent_create("ametyst.mdl",temp.x,edelstein);}
if(steintyp==3)
{temp_stone=ent_create("smarakt_gelb.mdl",temp.x,edelstein);}
if(steintyp==4)
{temp_stone=ent_create("diamond.mdl",temp.x,diamant);}
if(steintyp==5)
{temp_stone=ent_create("ametyst_lila.mdl",temp.x,edelstein);}


temp_stone.s_grid_x=posx;
temp_stone.s_grid_y=posy;


temp_stone.s_stein_typ=steintyp;

temp_stone.s_grid_drag_x=posx;
temp_stone.s_grid_drag_y=posy;

spielfeld[feldposition]=handle(temp_stone);

}

So kommt es in deinem Script vor und ich wollte fragen ob du es mir genauer erörterrn könntest. Also einmal erklären wie das funktioniert mit dem neu erstellen denn irgendwie weiß ich noch nicht wie das programm jetzt weiß, wo es einen neuen stein keiren soll...

lg
Robin
Posted By: Damocles_

Re: Online Jewel Drop + Highscore + GSTNet - 02/12/10 14:12

Die funktion her mach folgendes:

finde den alten Stein in der Matrix
(der muß vorhanden sein, ansonsten gibts nen fehler)

finde ihne durch ermitteln der Feld-Position im Pointer-array.
Markiere ihn als zerstört (andere Funktion lässt ihn löschen)

und dann erzeuge einen neuen Stein, der gegebenen Farbe
und setze sein handle and die gleiche stelle im pointer-array.

die drag werte weiß ich jetzt nicht wozu die sind,

----

diese funktion hier ermittelt nicht die Position des
neuen Steins, sondern setzt ihn einfach gegeben der parameter.

Du mußt halt linear durch den code durchgehen, und schrittweise
anschauen was abläuft.
Dann verstehst du auch den code.
Posted By: Robso661

Re: Online Jewel Drop + Highscore + GSTNet - 02/12/10 19:30

danke mehr wollte ich garnicht wissen
Posted By: Robso661

Re: Online Jewel Drop + Highscore + GSTNet - 02/13/10 18:40

hallo damocles ich bins mal wieder...
in welchem script kommt das bewegen deiner juwelen vor? was ich meine ist.. in welchem script kommt das mit dem anklicken der juwelen vor also der teil der dafür sorgt das ich die juwelen verschieben kann...also umdrehen.

-card_gameplay
-jeweldrop
-highscore_script
-shader_effects
-logger
-gshttp
-predefs

wo kommt das vor... und wenn ich in einem dieser script vorkommt welche zeile ist dass? wäre echt supernett wenn du mir das beantworten würdest....
danke im voraus
Posted By: Damocles_

Re: Online Jewel Drop + Highscore + GSTNet - 02/13/10 20:28

warscheinlich card_gameplay. Schau nach mouse-clicks, die initiieren ja die Aktion.

Is jetzt bestimmt nicht schwer zu finden...
Posted By: Robso661

Re: Online Jewel Drop + Highscore + GSTNet - 02/13/10 21:32

ich habe bereits schon etwas länger in gameplay gesucht aber naja ich werde noch mal schauen ein 2. blick kann schließlich nicht schaden

hat es irgndwas hiermit zu tun?

function switch_stones(posx,posy,posx2,posy2)
{

var feldposition;
feldposition=(10*posy)+posx;
var feldposition2;
feldposition2=(10*posy2)+posx2;

if((spielfeld[feldposition]<=0)||(spielfeld[feldposition2]<=0))
{return;}

temp_stone=ptr_for_handle(spielfeld[feldposition]);
temp_stone2=ptr_for_handle(spielfeld[feldposition2]);

//positionen austauschen
temp_stone.s_grid_x=posx2;
temp_stone.s_grid_y=posy2;
temp_stone2.s_grid_x=posx;
temp_stone2.s_grid_y=posy;

spielfeld[feldposition2]=handle(temp_stone);
spielfeld[feldposition]=handle(temp_stone2);

}

.......tut mir Leid aber ich kann absolut kein einiges mouseclick-event finden...
Posted By: Damocles_

Re: Online Jewel Drop + Highscore + GSTNet - 02/13/10 21:50

Genau, die tauscht die Positionen aus.

erkennbar an "switch_stones"
und "//positionen austauschen "
Posted By: Robso661

Re: Online Jewel Drop + Highscore + GSTNet - 02/13/10 21:52

ja und wie weiß die engine jetzt welche steine sie tauschen soll? denn da hagt es im mom bei mir
Posted By: Landixus

Re: Online Jewel Drop + Highscore + GSTNet - 02/13/10 22:00

nice game, 2-3 Bugs but nice laugh
Posted By: Pappenheimer

Re: Online Jewel Drop + Highscore + GSTNet - 02/13/10 22:29

Robso661, Deinen Fragen nach zu urteilen, felhlen Dir noch einige Grundlagen, um so ein Spiel zu schreiben.

Dieses sind die entscheidenden Zeilen, in denen die Steine benannt sind, die getauscht werden:

"
temp_stone=ptr_for_handle(spielfeld[feldposition]);
temp_stone2=ptr_for_handle(spielfeld[feldposition2]);

[...]
spielfeld[feldposition2]=handle(temp_stone);
spielfeld[feldposition]=handle(temp_stone2);
"

Das geschieht über Pointer und Handle.

Ein Handle ist eine für jede Entity einzigartige Zahl, die die Engine jeder Entity bei Spielstart zuweist. Dabei ist völlig unerheblich, welche Zahl das ist, wichtig ist nur, dass man weiss, dass man darüber eindeutig ein Objekt(= Entity) wiederfinden kann.

Ein Pointer ist ein Zeiger auf ein Objekt (Es gibt auch noch andere Zeiger, aber das macht es zu kompliziert jetzt.). Wenn man sich vorstellt, dass beim Fangenspielen, der Fänger immer eine rote Mütze aufgesetzt bekommt. Diese Mütze hat dann ja nicht die ganze Zeit ein und derselbe auf, sondern sie wechselt, sobald der Fänger jemanden anderen berührt. Genauso wechselt der Zeiger "temp_stone" den Stein(das Objekt), sobald der Spieler einen Stein anklickt.

Über die "handle" und die "ptr_for_handle"-Funktionen tauscht man Funktionen und Informationen über die Objekte unter den Objekten aus.
Posted By: Superku

Re: Online Jewel Drop + Highscore + GSTNet - 02/13/10 22:58

It's a nice game, I liked to play it on my last continental flight.
I like the design, too, except the fonts, they could have been better.
It seems to run very stable.
I disliked that I'm not allowed to drop a piece in the "hold" box again that I've accidently picked up before. Besides there are selectable tiles around the game field, what is their purpose?
Posted By: Damocles_

Re: Online Jewel Drop + Highscore + GSTNet - 02/13/10 23:15

If the selection is outside of the playfields its rather a bug wink

Using the holdbox is also a bit buggy, and can make you
loose a stone.

Its some really old game. I revived it mainly to
have that online-component to showcase a php highscore.

If anyone wants to pimp it up, feel free to excahnge the graphics
to someting nicer.

------

nice to see that it is still played online wink

I think especially for small indy games a "recent games"
list is good, to create at least some multiuser feeling.


Such a system would also work in an RPG for example.
The system then uploads the current position of a player
like every 60 seconds.
And the other pull that info from the 10 most recent entries,
to see where other players are (about)
Could be shown on a game-map.

Very simple and lean communication.

Maybe even with some interaction like "Harald56" is also fighting in this cave now. He killed 10 rats.
Posted By: MrGuest

Re: Online Jewel Drop + Highscore + GSTNet - 02/14/10 00:59

Nicely made, clean and simple,

Only problem was trying to beat the highscore!
Posted By: ambe

Re: Online Jewel Drop + Highscore + GSTNet - 02/14/10 02:10

addictive -.-'
Posted By: Damocles_

Re: Online Jewel Drop + Highscore + GSTNet - 02/14/10 02:13

yes, ambe I can see you played quite a number of games wink

maybe I should Refresh the highscore, so there is some challenge
to get into that list


----

Ok, fresh highscore list.
And for the old Score Holders:


Here The All-Time best players list:

Chris!!!!! 21550
Chris 20310
Chris 19410
EnterYourName 18980
plsbeatmes 18290
Niceflits!e 17840
flits 17630
MichaelS 17370
test_1 16300
test_1 16160
Posted By: Robso661

Re: Online Jewel Drop + Highscore + GSTNet - 02/14/10 09:55

das mit dem pointer wusste ich nur über handels wusste ich nicht so bescheid
Posted By: Damocles_

Re: Online Jewel Drop + Highscore + GSTNet - 02/14/10 17:11

Seems to be a bit more action now in the Highscore.

Try to beat Ambe wink
Posted By: MrGuest

Re: Online Jewel Drop + Highscore + GSTNet - 02/14/10 18:24

18870! WoohoO! grin

Though still nowhere near Chris previous top score frown

Posted By: Damocles_

Re: Online Jewel Drop + Highscore + GSTNet - 02/14/10 18:25

Very good. I dont get over 9000
Posted By: Damocles_

Re: Online Jewel Drop + Highscore + GSTNet - 02/15/10 09:39

Here the php codes used for this, if anyone wants to
use such a system for php based actions.

(Highscores, or even stuff like sendign messages or players
using the game currently)




Code:
<?php
//Higschore script


//parameterline: http://damocles11.byethost9.com/index2.php?name=hubert&score=12346


$name = $_GET['name'];
$score = $_GET['score']+0;  //+0 makes shure it will be an number
$check = $_GET['check']+0;  //checknumber


if(strcmp($name,"")==0) {$name="Player";}
if(strlen($name)>16) {$name="Player";}  //shorten too long names


$name=trim($name);  //remove spaces
$name=strip_tags($name); //remove tags
$name=str_replace("~","-",$name); //remove tilde

//check if score is valid
//this should be implemented with a new algorythm by the programmer

//echo "score:" . $score . "  check:" . $score%77 . "<br>";

if($check != $score%77) {$score=0;die("error!");}  //throw out wrong scores! 


/*
echo "Player: ";
echo $name;
echo "<br>has a score of: ";
echo $score;
echo "<br>----------------<br>";
*/


$filename="scores.txt";
$maxentries=10;  //maximum number of highscore entries

//check if Highscore file exists

if(file_exists($filename)==0)
{
    //create new Highscore

    //add new entry
    $handle = fopen ($filename, 'w+');
    rewind($handle);


    for($i=0;$i<$maxentries;$i++)
    {
      fputs($handle,"Player");
      fputs($handle,'~');
      fputs($handle,$maxentries+1-$i); //generate dummyscores
      fputs($handle,'~');
      
    }

    fclose($handle); //close file

}


//read contents
//compare if new Highscore is higher than one of the previous 10

    $handle = fopen ($filename, 'r');
    rewind($handle);

    $content=fgets($handle,filesize($filename));  //read the entries

    $elemente=explode('~',$content);

    $j=0;

    //retrive entries
    for($i=0; $i<$maxentries*2;$i+=2)  //read max 10 entries
    {
      
      $playerName[$j]=$elemente[$i];
      $playerScore[$j]=$elemente[$i+1];

    $j++;

    }

    //echo $content;

    fclose($handle); //close file




//check if player is part of the highscore

$newEntry=0;

for($i=0; $i<$maxentries;$i++)  //read max 10 entries
    {
 
      if($score>$playerScore[$i])
      {
       //push down lower entries
      
       for($j=$maxentries-1; $j>=$i;$j--)  //read max 10 entries
          {
            $playerName[$j+1]=$playerName[$j];
            $playerScore[$j+1]=$playerScore[$j];
           }
      
      // save entry
      $playerName[$i]=$name;
      $playerScore[$i]=$score;
      
      $newEntry=1;
      
      //$i=100; //just for savety
      break; //jump out of loop
      }
      
    }


//if($newEntry==1) {echo "better entry! <br>";}


//save the changed file

if($newEntry==1)
{

//overwrite old file
    $handle = fopen ($filename, 'w+');
    rewind($handle);


    for($i=0;$i<$maxentries;$i++)
    {
      fputs($handle,$playerName[$i]);
      fputs($handle,'~');
      fputs($handle,$playerScore[$i]);
      fputs($handle,'~');
    }

    //echo "$filename does not exist";
    fclose($handle); //close file

}


//now show all entries


    $handle2 = fopen ($filename, 'r');
    rewind($handle2);
/*
    $content2=fgets($handle2,filesize($filename)+1);  //read the entries

    $elemente2=explode('~',$content2);

    //retrive entries
    for($i=0; $i<$maxentries*2;$i+=2)  //read max 10 entries
    {
      echo $elemente2[$i] . "~" . $elemente2[$i+1] ."~";
   }

*/
  echo fread($handle2,filesize($filename)); 
    //echo $content;

    fclose($handle2); //close file
    

?>



Code:
<?php
//Higschore script
//alternate script, showing the recent players


//parameterline: http://damocles11.byethost9.com/index2.php?name=hubert&score=12346


$name = $_GET['name'];
$score = $_GET['score']+0;  //+0 makes shure it will be an number
$check = $_GET['check']+0;  //checknumber


if(strcmp($name,"")==0) {$name="Player";}
if(strlen($name)>16) {$name="Player";}  //shorten too long names


$name=trim($name);  //remove spaces
$name=strip_tags($name); //remove tags
$name=str_replace("~","-",$name); //remove tilde

//check if score is valid
//this should be implemented with a new algorythm by the programmer
//And of course not lie in an open sktipt...

//echo "score:" . $score . "  check:" . $score%77 . "<br>";

if($check != $score%77) {$score=0;die("error!");}  //throw out wrong scores! 


/*
echo "Player: ";
echo $name;
echo "<br>has a score of: ";
echo $score;
echo "<br>----------------<br>";
*/


$filename="recent.txt";
$maxentries=10;  //maximum number of highscore entries

//check if Highscore file exists

if(file_exists($filename)==0)
{
    //create new Highscore

    //add new entry
    $handle = fopen ($filename, 'w+');
    rewind($handle);


    for($i=0;$i<$maxentries;$i++)
    {
      fputs($handle,"Player");
      fputs($handle,'~');
      fputs($handle,0); //generate dummyscores
      fputs($handle,'~');
      
    }

    fclose($handle); //close file

}


//read contents
//compare if new Highscore is higher than one of the previous 10

    $handle = fopen ($filename, 'r');
    rewind($handle);

    $content=fgets($handle,filesize($filename));  //read the entries

    $elemente=explode('~',$content);

    $j=0;

    //retrive entries
    for($i=0; $i<$maxentries*2;$i+=2)  //read max 10 entries
    {
      
      $playerName[$j]=$elemente[$i];
      $playerScore[$j]=$elemente[$i+1];

    $j++;

    }

    //echo $content;

    fclose($handle); //close file





//save the changed file

if($score>0)
{




//overwrite old file
    $handle = fopen ($filename, 'w+');
    rewind($handle);

//add new player on top
      fputs($handle,$name);
      fputs($handle,'~');
      fputs($handle,$score);
      fputs($handle,'~');


//insert previous games (one less)

    for($i=0;$i<$maxentries-1;$i++)
    {
      fputs($handle,$playerName[$i]);
      fputs($handle,'~');
      fputs($handle,$playerScore[$i]);
      fputs($handle,'~');
    }

    //echo "$filename does not exist";
    fclose($handle); //close file

}


//now show all entries


    $handle2 = fopen ($filename, 'r');
    rewind($handle2);
/*
    $content2=fgets($handle2,filesize($filename)+1);  //read the entries

    $elemente2=explode('~',$content2);

    //retrive entries
    for($i=0; $i<$maxentries*2;$i+=2)  //read max 10 entries
    {
      echo $elemente2[$i] . "~" . $elemente2[$i+1] ."~";
   }

*/
  echo fread($handle2,filesize($filename)); 
    //echo $content;

    fclose($handle2); //close file
    

?>


Posted By: ambe

Re: Online Jewel Drop + Highscore + GSTNet - 02/15/10 12:04

BACK ON TOP! tongue
Posted By: Damocles_

Re: Online Jewel Drop + Highscore + GSTNet - 09/06/10 18:31

I've reset the best players list, but keeping the best 4 players in.

There are still people playing it frequently.
© 2024 lite-C Forums