{"author_link":"\/users\/marc-antoine-girard","author_name":"Marc-Antoine Girard","author_uid":"marc-antoine-girard","comments":[],"epoch":1649388402,"event":"LD50","format":"md","ldjam_node_id":291565,"likes":12,"metadata":{"p_key":"165518","p_author":"Marc-Antoine Girard","p_authorkey":"1167299","p_urlkey":"391226","p_title":"The story behind the Leaderboard","p_cat":"LDJam ","p_event":"LD50","p_time":"1649388402","p_likes":"12","p_comments":"0","p_status":"WAYBACK","us_key":"1167299","us_name":"Marc-Antoine Girard","us_username":"marc-antoine-girard","event_start":"1648857600","event_key":"110","event_name":"Ludum Dare 50"},"node":{"_collation":{"body_sanitizer":"TextUtils::SanitizeHTML via existing importer","event":"LD50","removed_author":false},"_superparent":276397,"_trust":1,"author":167299,"body":"Hey, thanks everyone for [playing our game](https:\/\/ldjam.com\/events\/ludum-dare\/50\/farm-dog) and for your comments! Now, I just wanted to share with you the story behind our Leaderboard - The why it was a a good choice and yet, why I would not recommend it.\n\n![POSTMAN.png](\/\/\/raw\/38d\/82\/z\/4d7dd.png)\n\nThe leaderboard was never supposed to be part of this Game Jam. I was just feeling tired on Sunday at 1:00 AM,  so I started to play this Compo game, and for a compo, it was still a pretty solid entry with **minimalist visuals**, the **bare minimum of inputs** - basically the kind of game that you could easily play on a smartphone. \n\nFor a full **10 minutes**, I played the game and just COULDN'T STOP. Some guy had posted his score on the game page and all I wanted was to beat it. That's when I realized that, even if our game turns out ok,  people will still play it again just to beat someone, or be the best at it. Then came the idea of adding the leaderboard.\n\nNow, that's where I must be honest and say that, even though it was a good move, it was a risky one. The leaderboard didn't make it into the game until 5 minutes before release, and even then, it was an insanely stressful time. Thing is, it was a big move and if it hadn't worked out, I would've wasted a whole day for nothing. This is why, before actually doing the feature, I had to consider most of what it implied:\n\n - Finding a free hosting service (I guess that was an added challenge cuz I could've payed for it), \n\t - **Back4app**\n - Hosting the leaderboard\n - Doing the requests\n - Making the UI\n - Doing async calls, which meant adding some loading screen in the UI\n - Finding some way to remember the user without needing to sign-up \/ sign-in\n - Actually **ADD** a scoring system\n\nIt finally took 7 hours of nightmare to make it barely work, and 20 for the full integration. It could've taken less time, but the backend I used provided an SDK for Unity (Parse) that looked really easy to implement. I mean, look at that:\n```c#\nParseObject gameScore = new ParseObject(\"GameScore\");\ngameScore[\"score\"] = 1337;\ngameScore[\"playerName\"] = \"Sean Plott\";\nTask saveTask = gameScore.SaveAsync();\n```\n\nTurned out that the it had been deprecated for **4-6 years** and wouldn't compile in Unity because of some code in the DLLs that already existed in Unity. Luckily, they provided the actually source code, so I went in Visual Studio, removed the broken bit, recompiled the DLLs and VOILA. It worked....\n... ...\nIn the Editor.\n\nI was smart enough to build the project and run it in WebGL, *which crashed immediately*. That's when I remembered that WebGL is not a fan of Threads, and the DLLs were using **Tasks**\u2026 ***Don't use Tasks in WebGL kids.*** ... I ended throwing the SDK out and do simple **HTTP request calls** to the database using **UnityWebRequest** (since it's single-thread). The database documentation on how to use Web Request was scarce, but it provided a way to use **cURL**, which was.. kind of alright to understand... \n\n```console\n curl -X GET \\ \n-H \"X-Parse-Application-Id: 8ffbed6523c84319a7ae17979fbea93b\" \\ \n-H \"X-Parse-REST-API-Key: 0b34122ce4fd4997b5993cc447cbfd1f\" \\ \n-G \\ --data-urlencode 'where={\"title\": \"My post title\", \"likes\": { \"$gt\": 100 }}' \\\nhttps:\/\/parseapi.back4app.com\/classes\/Post\n```\nI mean.. not great, but... alright.  After all of the painful debugging and integrating, I finally had something that worked. I was really proud of it, the UI was done, I could post data and it would show up in the leaderboard... but when it was time to actually use it, we realized something...\n\n**No one did the scoring system.**\n\nIt's one hour before release. We have to implement the tutorial scene, the scoring system, hook it up with leaderboard, show some UI to display the score, build, distribute, test-test-test and hope everything  holds. It's pretty easy to guess that we did not do it all.\n\nSo this is the story, or part of it. I guess I learned new things, but 21 hours before deadline is not the time to implement a new massive feature! ","comments":4,"comments-timestamp":"2022-04-08T07:21:49Z","created":"2022-04-07T19:17:00Z","files":[],"files-timestamp":0,"id":291565,"love":12,"love-timestamp":"2022-04-22T00:38:54Z","meta":[],"modified":"2022-04-22T00:38:54Z","name":"The story behind the Leaderboard","node-timestamp":"2022-04-08T03:29:14Z","parent":278196,"parents":[1,5,9,276397,278196],"path":"\/events\/ludum-dare\/50\/farm-dog\/the-story-behind-the-leaderboard","published":"2022-04-08T03:26:42Z","scope":"public","slug":"the-story-behind-the-leaderboard","subsubtype":"","subtype":"","type":"post","version":904717},"node_metadata":{"n_key":"291565","n_urlkey":"391226","n_parent":"278196","n_path":"\/events\/ludum-dare\/50\/farm-dog\/the-story-behind-the-leaderboard","n_slug":"the-story-behind-the-leaderboard","n_type":"post","n_subtype":"","n_subsubtype":"","n_author":"167299","n_created":"1649359020","n_modified":"1650587934","n_version":"904717","n_status":"WAYBACK"},"source_url":"https:\/\/ldjam.com\/events\/ludum-dare\/50\/farm-dog\/the-story-behind-the-leaderboard","text":"Hey, thanks everyone for [playing our game](https:\/\/ldjam.com\/events\/ludum-dare\/50\/farm-dog) and for your comments! Now, I just wanted to share with you the story behind our Leaderboard - The why it was a a good choice and yet, why I would not recommend it.\n\n![POSTMAN.png](\/\/\/raw\/38d\/82\/z\/4d7dd.png)\n\nThe leaderboard was never supposed to be part of this Game Jam. I was just feeling tired on Sunday at 1:00 AM,  so I started to play this Compo game, and for a compo, it was still a pretty solid entry with **minimalist visuals**, the **bare minimum of inputs** - basically the kind of game that you could easily play on a smartphone. \n\nFor a full **10 minutes**, I played the game and just COULDN'T STOP. Some guy had posted his score on the game page and all I wanted was to beat it. That's when I realized that, even if our game turns out ok,  people will still play it again just to beat someone, or be the best at it. Then came the idea of adding the leaderboard.\n\nNow, that's where I must be honest and say that, even though it was a good move, it was a risky one. The leaderboard didn't make it into the game until 5 minutes before release, and even then, it was an insanely stressful time. Thing is, it was a big move and if it hadn't worked out, I would've wasted a whole day for nothing. This is why, before actually doing the feature, I had to consider most of what it implied:\n\n - Finding a free hosting service (I guess that was an added challenge cuz I could've payed for it), \n\t - **Back4app**\n - Hosting the leaderboard\n - Doing the requests\n - Making the UI\n - Doing async calls, which meant adding some loading screen in the UI\n - Finding some way to remember the user without needing to sign-up \/ sign-in\n - Actually **ADD** a scoring system\n\nIt finally took 7 hours of nightmare to make it barely work, and 20 for the full integration. It could've taken less time, but the backend I used provided an SDK for Unity (Parse) that looked really easy to implement. I mean, look at that:\n```c#\nParseObject gameScore = new ParseObject(\"GameScore\");\ngameScore[\"score\"] = 1337;\ngameScore[\"playerName\"] = \"Sean Plott\";\nTask saveTask = gameScore.SaveAsync();\n```\n\nTurned out that the it had been deprecated for **4-6 years** and wouldn't compile in Unity because of some code in the DLLs that already existed in Unity. Luckily, they provided the actually source code, so I went in Visual Studio, removed the broken bit, recompiled the DLLs and VOILA. It worked....\n... ...\nIn the Editor.\n\nI was smart enough to build the project and run it in WebGL, *which crashed immediately*. That's when I remembered that WebGL is not a fan of Threads, and the DLLs were using **Tasks**\u2026 ***Don't use Tasks in WebGL kids.*** ... I ended throwing the SDK out and do simple **HTTP request calls** to the database using **UnityWebRequest** (since it's single-thread). The database documentation on how to use Web Request was scarce, but it provided a way to use **cURL**, which was.. kind of alright to understand... \n\n```console\n curl -X GET \\ \n-H \"X-Parse-Application-Id: 8ffbed6523c84319a7ae17979fbea93b\" \\ \n-H \"X-Parse-REST-API-Key: 0b34122ce4fd4997b5993cc447cbfd1f\" \\ \n-G \\ --data-urlencode 'where={\"title\": \"My post title\", \"likes\": { \"$gt\": 100 }}' \\\nhttps:\/\/parseapi.back4app.com\/classes\/Post\n```\nI mean.. not great, but... alright.  After all of the painful debugging and integrating, I finally had something that worked. I was really proud of it, the UI was done, I could post data and it would show up in the leaderboard... but when it was time to actually use it, we realized something...\n\n**No one did the scoring system.**\n\nIt's one hour before release. We have to implement the tutorial scene, the scoring system, hook it up with leaderboard, show some UI to display the score, build, distribute, test-test-test and hope everything  holds. It's pretty easy to guess that we did not do it all.\n\nSo this is the story, or part of it. I guess I learned new things, but 21 hours before deadline is not the time to implement a new massive feature! ","title":"The story behind the Leaderboard","wayback_source":[]}