It’s again time to post about the current project going on at university. We are creating games for use with a custom controller. This controller has some unusual control devices, like linear and rotary encoders, as well as conventional input methods like buttons and an accelerometer. Also it is not very ergonomic. If you want to know more about the device, you can find informations and images here on the Chair’s website.
For my project I chose to create a tank game, but not the obvious control-each-track-separately-with-one-of-the-two-linear-encoders kind of tank-game, but one inspired by the all time classic arcade game Pong. Two tanks, one at each edge of the screen, move along a straight path ad try to shoot each other. In between is a city block, which can be used to hide from the enemy’s attacks. This cover is completely destructible and after a couple of minutes there are only two places to hide left, one on each side of the screen. Additionally there are some powerups to vary the gameplay a bit, like carpet-bombers, shields and cover-piercing railguns.
Initially I wanted to make this a two-player game, with each player using one set of controls on one single controller to steer their tank, but the placement of the rotary encoders, used for the rotation of the tanks turrets, made this impossible. The two players would interfere with each other, because they are so close together. So instead I chose to write a simple artificial intelligence and made this the purpose of the exercise. This A.I. is of course nothing sophisticated. It is a simple state machine which can switch between hiding, attacking, defending and collecting pickups. Each state uses multiple raycasts to find the best position to hide or fire from, always trying to keep cover between the player and the enemy or finding the spot with the least amount of cover to fire through, respectively. And since it is so simple, it is really difficult to kill initially, since it seems to have perfect aim and always knows where to hide. Until you see through its simplicity, at which point it becomes nearly trivial. It can still land some lucky hits, but the player should be able to easily keep the upper hand.
A second, even simpler A.I. was used to control the soldiers trying to traverse the battlefield. They also use raycasts to detect obstacles, but then simply move up or down until the way to the other side of the screen is free again. When they are close to an enemy soldier, they try to kill each other.
To test the game’s mechanics without having access to the controller at home, I also created an alternative control scheme, using the keyboard. W/S to move up/down, A/D to rotate the turret, Spacebar to fire the main gun, Q for the small lasers and E to use your current powerup. If you want to try it, here you can find an alpha build.