26 November 2023

Deepest Sword - Sword Controller

 




Here I created a controller for the game, Deepest Sword. The game is about a knight that has to go slay a dragon, getting a larger sword with each failed attempt he faces along the way. When approaching making the controller, I wanted to create it in the form of a sword to give the player a chance to actually wield a sword while traversing through the puzzles that we have to make it through. I made use of the potentiometer in the middle of the sword to control the character’s movements both left and right. I used mapping to constrain the large range of values down to range between -1 and 1. When the potentiometer knob is turned to the right, the player will start moving right and vice versa when the knob is turned to the left. Another important function to make it through the game is the ability to swing the sword to lift the knight across obstacles and stab the dragon. To handle this with the controller, I used the values from the accelerometer to decide which direction we will be swinging. By tilting the sword to the right, the knight will swing the sword clockwise. When the sword is tilted to the left, the sword will swing counterclockwise. When held straight up and centered, the sword won’t be swung and will stop the swing from either direction. Lastly, the game gives the option to restart any given level by pressing the R key on the keyboard. To give the player a way to use that without needing a physical button, I used the z axis to map the R key to. By tilting forward and laying flat, the button will be pressed and the level will restart from the last checkpoint.


Code:


Schematic:




Video:






No comments:

Post a Comment

Note: Only a member of this blog may post a comment.