DEV Community

Sarthak Ganguly
Sarthak Ganguly

Posted on

Unity begone

Here is a challenge.

Search for "web gaming portal" on Google or any other search engine of your choice. Or anything that is remotely similar.

Here is a typical page or search result that you are likely to see.

Go to most of these and this is the page that you will see.

You will notice something eerily familiar.

Most of the games are the same, the majority of the games are coded in Unity and worse - the websites are often mirrors of one another.

Here is what I wanted to find - simple portal where I could play simpler games built with HTML and Javascript and nothing else. Sure, building them with engines like Phaser is one thing, but creating a complete game with Unity and then packing it together to play a game that I can't tinker with is no fun!

What are these portals?

Most of these are similar websites that host a bunch of games in good order and types. The objective is relatively simple - it allows users to play games on the web without having to login or bother about any installations otherwise. They target school and college students, and the business model is relatively simple - advertisements.

Lots and lots of advertisements. These are not just your on page ads (ones you can block with Ad blocking tools) but also compiled ads in game that you can't skip. Overall, if your objective is to kill time, by all means - these websites are great.

But let's say you wish to revisit the 13kb gaming challenges or even wish to tweak any of the similar pure HTML and Javascript games - you will have to either check out the limited games listed on the site or browse through the hundreds of games in GitHub or other repositories, download and host them locally and then play them.

Here's what I thought

What if I could just have a portal where I could play any of these games anytime I wanted?
Initially I tried this on a simple python http server. It worked good enough. I could ngrok it to share it with some of my friends.

Eventually, I thought to scale it up.

It was not hard.

All I did was

  • Downloaded a number of MIT or unlicensed games that I enjoy
  • Hosted them on a server in a docker container
  • Created a single JSON file that encapsulated the gaming meta data
  • Spun up a React SPA that held together all of the games using the games JSON file.

A typical JSON entry would look like this -

{
  "id": "unique-uuid-here",
  "title": "My Awesome Game",
  "slug": "mygame",
  "category": "arcade",
  "thumbnail": "",
  "emoji": "🚀",
  "description": "A detailed description shown in the intermediate view.",
  "players": 1000,
  "rating": 4.5,
  "badge": "new",
  "path": "/games/mygame/index.html",
  "source": "https://github.com/user/mygame",
  "isPlayable": true,
  "license": "MIT"
}
Enter fullscreen mode Exit fullscreen mode

Yes, this is my 'database' of sorts!

And yes, some of the fields in the json are dummies, like rating, badge, players and so on. But I can build or iterate on this basic setup in time.

And thus, the basic gaming portal was ready!

Theming was done thanks to Gemini and I was able to run this on my Pentium 3 potato PC running Puppy Linux.

The entire code is hosted here. The demo website is up at Frybahn.

Top comments (0)