internal

package
v0.0.0-...-d322e89 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 14, 2018 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

Variables

View Source
var (
	Log   logger = log.New(os.Stderr, "", log.Ltime|log.Lmicroseconds)
	Debug logger = nolog{}
)
View Source
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
)
View Source
var (
	HasFocus      bool
	HasMouseFocus bool
)

Focus state

View Source
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.

View Source
var FilePath string

FilePath of the executable (uses os-dependant separator).

View Source
var GLCleanup = func() error { return nil }

GLCleanup hook

View Source
var GLErr = func() error { return nil }

GLErr hook

View Source
var GLPrerender = func() error { return nil }

GLPrerender hook

View Source
var GLSetup = func() error { return nil }

GLSetup hook

View Source
var GameTime float64

GameTime is the current time.

View Source
var InputCleanup = func() error { return nil }

InputCleanup hook

View Source
var InputErr = func() error { return nil }

InputErr hook

View Source
var InputNewFrame = func() error { return nil }

InputNewFrame hook

View Source
var InputSetup = func() error { return nil }

InputSetup hook

View Source
var KeyState [512]bool //TODO: remove

KeyState holds the pressed state of all keys, indexed by position.

View Source
var MouseButtons uint32

MouseButtons holds the state of the mouse buttons.

View Source
var MouseDeltaX, MouseDeltaY int16

MouseDelta holds the delta from last mouse position.

View Source
var MousePositionX, MousePositionY int16

MousePosition holds the current mouse position.

View Source
var MouseWheelX, MouseWheelY int16
View Source
var Path string

Path of the executable (uses slash separators, and ends with one).

View Source
var PixelCleanup = func() error { return nil }

PixelCleanup hook

View Source
var PixelErr = func() error { return nil }

PixelErr hook

View Source
var PixelRender = func() error { return nil }

PixelRender hook

View Source
var PixelResize = func() {}

PixelResize hook

View Source
var PixelSetup = func() error { return nil }

PixelSetup hook

View Source
var PolyCleanup = func() error { return nil }

PolyCleanup hook

View Source
var PolyErr = func() error { return nil }

PolyErr hook

View Source
var PolySetup = func() error { return nil }

PolySetup hook

View Source
var QuitRequested = false

QuitRequested makes the game loop stop if true.

View Source
var Running = false

Running is true once the game loop is started.

View Source
var Title = "Cozely"

Title of the game

View Source
var UpdateStep = float64(1.0 / 50)

UpdateStep is the fixed time between calls to Update

View Source
var Window struct {
	Width, Height int16
	Multisample   int32
	// contains filtered or unexported fields
}

Window is the game window.

Functions

func Cleanup

func Cleanup() error

func ErrorDialog

func ErrorDialog(format string, v ...interface{}) error

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

func IsGameController(j int) bool

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 JoystickNameForIndex(j int) string

func Key

func Key(k KeyCode) bool

func MouseRelative

func MouseRelative() bool

MouseRelative returns true if the relative mode is enabled.

func MouseSetRelative

func MouseSetRelative(enabled bool) error

MouseSetRelative enables or disables the relative mode, where the mouse is hidden and mouse motions are continuously reported.

func MouseShow

func MouseShow(show bool)

MouseShow shows or hides the (system) mouse cursor

func MouseWarp

func MouseWarp(x, y int16)

MouseWarp moves the (system) mouse cursor in the window

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 SDLQuit

func SDLQuit()

SDLQuit is called when the game loop stops.

func SetFullscreen

func SetFullscreen(f bool)

func SetWindowTitle

func SetWindowTitle(title string)

func Setup

func Setup() error

func SwapWindow

func SwapWindow()

SwapWindow swaps the double-buffer.

func ToggleFullscreen

func ToggleFullscreen()

func Wrap

func Wrap(context string, err error) error

Wrap returns nil if err is nil, or a wrapped error otherwise.

Types

type GameLoop

type GameLoop interface {
	Enter()
	Leave()

	React()
	Update()
	Render()
}

GameLoop (identic to cozely.GameLoop).

var Loop GameLoop

Loop holds the active looper.

Note: The variable is set with cozely.Loop.

type Gamepad

type Gamepad C.SDL_GameController

Gamepad is a pointer to a SDL object.

func GameControllerOpen

func GameControllerOpen(j int) *Gamepad

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

func (*Gamepad) Joystick

func (a *Gamepad) Joystick() *Joystick

func (*Gamepad) Name

func (a *Gamepad) Name() string

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

func KeySearchPositionOf(l KeyLabel) KeyCode

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

func KeyLabelOf(pos KeyCode) KeyLabel

KeyLabelOf returns the key label at the specified position in the current layout.

type WrappedError

type WrappedError struct {
	Context string
	Err     error
}

func (WrappedError) Error

func (e WrappedError) Error() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL