Creating patterns for static nasties in MPAGD
Updated: Nov 17, 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!