ClojureScript Game Engine Development with Construct 2

Clojure game programming benefits most from use of a game engine. While game engines are not specifically written for Clojure, Clojure is written to run on many VMs, and can take advantage of many game engines.

Construct 2 happens to be a great game engine for use with Clojure in the form of ClojureScript. ClojureScript integrates very nicely with Construct 2’s plugins and behaviors. Construct 2 allows for Clojure games (in the form of ClojureScript) to reach practically every platform out there for 2D game publishing.

Construct 2 / ClojureScript games can reach any platform HTML 5 games can reach, including:

  • All modern web browsers
  • Behave like native PC, Mac, and Linux apps using the Node-Webkit wrapper
  • Be published by Chrome Web Store, Facebook, Kongregate, NewGrounds, Firefox Marketplace, iOS and Android app stores, the Windows 8 Store, and Amazon
  • And can easily integrate advertising into games published to your own web site

Continue reading “ClojureScript Game Engine Development with Construct 2”

LocalStorage in Construct 2

Construct 2 LocalStorage saves variables in a similar way to the Construct 2 Dictionary. (See my Construct 2 Dictionary Tutorial if you are not familiar with Dictionaries.) The two big differences between LocalStorage and Dictionary are that LocalStorage doesn’t go away when the web browser restarts, and LocalStorage is asynchronous, not synchronous like Dictionary.

If that didn’t all make perfect sense to you, don’t worry. That’s the whole point of this tutorial. This tutorial teaches the basics of using Construct 2’s LocalStorage to store information when the game is not running. We’ll make a simple app that uses LocalStorage to store variables when the web browser is not running.

Construct 2 LocalStorage Example
LocalStorage saves variables when the web browser or even the computer are not running.

Continue reading “LocalStorage in Construct 2”

Construct 2 Dictionary Tutorial

Construct 2 dictionaries store data in key-value pairs. Think of a Dictionary as a table with one column for names of values and one column for values associated with the names. If you want a value from a Construct 2 Dictionary, you request the value associated with a key (keys are sometimes called “names”). You can also have Construct 2 get all the key-value pairs, one pair at a time, and do things with them, such as print out high scores.

If you know one or more programming languages, this may all sound familiar to you. The Construct 2 Dictionary is similar to associative arrays and hashmaps found in other languages.

Names (called keys) cannot be duplicated in a Construct 2 Dictionary. For example, if you have a Dictionary of high scores, you could store key-value pairs of Doug-35, Bob-99, and John-42, but you could not have two scores named “John” in the list. For example, Doug-35, John-42, and John-33 would not work because the key “John” is used twice.

Note to Advanced Programmers: You can get around the no-duplicate-keys limitation by having multiple minion-style Construct 2 Dictionaries keyed off values from a master Dictionary. It would work like foreign keys in relational databases. I won’t go into that now, but remember, having no duplicate keys in a table is not a limiting factor. It just requires some extra planning and work.

Dictionaries are extremely useful for storing lots of related data. Dictionary use is easy for old-time programmers, but dictionaries need explaining in more detail for newer Construct 2 game developers. So, here’s a Construct 2 project example that shows the basics of Construct 2 Dictionary use.

New Empty Construct 2 Project
Select a new empty Construct 2 project.

Continue reading “Construct 2 Dictionary Tutorial”