GMStruct Inheritance and Types

In a previous post, I went through the basic usage of GMStruct, but I deliberately left out some details about inheritance and types. This is what I will be covering in this post.

Basic Types First of all, let's go over types in GMS. The first thing to note is that GMS comes with a set of basic types you can use: The String, Real, Pointer, Array and Boolean types.
You can use them to set the type of your struct attributes, in order to restrict the types of values you can pass to them at runtime. So far, nothing new.

Struct Types However, there are more types available in GMS; every struct you define will have its own type. This allows you to define an attribute to have a struct type.
For instance, you could have a Cat and an Owner struct. The Cat struct may have an owner attribute. That owner struct would be defined to be of type Owner.
This would look like this:

Inheritance So now we have basic struct types out of the way, let's have a look at inheritance.
Let's look at t…

GMWolf - Defining States with Objects

Game Maker State Machines often end up being very large objects, with a seemingly endless number of lines in each Event. I wanted to approach the creation of State machines using the powerful dynamic functions GameMaker provides, in order to make better use of the Object Resource.

GMStruct - extending GML with code generators

GML, or the GameMaker language has regularly been a little awkward for me to use due the lack of a core feature. That would of course be structures, a programming language staple allowing you to group together values under a single variable.

In the past, I would have recommended using arrays to act as structures, as described in my youtube video, and this is probably still good advice today (Or at least until YYG implement lightweight objects). However tired of messing around with arrays in my projects, I have decided to let robots take over, and generate all that code for me.

This is how I started creating GMStruct. A tool and language to bring structs to Game Maker.
Introducing code generation allows for numerous upgrades over 'array structs', allowing for inheritance, and even some polymorphism, all handled behind the scenes.

View the GMC Thread

The GMS Language "So how does it work?" I hear you ask. Well it's pretty simple:
The first step is to define the stru…