Documentation ¶
Index ¶
- Constants
- Variables
- func AddOverlay(id string, scene Scene)
- func AddScene(id string, scene Scene)
- func Exit()
- func GetSize() (int, int)
- func Init()
- func MainLoop()
- func SetCurrentScene(id string)
- type BasicSceneImpl
- func (s *BasicSceneImpl) IsFocused() bool
- func (s *BasicSceneImpl) IsInited() bool
- func (s *BasicSceneImpl) IsPaused() bool
- func (s *BasicSceneImpl) IsRunning() bool
- func (s *BasicSceneImpl) IsTerminated() bool
- func (s *BasicSceneImpl) SetFocused(focused bool)
- func (s *BasicSceneImpl) SetState(state int)
- type KeyboardInputEvent
- type MouseInputEvent
- type Scene
- type SimpleSceneImpl
- type Window
- type WindowAction
Constants ¶
const ( StateUninited = iota StateInited = iota StateRunning = iota StatePaused = iota StateTerminated = iota )
states
Variables ¶
var MainWindow = newWindow(800, 600)
MainWindow is _the_ window
Functions ¶
Types ¶
type BasicSceneImpl ¶
type BasicSceneImpl struct {
// contains filtered or unexported fields
}
BasicSceneImpl is a partial Scene implementation that implements shared basic fields and functionality You still need to implement the following functions yourself: Init() HandleInput(key_events []KeyboardInputEvent, mouse_events []MouseInputEvent) WindowAction Tick(timedelta float64, key_states []bool)
func (*BasicSceneImpl) SetFocused ¶
func (s *BasicSceneImpl) SetFocused(focused bool)
SetFocused ...
type KeyboardInputEvent ¶
type KeyboardInputEvent struct { Key glfw.Key Scancode int Action glfw.Action Mod glfw.ModifierKey }
KeyboardInputEvent represents a glfw keyboard event
type MouseInputEvent ¶
type MouseInputEvent struct { Button glfw.MouseButton Action glfw.Action Mod glfw.ModifierKey X, Y float32 }
MouseInputEvent represents a glfw mouse event
type Scene ¶
type Scene interface { // Returns true if the Scene cares about input AcceptsInput() bool // Processes input events HandleInput(keyEvents []KeyboardInputEvent, mouseEvents []MouseInputEvent) WindowAction // Update the game frame and process time-dependant input Tick(timedelta float64, keyStates []bool) // Some scenes might want to ignore input or pause if they aren't focused SetFocused(isFocused bool) IsFocused() bool // Init the scene Init() // Returns true unless the scene is in state STATE_UNINITED or STATE_TERMINATED IsInited() bool // Set the scene in running mode Run() // Returns true if the scene is in state STATE_RUNNING IsRunning() bool // Pause the scene Pause() // Returns true if the scene is in state STATE_PAUSED IsPaused() bool Exit() // returns true if this scene is in STATE_TERMINATED. IsTerminated() bool }
Scene are responsible for handling input and rendering their content. They can be in the following states: 1. Uninited - only bare minimum setup at this point 2. Inited - resources should be allocated 3. Running - Running normally 4. Paused - Paused, can be resumed to return to the Running state 5. Terminated - all resources should be released
type SimpleSceneImpl ¶
type SimpleSceneImpl struct {
BasicSceneImpl
}
SimpleSceneImpl is a simple scene implementation to use when you want default state transitions and input
func (*SimpleSceneImpl) AcceptsInput ¶
func (s *SimpleSceneImpl) AcceptsInput() bool
AcceptsInput true
func (*SimpleSceneImpl) Run ¶
func (s *SimpleSceneImpl) Run()
Run checks that the scene is inited and sets the state to running
type Window ¶
type Window struct {
// contains filtered or unexported fields
}
Window is an actual window in the OS.
type WindowAction ¶
type WindowAction int
WindowAction is something the window should do
const ( WindowActionNone WindowAction = iota WindowActionExit = iota )
Window actions