• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

HTML5 withnobody.com: HTML5 games website using Drupal 8

bacteriaman

Member
I have created a prototype for HTML5 games website built with Drupal 8.

http://withnobody.com/

As the domain name might suggest, the website is intended to host single-player and solitaire HTML5 games written in GameMaker: Studio 2.

INTRODUCTION

The system has the capacity to host an unlimited number of HTML5 games with the ability to store player scores for high score rankings and other statistical data.

To serve as an example, I used an HTML5 game I previously created with GameMaker: Studio 2 called "Dice With Nobody" (a single-player Yahtzee like adaptation of the popular similarly named mobile game.)


The following is a brief technical overview of how everything works.

DRUPAL 8

The data structure consists of 2 content types: a node to store game attributes and a custom entity to store player scores.

The game node includes a path field used in a field template to display the game inside an HTML object.

The score entity includes field references to the game node and user object. While the prototype only supports anonymous (unauthenticated) players, user accounts (part of Drupal core) could easily be enabled and expanded.

A custom module contains a hook that attaches a JSON variable when viewing a game node. The JSON contains attributes about the game node and player.

A REST web service is enabled to allow POSTing of player scores at the end of a game. Sidebar: this involved configuring 'trusted_host_patterns' and CORS in settings.local.php and services.yml respectively.

GM:S2 HTML5

The game includes a JavaScript extension containing one function. The function returns the aforementioned JSON variable attached by Drupal 8. The JSON attribute values are used in-turn to create the data structures needed to POST via http_request to the website's REST web service.

SUMMARY

There's still more work to do. The responsiveness of embedding the game in an HTML object is somewhat wonky. Also, the contents of the tabular score pages don't dynamically refresh with the latest score.

But overall the combination of Drupal 8 and GM:S2 HTML5 is working great. In fact, I actually intend to use this method for an client e-learning project involving over a dozen education-oriented HTML5 modules written in GM:S2 to store student responses and other historical data.

Feel free to give the game a whirl and see if you can achieve a high score. And of course your comments/feedback are welcome and appreciated.

Cheers,

John
 
Last edited:
Top