Documentation ¶
Index ¶
Constants ¶
const ( Unknown Button = iota Left = 1 << iota Right Up Down Action Menu Hands )
const FrameMsec = 16 * time.Millisecond
Variables ¶
var ( // CurrentKeymap is the current keymap used to translate // key code into Buttons. CurrentKeymap = DefaultKeymap DefaultKeymap = map[KeyCode]Button{ KeyCode(C.SDLK_s): Left, KeyCode(C.SDLK_f): Right, KeyCode(C.SDLK_e): Up, KeyCode(C.SDLK_d): Down, KeyCode(C.SDLK_j): Action, KeyCode(C.SDLK_k): Menu, KeyCode(C.SDLK_h): Hands, } DvorakKeymap = map[KeyCode]Button{ KeyCode(C.SDLK_o): Left, KeyCode(C.SDLK_u): Right, KeyCode(C.SDLK_PERIOD): Up, KeyCode(C.SDLK_e): Down, KeyCode(C.SDLK_h): Action, KeyCode(C.SDLK_t): Menu, KeyCode(C.SDLK_d): Hands, } )
Functions ¶
This section is empty.
Types ¶
type Drawer ¶
type Drawer interface { Draw(interface{}, geom.Point) geom.Point SetFont(name string, szPts float64) SetColor(color.Color) TextSize(string) geom.Point }
A Drawer can draw things and change colors.
type Finder ¶
The Finder's Find method takes a filename of a resource and returns the full path to it.
type Screen ¶
type Screen interface { // Draw should send draw commands via the given Writer. Draw(Drawer) // Handle is called for each event coming from the // Ui, with the exception of the Close event which is // intercepted by the ScreenStack to exit the program. Handle(*ScreenStack, Event) error // Update is called after all of the events are handled and after // the next frame is drawn in order to allow the screen to update // its state based on the events. Update(*ScreenStack) error // Transparent returns true iff the screen doesn't fill the window. Transparent() bool }
A Screen represents some game screen. E.g. the title, the main gameplay, etc.
type ScreenStack ¶
type ScreenStack struct { NFrames uint MeanFrame float64 // milliseconds // Buttons is a bit set of the currently pressed buttons. Buttons Button // contains filtered or unexported fields }
A ScreenStack holds the stack of game screens.
func NewScreenStack ¶
func NewScreenStack(win *Ui, first Screen) *ScreenStack
NewScreenStack returns a new screen stack with the given initial screen.
func (*ScreenStack) Pop ¶
func (s *ScreenStack) Pop()
Pop pops the current screen off of the top of the stack.
func (*ScreenStack) Push ¶
func (s *ScreenStack) Push(screen Screen)
Push pushes a new screen onto the top of the stack.
func (*ScreenStack) Run ¶
func (s *ScreenStack) Run()
Run runs the main loop of the program, calling the Draw(), Handle(), then Update() methods on the top screen on the stack.
type Ui ¶
type Ui struct {
// contains filtered or unexported fields
}
func (*Ui) Draw ¶
Draw queues a rendering of x and returns the dimensions of what will be rendered, or an error. Draw supports the following types:
string The given string is drawn at p in the current font, in the current color. geom.Rectangle The given rectangle is filled at offset p, in the current color. Sprite The given image is drawn at offset p. image.Image The given image is drawn at offset p.
Notes ¶
Bugs ¶
asRgba assumes the image bounds starts at (0,0).
barf