Not Fish
A multiplayer one button game.
You're a dolphin, your opponents are as well, who's going to be faster?
- Type: Prototype (48h)
- Team: Wouter De Wolf, Thomas Van Riel, Leo Vansteenkiste, Wouter Weynants
- Contributions: Ideation, Gameplay coding
- Engine: Unity 5
- Main Language: C#
- Source: Available on Bitbucket
Created during the 2015 edition of the DAE gamejam, awarded with the 3rd place out of ±15.
The gameplay is simple, get all around the keyboard and find yourself a key on the keyboard. Spam your assigned key as fast as possible to make your dolphin swim. The catch is that you need to take in some air from time to time or you'll start to slow down.
Try the game with up to 26 people, sweaty palms are optional.
Contributions
As main programmer, I was in charge of setting up the basic framework for the game. Using a simple state machine the main functions of the game are delegated to the required scripts. As gameplay programmer I made sure the gameplay is smooth and challenging. For instance, I implemented dolphin movement & behaviour, camera movement and multiplayer input.
Challenges
Challenging one button control
In order to get a challenging gameplay where each player can only control one button, I had to come up with some 'limitations' to make the game more interesting to play.
- The first thing I implemented was an impulse applied to the dolphin on each key press. This became a pretty boring game since the player who could tap fastest would just win, every time.
- The second ability I gave the dolphins was diving and jumping. If the player holds the key, the dolphin starts diving, when the key is released the dolphin climbs up and jumps out of the water. At that point it was more of a gimmick rather than a game changer. Diving and jumping would always be slower than just swimming more. Even with the hoop boosts implemented it just wasn't useful enough.
- The breakthrough for a more strategic gameplay was limiting the impulse force from each key press over time. If the player keeps tapping the magnitude of the impulse would just be less and less, making the dolphin swim slower and slower. Only by jumping (and taking in some air), the magnitude of the impulse could be restored to its original strength. With this 'limitation' you have to be more strategic when to swim and when to jump.
These steps taken over the course of two days of development, made a monotone game, gameplay wise, into a more strategic game. With the current setup you should be smart about when to spam your button and when to jump.
Any key as input
For our game we wanted to be able to bind the player to any key on the keyboard (or just any input device).
To do that we could use Unity's default InputManager system, but to do that we would need to make an entry for each key in the input manager panel, which would be a convoluted way to achieve the goal. The solution is quite simple and much more robust.
In Unity it is possible to get a KeyCode from the event system (if the event is a key press) and store that KeyCode in a variable. In unity, listening to each key press is best done within the OnGUI() method, since for each input an event is created and sent through to the OnGUI() function. So for each event a check can be performed to validate it as being a key and if that key is down. When you know the event is a key, you can get the KeyCode from the event and check if it is a valid key, done in the IsKeyUsable() method. In that method the KeyCode is validated against an array with KeyCodes and and checked if the key hasn't been assigned yet. If the key is usable, a new player can be spawned with the KeyCode as an identifier.
void OnGUI ()
{
// Receive input events to generate new players when setting up game
Event e = Event.current;
// Check if the event is a 'key down' event
if (e.isKey && e.keyCode != KeyCode.None && e.type == EventType.KeyDown && GameState == GameStates.SetupGame && !_buttonDown) {
KeyCode key = e.keyCode;
// Check if the key is valid and if it hasn't been assigned yet
if (IsKeyUsable (key)) {
SpawnPlayer (key);
}
}
}
bool IsKeyUsable (KeyCode key)
{
// Check if the key is within the array with keycodes
if (CheckKey (key)) {
// Check if the key is in use for another player
foreach (PlayerInfo pi in PlayersArr) {
if (pi.script.Key == key) {
return false;
}
}
return true;
}
return false;
}
bool CheckKey (KeyCode key)
{
foreach (KeyCode k in _validCodesArr) {
if (k == key)
return true;
}
return false;
}