I am always been interested in word games. In 2009 I released WorDrop, built with Flash, AS3 and Box2D, which has been played more than 4 million times before MochiMedia closed.
In 2013, I released worDrop, my first HTML5 game built with Construct 2, which I eventually licensed to Softgames.
I also wrote a couple of posts about the basics of word games.
Now it’s time to show you something more up to date, so let’s start with a fresh list of english words thanks to dawyl.
I used the list in JSON format, because it’s easier to convert into a JavaScript Oject I can use inside Phaser.
Look at the example:
Write a word with your keyboard, and see it in green if it’s included in the list of english words, or in red.
This has been made in literally a couple of lines, have a look at the commented source code:
let game; window.onload = function() { let gameConfig = { type: Phaser.AUTO, scale: { mode: Phaser.Scale.FIT, autoCenter: Phaser.Scale.CENTER_BOTH, parent: "thegame", width: 600, height: 120 }, scene: playGame } game = new Phaser.Game(gameConfig); window.focus(); } class playGame extends Phaser.Scene { constructor() { super("PlayGame"); } preload() { // import english words // thank you dwyl! - https://github.com/dwyl/english-words this.load.json("words", "words_dictionary.json"); } create() { // import json object into a variable this.data = this.cache.json.get("words"); // just a static text let staticText = this.add.text(10, 10, "Write a word: ", { font: "32px arial", fill: "#ffffff" }); // this is the text we are going to write this.wordText = this.add.text(staticText.getBounds().right, 10, "", { font: "32px arial" }); // keydown linster to call updateWord method this.input.keyboard.on("keydown", this.updateWord, this); } updateWord(e) { // delete last letter if (e.keyCode === 8 && this.wordText.text.length > 0) { this.wordText.text = this.wordText.text.substr(0, this.wordText.text.length - 1); } // add a letter else { if (e.keyCode >= 48 && e.keyCode <= 90) { this.wordText.text += e.key; } } // set text color to red if the world is not included in the list, green otherwise this.wordText.setColor(this.wordText.text in this.data ? "#00ff00" : "#ff0000"); } }
I think I am going to build a modern version of my worDrop game, optimized for mobile. Stay tuned and download the source code, word list included.