Documentation ¶
Index ¶
- Constants
- Variables
- func Cleanup() error
- func ErrorDialog(format string, v ...interface{}) error
- func GetFullscreen() bool
- func GetSDLError() error
- func GetSeconds() float64
- func IsGameController(j int) bool
- func JoystickNameForIndex(j int) string
- func Key(k KeyCode) bool
- func MouseRelative() bool
- func MouseSetRelative(enabled bool) error
- func MouseShow(show bool)
- func MouseWarp(x, y int16)
- func NumJoysticks() int
- func OpenWindow(title string, width, height int16, display int, fullscreen bool, ...) error
- func ProcessEvents(win struct{ ... })
- func SDLQuit()
- func SetFullscreen(f bool)
- func SetWindowTitle(title string)
- func Setup() error
- func SwapWindow()
- func ToggleFullscreen()
- func Wrap(context string, err error) error
- type GameLoop
- type Gamepad
- type GamepadAxis
- type GamepadButton
- type Joystick
- type JoystickID
- type KeyCode
- type KeyLabel
- type WrappedError
Constants ¶
const ( GamepadButtonInvalid = GamepadButton(C.SDL_CONTROLLER_BUTTON_INVALID) GamepadA = GamepadButton(C.SDL_CONTROLLER_BUTTON_A) GamepadB = GamepadButton(C.SDL_CONTROLLER_BUTTON_B) GamepadX = GamepadButton(C.SDL_CONTROLLER_BUTTON_X) GamepadY = GamepadButton(C.SDL_CONTROLLER_BUTTON_Y) GamepadBack = GamepadButton(C.SDL_CONTROLLER_BUTTON_BACK) GamepadGuide = GamepadButton(C.SDL_CONTROLLER_BUTTON_GUIDE) GamepadStart = GamepadButton(C.SDL_CONTROLLER_BUTTON_START) GamepadLeftClick = GamepadButton(C.SDL_CONTROLLER_BUTTON_LEFTSTICK) GamepadRightClick = GamepadButton(C.SDL_CONTROLLER_BUTTON_RIGHTSTICK) GamepadLeftBumper = GamepadButton(C.SDL_CONTROLLER_BUTTON_LEFTSHOULDER) GamepadRightBumper = GamepadButton(C.SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) GamepadDpadUp = GamepadButton(C.SDL_CONTROLLER_BUTTON_DPAD_UP) GamepadDpadDown = GamepadButton(C.SDL_CONTROLLER_BUTTON_DPAD_DOWN) GamepadDpadLeft = GamepadButton(C.SDL_CONTROLLER_BUTTON_DPAD_LEFT) GamepadDpadRight = GamepadButton(C.SDL_CONTROLLER_BUTTON_DPAD_RIGHT) GamepadButtonMax = GamepadButton(C.SDL_CONTROLLER_BUTTON_MAX) )
const ( GamepadInvalidAxis = GamepadAxis(C.SDL_CONTROLLER_AXIS_INVALID) GamepadLeftX = GamepadAxis(C.SDL_CONTROLLER_AXIS_LEFTX) GamepadLeftY = GamepadAxis(C.SDL_CONTROLLER_AXIS_LEFTY) GamepadRightX = GamepadAxis(C.SDL_CONTROLLER_AXIS_RIGHTX) GamepadRightY = GamepadAxis(C.SDL_CONTROLLER_AXIS_RIGHTY) GamepadLeftTrigger = GamepadAxis(C.SDL_CONTROLLER_AXIS_TRIGGERLEFT) GamepadRightTrigger = GamepadAxis(C.SDL_CONTROLLER_AXIS_TRIGGERRIGHT) GamepadMaxAxis = GamepadAxis(C.SDL_CONTROLLER_AXIS_MAX) )
Variables ¶
var ( Log logger = log.New(os.Stderr, "", log.Ltime|log.Lmicroseconds) Debug logger = nolog{} )
var ( // RenderDelta is the time elapsed between current and previous frames. RenderDelta float64 // UpdateLag is the time accumulator used to decorrelate render frames from // updates. UpdateLag float64 )
var ( HasFocus bool HasMouseFocus bool )
Focus state
var Config = struct { Debug bool WindowSize [2]int16 Display int Fullscreen bool FullscreenMode string VSync bool }{ Debug: false, WindowSize: [2]int16{1280, 720}, Display: 0, Fullscreen: false, FullscreenMode: "Desktop", VSync: true, }
Config holds the initial configuration of the game.
var FilePath string
FilePath of the executable (uses os-dependant separator).
var GLCleanup = func() error { return nil }
GLCleanup hook
var GLErr = func() error { return nil }
GLErr hook
var GLPrerender = func() error { return nil }
GLPrerender hook
var GLSetup = func() error { return nil }
GLSetup hook
var GameTime float64
GameTime is the current time.
var InputCleanup = func() error { return nil }
InputCleanup hook
var InputErr = func() error { return nil }
InputErr hook
var InputNewFrame = func() error { return nil }
InputNewFrame hook
var InputSetup = func() error { return nil }
InputSetup hook
var KeyState [512]bool //TODO: remove
KeyState holds the pressed state of all keys, indexed by position.
var MouseButtons uint32
MouseButtons holds the state of the mouse buttons.
var MouseDeltaX, MouseDeltaY int16
MouseDelta holds the delta from last mouse position.
var MousePositionX, MousePositionY int16
MousePosition holds the current mouse position.
var MouseWheelX, MouseWheelY int16
var Path string
Path of the executable (uses slash separators, and ends with one).
var PixelCleanup = func() error { return nil }
PixelCleanup hook
var PixelErr = func() error { return nil }
PixelErr hook
var PixelRender = func() error { return nil }
PixelRender hook
var PixelResize = func() {}
PixelResize hook
var PixelSetup = func() error { return nil }
PixelSetup hook
var PolyCleanup = func() error { return nil }
PolyCleanup hook
var PolyErr = func() error { return nil }
PolyErr hook
var PolySetup = func() error { return nil }
PolySetup hook
var QuitRequested = false
QuitRequested makes the game loop stop if true.
var Running = false
Running is true once the game loop is started.
var Title = "Cozely"
Title of the game
var UpdateStep = float64(1.0 / 50)
UpdateStep is the fixed time between calls to Update
var Window struct { Width, Height int16 Multisample int32 // contains filtered or unexported fields }
Window is the game window.
Functions ¶
func ErrorDialog ¶
ErrorDialog displays a dialog box.
func GetFullscreen ¶
func GetFullscreen() bool
func GetSDLError ¶
func GetSDLError() error
GetSDLError returns nil or the current SDL Error wrapped in a Go error.
func GetSeconds ¶
func GetSeconds() float64
GetSeconds returns the number of seconds elapsed since program start.
Note: This functions use the performance counter.
func IsGameController ¶
IsGameController returns true if the given joystick is supported by the game controller interface, false if it isn't or it's an invalid index.
func JoystickNameForIndex ¶
func MouseRelative ¶
func MouseRelative() bool
MouseRelative returns true if the relative mode is enabled.
func MouseSetRelative ¶
MouseSetRelative enables or disables the relative mode, where the mouse is hidden and mouse motions are continuously reported.
func NumJoysticks ¶
func NumJoysticks() int
NumJoysticks returns the number of attached joysticks on success or a negative error code on failure; call SDL_GetError() for more information.
func OpenWindow ¶
func OpenWindow( title string, width, height int16, display int, fullscreen bool, fullscreenMode string, vsync bool, debug bool, ) error
OpenWindow creates the game window and its associated OpenGL context.
func ProcessEvents ¶
func ProcessEvents(win struct { Resize func() Hide func() Show func() Focus func() Unfocus func() Quit func() })
ProcessEvents processes and dispatches all events.
func SetFullscreen ¶
func SetFullscreen(f bool)
func SetWindowTitle ¶
func SetWindowTitle(title string)
func ToggleFullscreen ¶
func ToggleFullscreen()
Types ¶
type GameLoop ¶
type GameLoop interface { Enter() Leave() React() Update() Render() }
GameLoop (identic to cozely.GameLoop).
type Gamepad ¶
type Gamepad C.SDL_GameController
Gamepad is a pointer to a SDL object.
func GameControllerOpen ¶
GameControllerOpen Returns a gamecontroller pointer or nil if an error occurred; call SDL_GetError() for more information.
func (*Gamepad) Axis ¶
func (a *Gamepad) Axis(x GamepadAxis) int16
func (*Gamepad) Button ¶
func (a *Gamepad) Button(b GamepadButton) bool
type GamepadAxis ¶
type GamepadAxis = C.SDL_GameControllerAxis
type GamepadButton ¶
type GamepadButton C.SDL_GameControllerButton
type Joystick ¶
type Joystick C.SDL_Joystick
Joystick is a pointer to a SDL object.
func (*Joystick) InstanceID ¶
func (a *Joystick) InstanceID() JoystickID
type JoystickID ¶
type JoystickID C.SDL_JoystickID
JoystickID is the unique identifier given by SDL to a joystick.
type KeyCode ¶
type KeyCode uint32
A KeyCode designate a key by its physical position on the keyboard. It is not affected by the layout or any other language settings.
func KeySearchPositionOf ¶
KeySearchPositionOf searches the current position of label in the current layout.
type KeyLabel ¶
type KeyLabel rune
A KeyLabel designate a key by its label in the current layout of the keyboard. For printable characters, the value is the rune that would be generated by pressing the key without any modifiers.
func KeyLabelOf ¶
KeyLabelOf returns the key label at the specified position in the current layout.
type WrappedError ¶
func (WrappedError) Error ¶
func (e WrappedError) Error() string