Devlog 2: Level Design


One of the challenges I had when creating the levels is art. It is a skill that I am working on improving but at the same time I need to be productive and take a fast run in order to finish the game on time. I had to find a solution that can make my life a bit easier when it comes to the arts.

To start, I used the sprites that Jonathan used in his course “The Ultimate Guide to Mobile Game Development” and I used the skills I learned in that course to build a tile-map for the first level. Now I have a simple level where I used the dungeon sprites that were provided in that course. Then I decided to build another level with the same tileset, but I was thinking that I shouldn’t have all the levels having the same dungeon-y theme. I need to create levels with variable themes so that levels won’t be boring.

Level 2 of Insanity
Level 2 of Insanity

Thankfully a friend of mine, who is a graphic designer, referred me to a website called Freepik. This website has a big set of sprites that you can use to build your own 2D game varying from 2D characters with their animations to tilesets to GUI items and a lot more. Basically what I did is that I downloaded almost all the tilesets from that website and I had to find my way through Adobe Illustrator to extract those tiles, make a sprite sheet with the correct sizes so I can slice them properly in Unity and create the tilemaps. I have to admit, the results turned out to be great! So if you are a game developer who is not good at art like me, I recommend that you use this website as a good start.

Then it came the time to decide which traps should I implement to make the game challenging and at the same time fun. The idea that I have is that I wanted the player to advance through the game bit by bit. I don’t want level one to have tough traps and tricky jumps, otherwise, the player will get bored from the game; but rather, let’s start with an easy level and get tougher the more the player advances through the game. The traps that I am initially thinking about are the following:

  1. Spikes (of course)
  2. Circular Saws (stationary and moving).
  3. Fire (bring the heat!)
  4. tracking missiles? (not yet sure whether I should include this or not.)

When it comes to the behavior of those traps, I tried as much as I could to make the behavior of those traps modular. So basically I have built a universal class called TrapDamageBehavior. This class is responsible for killing the player if it collides with the trap. This class can work with any trap that I can think of. Now some of those traps are not stationary. For example, The Circular Saws tend to move back and forth in their tracks at the level. For this scenario, I wanted to do some OOP. Basically, I have created a generic parent class called MovableObject that Inherits from MonoBehavior. Here is its code:

public class MoveableObject : Monobehavior
{
    #region Private Protected Variables

    /// <summary>
    /// The object's point A
    /// </summary>
    [SerializedField] protected Transform pointA;

    /// <summary>
    /// The object's point B
    /// </summary>
    [SerializedField] protected Transform pointB;

    /// <summary>
    /// The movement speed
    /// </summary>
    [SerializedField] protected float _movementSpeed;

    #endregion
}

This class has two points, A and B, where the object can move between and a movement speed variable. Now I can create another class called OscillatingMovement that defines the movement of any object that needs to move between two points. That class will inherit from MovableObject and use points A and B and the movement speed variable. This class has a function called Movement where the object is moved from one point to another back and forth. The code of the function is this:

public void Movement()
{
    //positionToMoveTo is initialized in start to pointA

    transform.position = Vector3.MoveTowards(transform.position, positionToMoveTo.position, _movementSpeed * Time.Deltatime);

    if (transform.position == pointA.position)
        positionToMoveTo = pointB;
    else if (transform.position == pointB.position)
        positionToMoveTo = pointA;
}

I was able to use this class to move all the circles saw traps as well as the moving platforms in my game; I even used the same class to move the level target which is the gem in the same manner. All that I have to do is to reference PointA and PointB for any moving object in the scene and define a movement speed and the object will move between Point A and B right away. The reason why I thought of building the movement of those objects in this way is that I am trying as much as I can to reuse the parent class with multiple objects. For example, If I am to implement the missile that I may need to create a child class that only uses point A for example as a spawn point and point B be the player last location upon spawning and the missile can then move towards point B but not in an oscillating movement but rather a one-directional movement.

There is still a lot to consider and to think about when it comes to the traps and I also see opportunities for optimization; but for now, this is how I approached my trap behaviors.

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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