After finishing off the gamepad controller implementation in Project Spaghetti last week, we’re on to the mouse controls. Although Project Spaghetti is an action game and a good fit for the keyboard or controller, if we can manage a solid mouse-based user interface, it shouldn’t be a big leap to implement touch controls for mobile devices at a later date.
Everything so far has been designed from a player-centric point of view. Moving up, for example, moves up from where the player currently is, so long as the input is held down, and shooting is relative to where the player is facing. However, mouse-based navigation is going to require a little more work, likely involving motion paths (the kind we’ve been using with enemy AI). Unfortunately, players might not quite get the movement response they want when clicking around the room, so we’re going to have to try a simple implementation and then work on fixing potential problems from there. Players who want to use a mouse but also maintain finer control over their cowboy’s movement are going to want to make minor course decisions, rather than rely on pathfinding, especially when steering around obstacles or fleeing pursuers like angry ghosts or scorpions. To borrow from mainstream action RPGs, we’ll likely go with using the right mouse button to determine a target location for movement.
Movement on the right button frees the left button up for other functions in the game: shooting and dodging. Holding down the button when the cursor is over a location away from the player should charge the shot, while releasing the button should fire a shot in the direction of the cursor. For dodging, we’ll take advantage of the fact that the player is never going to want to shoot themselves! If the player clicks the left mouse button near their character, the result will be a dodge, not a shot, and further dragging of the mouse within the dodge window will determine the roll direction, if any.
And of course, the final touch will be adding mouse navigation to the various system menus like options or controls. And if players want to switch left and right mouse button functionality, we should let them do that from the controls menu.
One problem we’ll have when moving from a mouse to a touch screen will be the lack of buttons. Obviously, without a right or left button to determine whether the cowboy should move or shoot, we’ll have to interpret the touch screen actions a bit differently from the mouse. A possible solution is to require a double tap for the equivalent of the right mouse button, while a single tap or drag will be for shooting/dodging.
Although the retro twitch action in Project Spaghetti is probably more suited for controllers or keyboards, there is an advantage to supporting the mouse (besides laying the foundation for touch controls) and that’s ease of use. People who aren’t used to playing games have trouble wrapping their head around movement with a bunch of keys (and for people not used to blind typing, even locating keys with their fingers while watching the screen can prove a challenge), and of course, if they’re not gamers, they probably don’t own a controller. A solid mouse control scheme means we can put Project Spaghetti in the hands of someone who isn’t as familiar with games. More people able to play means more people able to have fun (if we do our jobs right), and that’s a good thing.