Introduction

The final level in which I have created is in all regards my favorite level. Simple in it designs, but plentiful in surprise. Plentiful in a layer of complexity that one may take for granted without understanding the nature of code that lie beneath, a nature that I shall explain to you in this document.

Idea Creation

For a final level, what would one add? That is something I contemplated quite a bit in the early phases of the game’s making. What should I add to encapsulate the unique flair of my own coding ingenuity? Well, I came upon an idea in which I found would be very humorous and very fitting for a final level. A level that was essentially the first level, but with no enemies, platforms, lucky blocks, nothing. But as one would approach the center of the level, in likely visible disappointment, they would be shocked on what they would find. A collage of enemies surrounding them on both sides with the boss charging from the sky straight towards to their poor soul. Eventually, if you are to survive the boss long enough, the enemies would start to move towards the end, and the boss would dissipate from existences, as you claim a fruitful victory

Game Creation

So the main thing that was to be created was the code for the new enemy, namely a thwomp, and code for the boss. The first issue that arose in this was creating enemies that at first wouldn’t be present, but as the player reached a certain point on the map, they would then appear out of nowhere. To do in the most simple manner possible, enemies would be displaced 1000 units to the right of the actual game and when they were to be called upon, we would simply remove the additional units added for them to be in their proper place. Such can be observed in the code below:

spawnThwomp() {
    let playerX = GameEnv.PlayerPosition.playerX;

    //If Player Between 40% and 80% of level & this is the first time this is so, spawn Thwomps
    if ((playerX > GameEnv.innerWidth * 0.4) && (playerX < GameEnv.innerWidth * 0.8) && this.flag === 0) {
      this.x = this.xPercentage * GameEnv.innerWidth
      this.flashScreen();
      this.flag = 1
    }
  }