GameMaker: VFX Part 1

Greetings Patrons,

I will be breaking different series of articles into separate installments. This will allow me to hit different skill levels, explore a broad range of techniques across each category, and market these articles in a strategic way (often Part 1 of a series will be public/free to entice new users to sign-up to continue to receive future installments). These series may not always be sequential, so please do continue to suggest content (VFX Part 2 may not be next week’s article, for example).

Visual effects! I get asked about my approach to visual effects all of the time. I get asked about particles, sprite squash/stretch, shaders, etc. I will cover all of these topics at some point, but today I am going to focus on basic dust and smoke particles, how I use them, and a few tricks that you can use to make them more interesting and appealing. I will attach a sample project that includes a room to play around with, as well as all of the code (well-commented) necessary to create these effects.

Kicking Up Some Dust
Alright, so first thing’s first: we need to create some dust. You can use GameMaker’s built-in particle system if you’d like. It isn’t bad-, but I happen to use objects for my particles. I don’t run into efficiency issues, so you probably shouldn’t worry about it. Using objects gives me a certain amount of control over how my particles act (as well as allow for collision and things like that), and I also just like the work environment better and find that coding particles is a pain.

We have some creative freedom here. There is a lot of different things that we can do with our dust particles: collide with objects, accelerate, apply friction, apply gravity (y-axis? z-axis?!), and so on. For now, I think I am going to ignore any kind of collision, but we *will* implement a fake z-axis that allows our dust to be able to rise and fall. Perhaps we will have some form of collision with the z-axis “floor” after all.

For those who haven’t seen any of the GIFs from my Fara series of projects, I am using a fake z-axis to simulate depth. Adding this to a top-down game is actually quite simple. Objects are given a couple new variables: _z (position), _vz (velocity), potential gravity variables, etc. From there we just need to know that the floor is _z = 0 and anything that isn’t grounded has a _z that is less than zero.

Alright, so not very exciting yet. You can change the variables for different effects, but this *does* include all of the variables I would use for a typical particle. So what else can we do with this? The first thing that I notice is that without a frame of reference, the z-axis is useless. A shadow on the ground could fix this! If you don’t know how to use surfaces, this is the time to learn! I draw all of the shadows cast by objects to a single surface. This way the shadows can be transparent without overlapping improperly.

Hey, now that’s more like it! For each room in the project I created a new particle type to show off the progression. oVFXDust0 is that first example and oVFXDust1 is the example above. The only difference is a code block added to the end step event. That code draws a shadow to the surface held by a controller object used for shadow casting. You will note that I have halved the radius along the y-axis to further simulate depth.

What’s next? The technique used to draw overlapping shadows is helpful and allows a layer of objects to be drawn at a particular alpha value without overlapping improperly. We can apply this same technique to the particles themselves. This will allow the particles to be drawn with transparency and will also make the shadows more visible beneath them.

This is starting to look like dust! I also think it is a good stopping point for part one. As you probably noticed, I didn’t write much actual tutorial text within this article. Instead, most of the content is within the sample project, included code, and comments. Let me know if you would prefer a more step-by-step approach. I have yet to really monitor if I have programmer followers, designers, etc, so I am not sure what all of you would prefer. I want this to be an open thing where you can communicate with me about what you want, what you like, what needs to be changed, and so on.


Until next time,

GameMaker: VFX Part 1

2 thoughts on “GameMaker: VFX Part 1

  1. somemadpoet says:

    What’s the password? From: Zack Bell Games To: Sent: Friday, January 20, 2017 9:35 PM Subject: [New post] GameMaker: VFX Part 1 #yiv4370256706 a:hover {color:red;}#yiv4370256706 a {text-decoration:none;color:#0088cc;}#yiv4370256706 a.yiv4370256706primaryactionlink:link, #yiv4370256706 a.yiv4370256706primaryactionlink:visited {background-color:#2585B2;color:#fff;}#yiv4370256706 a.yiv4370256706primaryactionlink:hover, #yiv4370256706 a.yiv4370256706primaryactionlink:active {background-color:#11729E;color:#fff;}#yiv4370256706 | | |


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s