Simple Water Effects in Sky Diver Classic
The most fascinating element in videogame development is water. We humans are surrounded by it: we enjoy visiting rivers, lakes, oceans… even at our homes or places of work we can take advantage of clean tap water in our daily lives! One of my favorite things to do on the weekend is to come down to the bay and relax by watching the sea crash into the rocks. But water in videogames can be extraordinarily difficult to get right. As we are so accustomed to its presence, every little difference with the real thing will be noticed.
There are many ways to portrait water in a videogame. From physics based fluid simulations to complex visual tricks, each game has its own flavor. In Sky Diver Classic the water is ever present. It essentially delimits the area where the players can land safely (when there aren’t horrible traps to catch them). So, I wanted it to be appealing, to feel a bit alive. But due to my limited time budget, I also needed a fast solution.
Sky Diver Classic’s simple pixel art visuals played in my favor. I decided that having these effects should be enough to achieve a decent look:
- Basic water refraction.
- Change the color of the objects inside the water.
- Basic particles.
Other effects I could have done are surface waves, reflections, more advance light refraction effects… Which I may consider in the future, but for now these will do!
A basic water refraction for 2D games can be achieved by altering the position of the pixels with a sine-wave function (another reason why math is important in game development). If you offset the position of each pixel of the object being in water by the amplitude of the sinewave, you will get a nice wavy pattern. You can then change the phase of the wave with time to get it to animate.
To change the color of the objects inside the water I just needed to alter a bit the materials created to set the color palette of the game. I added a new row of gradient in the sprite palette (see my previous article to better understand how it works) and made the material code to switch to that color depending on whether the pixel to be drawn is inside the water area or not. The best part of this way is that I can then have specific water styles for the different levels, just by adjusting the palette texture!
Particle effects are one of the most versatile components of visual effects in games. They are universally used in every game, as they add a lot of visual value without much effort and CPU cost. A particle effect in its essence is a basic physics simulation that is applied to a group of objects with a limited lifetime. The Unity editor includes tools to design and modify particle effects, with a decent amount of parameters.
In Sky Diver Classic I use particle effects for the blood splat that appears when you crash into the ground, for snow falling, lava, electricity… And yes, for the water too! There are two main particle effects that I apply to the water: Bubbles and water splash. Both are remarkably simple particle effects using the same small square texture.
All in all, with only those simple effects, the water in the game looks quite good and watery! But there are many improvements I could do. What improvements would you want to see done?
Want to know more about any other game development topics or issues? Leave me a comment and I’ll be happy to write about it!
Want to try Sky Diver Classic? Here is the link: https://play.google.com/store/apps/details?id=com.StrawberryTreeGames.SkyDiverClassic
Leave a Reply