GameMaker: Tower defense path-finding


Most of units turning back to take advantage of appearing hole in the maze

This example may be useful for ones making games of Tower Defense genre, as well as other games that require instances to dynamically re-adjust their path as new obstacles are being added.

System, included in this example, recalculates paths only when needed, thus providing minimum resource usage.
As well it detects if units have been blocked (to exclude possibility of cheating by enclosing units), and has a lesser sub-system to recycle & reuse paths.

Overall, should be intermediately useful.

Download

GameMaker: Pointing to an off-screen object


Illustration

This intermediate example demonstrates, how to create a rather nice interface element being an arrow that points between a on-screen object (normally player) and a off-screen location, that needs to be reached. In this case, arrow indicates exact direction to target, and is made to clamp accurately to screen edges (preserving direction vector), to avoid confusion on behalf of player.
Such feature is specifically useful for exploration games, where goal(s) may be at different distance from player, and some guidance is required.

Download

Source code follows,

Continue reading

GameMaker: Orbiting


Interactive demo. Mouseover to activate, drag planets around.

This is an example of making an instance orbit around other instance in GameMaker.

In contrast to other similar examples (and commonly given advice of the kind), it allows to define orbiting speed in a common way (pixels/frame instead of degrees/frame).

This is accomplished by calculating the distance to orbit' center (from current position), calculating the orbit' length, and thus converting pixel speed to degree speed.

New position is then calculated and instance' speed is adjusted for it to reach it the next frame.
This allows to use direction in collision calculations as per usual.

Overall, the code is simple enough but documented regardless.

Download GMK

Code follows,

Continue reading

GameMaker: 8-way shooting with 4 keys


This is a specific example for shooting in 8 directions by having 4 'shoot' keys, which, in different combinations, determine direction. While not being exactly a common control scheme, in some situations this proves to be better than different schemes with single attack button, as it allows projectiles to be fired in directions independent from movement, essentially granting something similar to 'analog sticks' of gamepads.
Example is simple, well commented, and would be rather easy to implement.

Download GMK

GameMaker: “notification” window


In the example, 'notifier' is just being annoying on purpose

This is an example for adding smooth-looking slide effect to game's window in GameMaker.
I suppose that ones to use my old program 'GMConverter' might have seen it there.
Despite of simplicity, it doesn't seem to be a common thing to see in games and applications.
Taking low ability of people to understand my original code, this example is well-commented and attempts to simplify usage where possible.

Download

Continue reading

GameMaker: Collision with 2d array


How it looks and how it is internally

This example demonstrates how to organize system where some level information is presented as a 2-dimensional array (item data indicating block index), and organize collisions with that.

Could basically say that this is a smaller version of my Terra example. Except simpler, using arrays, and Lite-compatible. As well it does not support truly infinite worlds (has a 32000x32000 limit), but target user is not likely to need that anyway.

Download GMK

GameMaker: Coins, floating text, basic shop

GameMaker example - coins, floating text, basic shop
Let's just say that art assets for this example are from abstract collection.

While I have made this example a long time ago, it appears that questions about such still are common, and thus it would make sense to give it a 'searchable form' of post here.
This example demonstrates creation of 3 things:
  • Coins, as a basic collectable item.
  • Floating text, which is used here to display '+1' on picking up a coin, but has many other uses.
  • Shops, as objects that sell you useful (or here, useless) things for coins.
Overall, rather simplistic, however still useful for ones that do not know what they're doing with these.

Download GMK

GameMaker: ‘strategy’ unit selection

Today I've made a simple example for strategy-like unit selection.
That is, selecting units (instances) with mouse, with selection rectangle and selected units being displayed accordingly.
Example is well-commented and should be easy to use.
Principle of work is simple - to detect units that overlap selection rectangle, game should cycle through them, performing collision_rectangle checks. Amount of calculations and code complexity is cut here by local variable usage (if you did not know, local variables 'var' will be available inside of with constructions without any prefixes).

Download GMK

Source code follows,

Continue reading