Documentation
¶
Overview ¶
Package adapter implements the Adapter design pattern. The space ship uses the default KeyPanel controller which conforms to a common Controller interface to receive the input from the pilot. A new joystick-style controller, SpaceStick, is introduced with its own incompatible interface. The StickToKeysAdapter adapts the SpaceStick to the legacy Controller interface, allowing the pilot to control the ship as if using the original controls.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Controller ¶
type Controller interface {
Up()
Down()
Left()
Right()
}
Controller is the common interface expected for the ship's controller
type SpaceStick ¶
type SpaceStick struct{}
SpaceStick is the new modern controller with the custom interface
func (*SpaceStick) Touch ¶
func (s *SpaceStick) Touch(direction uint)
Touch moves the object in the corresponding direction
type StickToKeysAdapter ¶
type StickToKeysAdapter struct {
// contains filtered or unexported fields
}
StickToKeysAdapter is the interface, that implements Controller interface for the new type of joystick controllers
func (*StickToKeysAdapter) Right ¶
func (a *StickToKeysAdapter) Right()
Right tilts ship to the right