DESIGN & CODE

With all the art done, piecing the game together was relatively simple, but it took a lot of time. I planned from the start to have 3 levels and got stuck when determining how they’d interact. I first started with the idea of 3 separate maps, but I’ve always preferred when games have everything contained in 1 persistent map so that’s what I did.

I had a total of 9 images to make the landscape for each level (3 each). The only problem was getting to each one. I developed a very simple teleporting system when the player went the designated edge of a level with the first 2 being navigable back/forth and the last 2 having one-way access (which the player is warned of).

There are 3 main systems that I created for Knightborn2D’s navigation:

  1. A trigger box that would teleport the player to the previous/next level’s respective world coordinates. Player input would be disabled, the screen would fade to black, and then the player would teleport.

  2. A trigger box (green outline) that would control the player camera’s “dead zone”. This would freeze the player camera once overlapped and will prevent the player from seeing the edge of the playground/foreground.

  3. Lastly, naming locations is an important tool to familiarize players with new areas. This was done once again with a trigger box, UI would fade in saying “New Area Discovered - [Area Name]” as seen to the right.

Some of the code is shown below, but please keep in mind that I was a novice coder at this time (2021) and wasn’t aware of best practices or know all the systems available like I do now.

Level code that contains logic for setting camera dead zone, level 2 to 3 specific transitioning, “level end” event which rolls the credits, and background music to play when leaving the main menu. I’m not sure why I put everything on event tick in the level blueprint - looking back, it would’ve been better to make a separate blueprint actor or interface for the dead zones, level transitions, and music cues.

The is the code for enabling/disabling the camera dead zone logic. When the player overlaps any one of 6 trigger boxes marking the edge of the level, the player camera is locked until they’ve left the trigger box’s zone. The camera itself is its own actor - not attached to the player; this made adding camera logic easier.

The transition code for between level movement was the most complex system. It involved a long chain of nodes disabling player input, starting camera/audio fade, getting player location and teleporting the player, and then reversing the previous steps. There is also a separate branch of logic for the third level which enabled its specific music for a boss fight that wasn’t implemented.

Previous
Previous

Art (Backgrounds, UI)

Next
Next

Gameplay Design & Code