MATLAB Game – Oil and Water

I finished this game earlier this year in May, but never made a video of it nor posted about it. It’s kind of hard to understand exactly what’s going on in the video, so hopefully this post clarifies things.

Player Input

My previous games only took the mouse in as an input. This one uses the following scheme:

W = move up
A = move left
S = move down
D = move right
1 = select ‘Oil Vial’ spell
2 = select ‘Spark’ spell
3 = select ‘Water Vial’ spell
4 = select ‘Chill’ spell
mouse 1 = cast spell


The player’s mana is capped at 100 mp and regenerates throughout the game. Oil Vial and Spark go together to create fire and Water Vial and Chill go together to create ice. Fire spreads out and damages everything standing in it (including the player). Ice prevents movement for anything caught in it (including the player). Also, each spell has its own mana cost:

Oil Vial = 25 mp
Spark = 5 mp
Water Vial = 10 mp
Chill = 50 mp


There are only two types of enemies in the game: turrets and blasters (I couldn’t think of a better name…). They’re basically the same, except that turrets don’t move and blasters have a random movement. Both turrets and blasters fire a red projectile that travels towards the player’s current position. The blasters are constrained in that they cannot move while their projectiles are in flight.

The player takes damage by either touching an enemy, which reduces player life by 20 hp, getting hit by a projectile, reducing player life by 10 hp, or standing in fire, also reducing player life by 10 hp. The player starts with 100 hp and the game ends if the player hits 0. There is no way to gain back health.


There are four levels in the game. Level 1 consists of two turrets. Level 2 has two blasters. Level 3 has multiple turrets in four corners of the map. Level 4 has nine blasters.


I had originally had big plans for this game. Here’s a few of the ideas I had:

  • Wind

    The idea behind wind would’ve been to move fire around to damage enemies. I had dreamt up something like winds along the cardinal directions (north, south, east, and west) to push fire around the map. Vortexes were also on my mind, which would basically cause fire to have more damage.

  • Puzzles

    Levels would have been more than blasting enemies, but also completing puzzles. For example, activating a switch behind a wall by using wind to move the fire

  • Magnetism

    Click on an object to give it a polarity, click on another to have the other object stick to it.

  • Electricity

    This one was fun. Basically, you would click on objects/enemies to “paint” them with a charge. As an example, you could be to paint five objects with electrons such that you would have -5e of net charge in the environment. Then, you would put +5e on a nearby enemy. The resultant arc between the 5 objects and the enemy would cause damage.

  • Bosses

    With magnetism and electricity, I was thinking of something akin to this boss from The Legend of Zelda: A Link to the Past.

    Basically, the player would paint it’s helmet with a bunch of electrons, use magnetism to rip off the helmet, and then put a positive charge on the weak spot underneath to cause a big arc.

Wrap up

As can be seen, I had a bunch of ideas for this game that ended up as four levels of colorful dots dancing around a screen. The thought of going back and incorporating my ideas is probably what kept me from posting about this game in the first place. But to implement these things, I would have to move to something more powerful than MATLAB (you know… something with graphics). Maybe I will sometime in the future, but until then, the ideas are free for anyone to grab and make their own.

2 thoughts on “MATLAB Game – Oil and Water

  1. Hey, I really like your game of life. I was then wondering if you could send the script to me or post it here on this website. Either or, I would be very interested in seeing it for further analysis.


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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s