top of page
  • Writer's pictureBruce

Creating patterns for static nasties in MPAGD

Updated: Nov 18, 2020

Here's a really simple way to add a pattern to the appearance/disappearance of a static nasty...without making it random. We'll be using MPAGDs DATA and READ commands to do this.

So, the effect I was trying to create in 24 Hour Parsley People: Episode 2 was of steam venting from a broken pipe (platform game clichés FTW!). But rather than it vent for x seconds and stop venting for y seconds, I wanted it to work in a pattern for example:

  • Vent: 2 seconds

  • Off: 3 seconds

  • Vent: 4 seconds

  • Off: 1 second

...and so on ( for a reasonable but not ridiculous number of variations)

This would then require the player to try and figure out the pattern before making their move.

Here's an example of the code running in a demo screen. I'm using the DIRECTION variable to store the pattern's current time setting - note that a higher DIRECTION value = a longer time period in the pattern:

This kind of pattern is ideal for using MPAGDs 'DATA' and 'READ' functions. But first we're going to create a sprite. As a minimum you'll need 2 frames, 1 for the nasty and a blank one. In my example, I'm using 5 frames the first 4 (numbers 0 to 3) are the Steam animation and the fifth one (#4) is blank...

So, when the steam is venting we will cycle through frames 0-3 and then when it stops venting we will hold the sprite on frame 4.

This means we can inflict damage if the player collides with the steam sprite ONLY when the steam frame is in the range 0 to 3.

And here's the code for your Steam Event...

Now, this wont quite work on it's own. We're going to need to initialise some of the parameters when the Sprite first draws on screen.

We're going to set an initial time length in DIRECTION (since in the code above Direction only gets set when it equals SETTINGA. By default, a sprites DIRECTION is always initially 0 unless you change it in the sprite initialisation screen.

but we can also add a bit of variety here too, for example, we could randomise whether the steam is ON or OFF initially (SETTINGB), so your code in your Sprite Initialisation event might look something like:

And that's it. Now your static nasties can appear and disappear in a pattern, entirely at your command :)

Hope this helps!

439 views0 comments

Recent Posts

See All


Want to support my work?....Buy my games!


Hello, I'm Bruce and I write games for old 8bit computers using Jonathan Cauldwell's excellent Multi-Platform Arcade Games Designer (MPAGD)

I've written a few successful* games for the Sinclair ZX Spectrum and MSX platforms that have been (largely) well received including Twenty Four Hour Parsley People scoring a 10 out of 10 on Planeta Sinclair.

In my blog I am sharing lots of the code that I wrote for my games, in a way that you can use in your own games.   I've commented it so that you'll learn some of the techniques I use to create interesting new mechanics and help your games stand out from the pack.

MPAGD includes lots of standard scripts, they're great to get you started, but if you're new (or just rusty) when it comes to writing code, hopefully my tutorials will help you get started and  turn your imagination into awesome 8 bit games!

All my code is free to use and do with as you please, but if you find them useful please feel free to buy me a coffee ...or better still - buy or download my games :)

*successful is a very relative term in 8bit computer games

bottom of page