Documentation ¶
Overview ¶
Package paunch is a 2D game engine written in Go.
Index ¶
- Constants
- func Clear() error
- func Collides(collider1, collider2 Collider) bool
- func DisableEffects()
- func SetClearColor(r uint8, g uint8, b uint8)
- func SetNativeWindowSize(nativeWidth, nativeHeight int)
- func SetWindowFullScreen(fullscreen bool)
- func SetWindowNativeMousePos(shouldBeNative bool)
- func SetWindowSize(width, height int)
- func SetWindowTitle(title string)
- func ShouldClose() bool
- func Start() error
- func Stop()
- func UpdateDisplay() error
- func UpdateEvents() error
- func UseEffect(effect *Effect) error
- type Action
- type Axis
- type CharacterEventResponder
- type Collider
- type CollisionEventResponder
- type Direction
- type DrawEventResponder
- type Effect
- func (effect *Effect) SetVariable2f(variable string, val1 float32, val2 float32) error
- func (effect *Effect) SetVariable2i(variable string, val1 int, val2 int) error
- func (effect *Effect) SetVariable3f(variable string, val1 float32, val2 float32, val3 float32) error
- func (effect *Effect) SetVariable3i(variable string, val1 int, val2 int, val3 int) error
- func (effect *Effect) SetVariable4f(variable string, val1 float32, val2 float32, val3 float32, val4 float32) error
- func (effect *Effect) SetVariable4i(variable string, val1 int, val2 int, val3 int, val4 int) error
- func (effect *Effect) SetVariablef(variable string, val float32) error
- func (effect *Effect) SetVariablei(variable string, val int) error
- type EventManager
- func (eventManager *EventManager) Collides(collider Collider) bool
- func (eventManager *EventManager) GetUserEvents(getting bool)
- func (eventManager *EventManager) RunCharacterEvent(character rune)
- func (eventManager *EventManager) RunCollisionEvent()
- func (eventManager *EventManager) RunDrawEvent()
- func (eventManager *EventManager) RunJoystickAxisEvent(device int, value float64)
- func (eventManager *EventManager) RunJoystickButtonEvent(button int, action Action)
- func (eventManager *EventManager) RunKeyEvent(key Key, action Action)
- func (eventManager *EventManager) RunMouseButtonEvent(button MouseButton, action Action, x, y float64)
- func (eventManager *EventManager) RunMouseEnterWindowEvent(x, y float64, entered bool)
- func (eventManager *EventManager) RunMousePositionEvent(x, y float64)
- func (eventManager *EventManager) RunScrollEvent(xOffset, yOffset float64)
- func (eventManager *EventManager) RunTickEvent()
- func (eventManager *EventManager) RunWindowFocusEvent(focused bool)
- func (eventManager *EventManager) RunWindowResizeEvent(width, height int)
- type Font
- type JoystickAxisEventResponder
- type JoystickButtonEventResponder
- type Key
- type KeyboardEventResponder
- type MouseButton
- type MouseButtonEventResponder
- type MouseEnterWindowResponder
- type MousePositionEventResponder
- type Mover
- type OpenGLError
- type Physics
- func (physics *Physics) Accelerate(forceX, forceY float64)
- func (physics *Physics) Acceleration() (float64, float64)
- func (physics *Physics) AddForce(name string, forceX, forceY float64)
- func (physics *Physics) Calculate()
- func (physics *Physics) DeleteForce(name string)
- func (physics *Physics) DisableForce(name string)
- func (physics *Physics) EnableForce(name string)
- func (physics *Physics) Move(x, y float64)
- func (physics *Physics) Position() (x, y float64)
- func (physics *Physics) SetAcceleration(force float64, axis Axis)
- func (physics *Physics) SetFriction(forceX, forceY float64)
- func (physics *Physics) SetMaxAcceleration(force float64, axis Axis)
- func (physics *Physics) SetMinAcceleration(force float64, axis Axis)
- func (physics *Physics) SetPosition(x, y float64)
- type ScrollResponder
- type ShaderType
- type Shape
- type ShapeType
- type Sound
- func (sound *Sound) Channels() uint
- func (sound *Sound) Destroy()
- func (sound *Sound) Frequency() uint
- func (sound *Sound) Gain() float32
- func (sound *Sound) Length() float32
- func (sound *Sound) Offset() float32
- func (sound *Sound) Pause()
- func (sound *Sound) Play()
- func (sound *Sound) Playing() SoundState
- func (sound *Sound) SetGain(gain float32)
- func (sound *Sound) SetLoop(willLoop bool)
- func (sound *Sound) SetOffset(seconds float32)
- func (sound *Sound) SetPitch(pitch float32)
- func (sound *Sound) Size() uint
- func (sound *Sound) Stop()
- type SoundState
- type Sprite
- type Text
- func (text *Text) Draw()
- func (text *Text) Message() string
- func (text *Text) Move(x, y float64)
- func (text *Text) Position() (float64, float64)
- func (text *Text) SetColor(r, g, b, a uint8) error
- func (text *Text) SetMessage(message string) error
- func (text *Text) SetPosition(x, y float64)
- func (text *Text) Size() (float64, float64)
- type TickEventResponder
- type WindowFocusEventResponder
- type WindowResizeEventResponder
Constants ¶
const ( Top = Up Bottom = Down )
Aliases for Direction IDs
const ( Press = Action(glfw.Press) Release = Action(glfw.Release) Hold = Action(glfw.Repeat) )
Action IDs
const ( MouseButton1 = MouseButton(glfw.MouseButton1) MouseButton2 = MouseButton(glfw.MouseButton2) MouseButton3 = MouseButton(glfw.MouseButton3) MouseButton4 = MouseButton(glfw.MouseButton4) MouseButton5 = MouseButton(glfw.MouseButton5) MouseButton6 = MouseButton(glfw.MouseButton6) MouseButton7 = MouseButton(glfw.MouseButton7) MouseButton8 = MouseButton(glfw.MouseButton8) MouseButtonLast = MouseButton(glfw.MouseButtonLast) MouseButtonLeft = MouseButton(glfw.MouseButtonLeft) MouseButtonRight = MouseButton(glfw.MouseButtonRight) MouseButtonMiddle = MouseButton(glfw.MouseButtonMiddle) )
Mouse button IDs
const ( KeyUnknown = Key(glfw.KeyUnknown) KeySpace = Key(glfw.KeySpace) KeyApostrophe = Key(glfw.KeyApostrophe) KeyComma = Key(glfw.KeyComma) KeyMinus = Key(glfw.KeyMinus) KeyPeriod = Key(glfw.KeyPeriod) KeySlash = Key(glfw.KeySlash) Key0 = Key(glfw.Key0) Key1 = Key(glfw.Key1) Key2 = Key(glfw.Key2) Key3 = Key(glfw.Key3) Key4 = Key(glfw.Key4) Key5 = Key(glfw.Key5) Key6 = Key(glfw.Key6) Key7 = Key(glfw.Key7) Key8 = Key(glfw.Key8) Key9 = Key(glfw.Key9) KeySemicolon = Key(glfw.KeySemicolon) KeyEqual = Key(glfw.KeyEqual) KeyA = Key(glfw.KeyA) KeyB = Key(glfw.KeyB) KeyC = Key(glfw.KeyC) KeyD = Key(glfw.KeyD) KeyE = Key(glfw.KeyE) KeyF = Key(glfw.KeyF) KeyG = Key(glfw.KeyG) KeyH = Key(glfw.KeyH) KeyI = Key(glfw.KeyI) KeyJ = Key(glfw.KeyJ) KeyK = Key(glfw.KeyK) KeyL = Key(glfw.KeyL) KeyM = Key(glfw.KeyM) KeyN = Key(glfw.KeyN) KeyO = Key(glfw.KeyO) KeyP = Key(glfw.KeyP) KeyQ = Key(glfw.KeyQ) KeyR = Key(glfw.KeyR) KeyS = Key(glfw.KeyS) KeyT = Key(glfw.KeyT) KeyU = Key(glfw.KeyU) KeyV = Key(glfw.KeyV) KeyW = Key(glfw.KeyW) KeyX = Key(glfw.KeyX) KeyY = Key(glfw.KeyY) KeyZ = Key(glfw.KeyZ) KeyLeftBracket = Key(glfw.KeyLeftBracket) KeyBackslash = Key(glfw.KeyBackslash) KeyRightBracket = Key(glfw.KeyRightBracket) KeyGraveAccent = Key(glfw.KeyGraveAccent) KeyWorld1 = Key(glfw.KeyWorld1) KeyWorld2 = Key(glfw.KeyWorld2) KeyEscape = Key(glfw.KeyEscape) KeyEnter = Key(glfw.KeyEnter) KeyTab = Key(glfw.KeyTab) KeyBackspace = Key(glfw.KeyBackspace) KeyInsert = Key(glfw.KeyInsert) KeyDelete = Key(glfw.KeyDelete) KeyRight = Key(glfw.KeyRight) KeyLeft = Key(glfw.KeyLeft) KeyDown = Key(glfw.KeyDown) KeyUp = Key(glfw.KeyUp) KeyPageUp = Key(glfw.KeyPageUp) KeyPageDown = Key(glfw.KeyPageDown) KeyHome = Key(glfw.KeyHome) KeyEnd = Key(glfw.KeyEnd) KeyCapsLock = Key(glfw.KeyCapsLock) KeyScrollLock = Key(glfw.KeyScrollLock) KeyNumLock = Key(glfw.KeyNumLock) KeyPrKeyScreen = Key(glfw.KeyPrintScreen) KeyPause = Key(glfw.KeyPause) KeyF1 = Key(glfw.KeyF1) KeyF2 = Key(glfw.KeyF2) KeyF3 = Key(glfw.KeyF3) KeyF4 = Key(glfw.KeyF4) KeyF5 = Key(glfw.KeyF5) KeyF6 = Key(glfw.KeyF6) KeyF7 = Key(glfw.KeyF7) KeyF8 = Key(glfw.KeyF8) KeyF9 = Key(glfw.KeyF9) KeyF10 = Key(glfw.KeyF10) KeyF11 = Key(glfw.KeyF11) KeyF12 = Key(glfw.KeyF12) KeyF13 = Key(glfw.KeyF13) KeyF14 = Key(glfw.KeyF14) KeyF15 = Key(glfw.KeyF15) KeyF16 = Key(glfw.KeyF16) KeyF17 = Key(glfw.KeyF17) KeyF18 = Key(glfw.KeyF18) KeyF19 = Key(glfw.KeyF19) KeyF20 = Key(glfw.KeyF20) KeyF21 = Key(glfw.KeyF21) KeyF22 = Key(glfw.KeyF22) KeyF23 = Key(glfw.KeyF23) KeyF24 = Key(glfw.KeyF24) KeyF25 = Key(glfw.KeyF25) KeyKp0 = Key(glfw.KeyKp0) KeyKp1 = Key(glfw.KeyKp1) KeyKp2 = Key(glfw.KeyKp2) KeyKp3 = Key(glfw.KeyKp3) KeyKp4 = Key(glfw.KeyKp4) KeyKp5 = Key(glfw.KeyKp5) KeyKp6 = Key(glfw.KeyKp6) KeyKp7 = Key(glfw.KeyKp7) KeyKp8 = Key(glfw.KeyKp8) KeyKp9 = Key(glfw.KeyKp9) KeyKpDecimal = Key(glfw.KeyKpDecimal) KeyKpDivide = Key(glfw.KeyKpDivide) KeyKpMultiply = Key(glfw.KeyKpMultiply) KeyKpSubtract = Key(glfw.KeyKpSubtract) KeyKpAdd = Key(glfw.KeyKpAdd) KeyKpEnter = Key(glfw.KeyKpEnter) KeyKpEqual = Key(glfw.KeyKpEqual) KeyLeftShift = Key(glfw.KeyLeftShift) KeyLeftControl = Key(glfw.KeyLeftControl) KeyLeftAlt = Key(glfw.KeyLeftAlt) KeyLeftSuper = Key(glfw.KeyLeftSuper) KeyRightShift = Key(glfw.KeyRightShift) KeyRightControl = Key(glfw.KeyRightControl) KeyRightAlt = Key(glfw.KeyRightAlt) KeyRightSuper = Key(glfw.KeyRightSuper) KeyMenu = Key(glfw.KeyMenu) KeyLast = Key(glfw.KeyLast) )
Keyboard key IDs
const ( Initial = SoundState(al.Initial) Playing = SoundState(al.Playing) Paused = SoundState(al.Paused) Stopped = SoundState(al.Stopped) )
Sound state IDs
const ( Vertex = ShaderType(gl.VERTEX_SHADER) Fragment = ShaderType(gl.FRAGMENT_SHADER) )
Shader type IDs
const ( ShapePoints = ShapeType(gl.POINTS) ShapeLines = ShapeType(gl.LINES) ShapeLineStrip = ShapeType(gl.LINE_STRIP) ShapeLineLoop = ShapeType(gl.LINE_LOOP) ShapeTriangles = ShapeType(gl.TRIANGLES) ShapeTriangleStrip = ShapeType(gl.TRIANGLE_STRIP) ShapeTriangleFan = ShapeType(gl.TRIANGLE_FAN) ShapePolygon = ShapeType(gl.POLYGON) )
Shape IDs
Variables ¶
This section is empty.
Functions ¶
func Clear ¶
func Clear() error
Clear clears the pixels on screen. This should probably be called before every new frame.
func SetClearColor ¶
SetClearColor sets the color the screen will become after a call to the Clear function.
func SetNativeWindowSize ¶
func SetNativeWindowSize(nativeWidth, nativeHeight int)
SetNativeWindowSize sets the native width and height of the Paunch window. The native width and height are values representing what size the window must be at for one screen pixel to equal one pixel in your program. If these values are not set, Paunch will make these values equal to the size of the window at the time Start() is called.
func SetWindowFullScreen ¶
func SetWindowFullScreen(fullscreen bool)
SetWindowFullScreen sets whether or not the Paunch window is full screen. The window will not be full screen by default.
func SetWindowNativeMousePos ¶
func SetWindowNativeMousePos(shouldBeNative bool)
SetWindowNativeMousePos changes the behavior of the reported mouse position. If enabled, supplied mouse positions are made relative to the native width and native height of the Window object. This is useful for applications that stretch to larger window sizes, so that mouse position behavior remains the same regardless of window size.
func SetWindowSize ¶
func SetWindowSize(width, height int)
SetWindowSize sets the width and height of the Paunch window. Width and height MUST be set before calling Start(). Any number below zero is not a valid width or height value.
func SetWindowTitle ¶
func SetWindowTitle(title string)
SetWindowTitle sets the title of the Paunch window, which is generally the text that's shown at the top of the window. The default string is empty.
func ShouldClose ¶
func ShouldClose() bool
ShouldClose returns whether or not the user has attempted to close the window. Will always return false if the Window object has not been opened.
func Start ¶
func Start() error
Start starts the Paunch system by opening the window and beginning to recieve input. Some Paunch operations may fail if this function has not yet been called, including all drawing commands.
func UpdateDisplay ¶
func UpdateDisplay() error
UpdateDisplay updates the window to display whatever has been drawn to the framebuffer.
Types ¶
type CharacterEventResponder ¶
type CharacterEventResponder interface {
OnCharacter(character rune)
}
CharacterEventResponder is an interface that requires methods that allow an EventManager to call on the OnCharacter method of an object when the user inputs a valid unicode character. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.
type Collider ¶
type Collider interface { // Move moves the Collider object the specified distance. Move(x, y float64) // SetPosition sets the position of the Collider. SetPosition(x, y float64) // Position returns the x, y coordinates of the Collider object's // current position. Position() (float64, float64) // DistanceToTangentPoint returns the x, y coordinates of the nearest point // tangent to the Collider object. This method is useful for position // correction when objects have sunk into each other. DistanceToTangentPoint(float64, float64, Direction) (float64, float64) // contains filtered or unexported methods }
Collider is an object that represents a shape that can be tested for collision against another Collider.
func NewCollider ¶
NewCollider creates a new Collider object. The supplied coordinates should be in an "x1, y1, x2, y2..." format. Colliders work differently internally depending on the shape the coordinate describes. Collision detection is faster for singular points and bounding boxes than with lines and polygons.
type CollisionEventResponder ¶
type CollisionEventResponder interface { GetColliders() []Collider OnCollision(c1, c2 Collider, culprit interface{}) }
CollisionEventResponder is an interface that requires methods that allow an EventManager to check the object's Collider objects against those of other objects. Objects that implement this interface will automatically be checked when added to an EventManager.
type Direction ¶
type Direction int
Direction corresponds to a directional value.
const ( Up Direction Down Left Right )
Direction IDs
type DrawEventResponder ¶
type DrawEventResponder interface {
OnDraw()
}
DrawEventResponder is an interface that requires methods that allow an EventManager to draw an object at every frame. Objects that implement this interface will be autmatically called on every frame.
type Effect ¶
type Effect struct {
// contains filtered or unexported fields
}
Effect is an object that manages shaders.
func NewEffectFromDirectory ¶
NewEffectFromDirectory creates a new Effect object based on the shader directory given.
func NewEffectFromFiles ¶
NewEffectFromFiles creates a new Effect object based on the shader file names given.
func NewEffectFromStrings ¶
func NewEffectFromStrings(text []string, types []ShaderType) (*Effect, error)
NewEffectFromStrings creates a new Effect object based on the given strings containing GLSL shader script. The types values should correlate with the type of shader the script is describing.
func (*Effect) SetVariable2f ¶
SetVariable2f sets a specified variable to the two supplied integers to be passed into an effect.
func (*Effect) SetVariable2i ¶
SetVariable2i sets a specified variable to the two supplied integers to be passed into an effect.
func (*Effect) SetVariable3f ¶
func (effect *Effect) SetVariable3f(variable string, val1 float32, val2 float32, val3 float32) error
SetVariable3f sets a specified variable to the three supplied integers to be passed into an effect.
func (*Effect) SetVariable3i ¶
SetVariable3i sets a specified variable to the three supplied integers to be passed into an effect.
func (*Effect) SetVariable4f ¶
func (effect *Effect) SetVariable4f(variable string, val1 float32, val2 float32, val3 float32, val4 float32) error
SetVariable4f sets a specified variable to the four supplied integers to be passed into an effect.
func (*Effect) SetVariable4i ¶
SetVariable4i sets a specified variable to the four supplied integers to be passed into an effect.
func (*Effect) SetVariablef ¶
SetVariablef sets a specified variable to the supplied integer to be passed into an effect.
type EventManager ¶
type EventManager struct {
Objects []interface{}
}
EventManager triggers methods with the On- prefix when appropriate given the objects supplied to it.
func NewEventManager ¶
func NewEventManager() *EventManager
NewEventManager creates a new EventManager.
func (*EventManager) Collides ¶
func (eventManager *EventManager) Collides(collider Collider) bool
Collides checks if the supplied Collider collides with any of the EventManager's objects.
func (*EventManager) GetUserEvents ¶
func (eventManager *EventManager) GetUserEvents(getting bool)
GetUserEvents sets whether or not the EventManager object should be recieving user events. The default value is false.
func (*EventManager) RunCharacterEvent ¶
func (eventManager *EventManager) RunCharacterEvent(character rune)
RunCharacterEvent simulates a character event, triggering the expected response from the EventManager's objects.
func (*EventManager) RunCollisionEvent ¶
func (eventManager *EventManager) RunCollisionEvent()
RunCollisionEvent checks for collisions between the EventManager's objects and triggers appropriate methods.
func (*EventManager) RunDrawEvent ¶
func (eventManager *EventManager) RunDrawEvent()
RunDrawEvent runs a draw event, triggering the expected response from the EventManager's objects.
func (*EventManager) RunJoystickAxisEvent ¶
func (eventManager *EventManager) RunJoystickAxisEvent(device int, value float64)
RunJoystickAxisEvent simulates a joystick axis event, triggering the expected response from the EventManager's objects.
func (*EventManager) RunJoystickButtonEvent ¶
func (eventManager *EventManager) RunJoystickButtonEvent(button int, action Action)
RunJoystickButtonEvent simulates a joystick button event, triggering the expected response from the EventManager's objects.
func (*EventManager) RunKeyEvent ¶
func (eventManager *EventManager) RunKeyEvent(key Key, action Action)
RunKeyEvent simulates a key event, triggering the expected response from the EventManager's objects.
func (*EventManager) RunMouseButtonEvent ¶
func (eventManager *EventManager) RunMouseButtonEvent(button MouseButton, action Action, x, y float64)
RunMouseButtonEvent simulates a mouse button event, triggering the expected response from the EventManager's objects.
func (*EventManager) RunMouseEnterWindowEvent ¶
func (eventManager *EventManager) RunMouseEnterWindowEvent(x, y float64, entered bool)
RunMouseEnterWindowEvent simulates a mouse enter window event, triggering the expected response from the EventManager's objects.
func (*EventManager) RunMousePositionEvent ¶
func (eventManager *EventManager) RunMousePositionEvent(x, y float64)
RunMousePositionEvent simulates a mouse position event, triggering the expected response from the EventManager's objects.
func (*EventManager) RunScrollEvent ¶
func (eventManager *EventManager) RunScrollEvent(xOffset, yOffset float64)
func (*EventManager) RunTickEvent ¶
func (eventManager *EventManager) RunTickEvent()
RunTickEvent runs a tick event, triggering the expected response from the EventManager's objects.
func (*EventManager) RunWindowFocusEvent ¶
func (eventManager *EventManager) RunWindowFocusEvent(focused bool)
RunWindowFocusEvent simulates a window focus event, triggering the expected response from the EventManager's objects.
func (*EventManager) RunWindowResizeEvent ¶
func (eventManager *EventManager) RunWindowResizeEvent(width, height int)
RunWindowResizeEvent simulates a window resize event, triggering the expected response from the EventManager's objects.
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
Font represents a font file. Most common font files are supported.
type JoystickAxisEventResponder ¶
JoystickAxisEventResponder is an interface that requires methods that allow an EventManager to call on the OnJoystickAxis method of an object when the user has at least on analog device on their joystick. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.
type JoystickButtonEventResponder ¶
JoystickButtonEventResponder is an interface that requires methods that allow an EventManager to call on the OnJoystickButton method of an object when the user presses, holds, or releases a joystick button. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.
type KeyboardEventResponder ¶
KeyboardEventResponder is an interface that requires methods that allow an EventManager to call the OnKeyboard method of an object when a keyboard event happens. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.
type MouseButtonEventResponder ¶
type MouseButtonEventResponder interface {
OnMouseButton(button MouseButton, action Action, x, y float64)
}
MouseButtonEventResponder is an interface that requires methods that allow an EventManager to call the OnMouseButton method of an object when a mouse button event happens. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.
type MouseEnterWindowResponder ¶
MouseEnterWindowResponder is an interface that requires methods that allow an EventManager to call on the OnMouseEnterWindow method of an object when a mouse enters or leaves a window. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.
type MousePositionEventResponder ¶
type MousePositionEventResponder interface {
OnMousePosition(x, y float64)
}
MousePositionEventResponder is an interface that requires methods that allow an EventManager to call the OnMousePosition method of an object when a mouse position event happens. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.
type OpenGLError ¶
OpenGLError is an error-implementing object describing sets of OpenGL errors.
func (OpenGLError) Error ¶
func (err OpenGLError) Error() string
Error returns a descriptive string.
type Physics ¶
type Physics struct { Movers []Mover // contains filtered or unexported fields }
Physics is an object meant to make the Movement of multiple related Movers, such as a Renderable and a Collision, easier. It also allows for easy management of multiple forces of Movement at once.
func (*Physics) Accelerate ¶
Accelerate exerts a specified force upon the Physics object the next time the Calculate method is called.
func (*Physics) Acceleration ¶
Acceleration returns the X and Y acceleration of the Physics object.
func (*Physics) AddForce ¶
AddForce adds a constant force to the Physics object, which is taken into account every time the Calculate method is called. The force is disabled by default.
func (*Physics) Calculate ¶
func (physics *Physics) Calculate()
Calculate Moves the Physics object given any specified constant forces, calls to the Accelerate method, and any leftover acceleration. Then, friction is applied to the resulting acceleration value.
func (*Physics) DeleteForce ¶
DeleteForce reMoves a constant force from the Physics object.
func (*Physics) DisableForce ¶
DisableForce makes the specified force inactive for future calls to the Calculate method.
func (*Physics) EnableForce ¶
EnableForce makes the specified force active for future calls to the Calculate method.
func (*Physics) SetAcceleration ¶
SetAcceleration sets the acceleration of the Physics object on the specified axis.
func (*Physics) SetFriction ¶
SetFriction sets the friction value of the Physics object. Friction is a force that enfluences acceleration to Move toward zero. This might be used to simulate the natural slowdown of an object rubbing against a surface.
func (*Physics) SetMaxAcceleration ¶
SetMaxAcceleration sets the maximum allowed acceleration of the Physics object on the specified axis. In situations where the object would normally go faster than the specified value, it will be set to the value instead.
func (*Physics) SetMinAcceleration ¶
SetMinAcceleration sets the minimum allowed acceleration of the Physics object on the specified axis. In situations where the object would normally go slower than the specified value, it will be set to the value instead.
func (*Physics) SetPosition ¶
SetPosition sets the position of the Physics object relative to the Physics object's first Mover.
type ScrollResponder ¶
type ScrollResponder interface {
OnScroll(xOffset, yOffset float64)
}
ScrollResponder is an interface that requires methods that allow an EventManager to call the OnScroll method of an object when a scrolling event happens. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.
type Shape ¶
type Shape struct {
// contains filtered or unexported fields
}
Shape is an object that represents a vector shape, such as a triangle or other polygon, that can be drawn on screen.
func NewShapeFromShape ¶
NewShapeFromShape creates a copy of an existing Shape object.
func (*Shape) Position ¶
Position returns the X and Y position relative to the first specified vertex.
func (*Shape) SetPosition ¶
SetPosition sets the position of the Shape object relative to first specified vertex.
func (*Shape) SetScaling ¶
SetScaling sets the scaling factor of the Shape object. For instance, an x and y scale value of two will make the Shape object twice as large.
type Sound ¶
Sound represents a playable sound clip.
func NewSound ¶
NewSound returns a new Sound object based on the provided file. As of right now, NewSound only supports standard WAV files.
func (*Sound) Destroy ¶
func (sound *Sound) Destroy()
Destroy cleans up the Sound object, which will no longer be playable. This should be done after the Sound object is no longer needed.
func (*Sound) Pause ¶
func (sound *Sound) Pause()
Pause pauses the Sound object at it's current time. The Play method will resume from where the Pause method left off.
func (*Sound) Play ¶
func (sound *Sound) Play()
Play plays the Sound object from it's current time. If the Sound has never been played, that time will be at the beginning.
func (*Sound) Playing ¶
func (sound *Sound) Playing() SoundState
Playing returns a SoundState value reflecting the playing state of the Sound object.
func (*Sound) SetLoop ¶
SetLoop sets whether or not the Sound object should loop at the end of it's sample. The default value is false.
func (*Sound) SetPitch ¶
SetPitch sets the pitch modulation of the Sound object. 1 is the default value. A reduction in pitch by half is equal to lowering the sound by one octave, and vice versa when doubling pitch.
type SoundState ¶
type SoundState int
SoundState is a value that can be retured by Sound.GetPlaying().
type Sprite ¶
type Sprite struct {
// contains filtered or unexported fields
}
Sprite is a textured object, an object that is displayed on the screen using image data.
func NewSprite ¶
NewSprite creates a new Sprite object using the given data, which is expected to be in RGBA format. If you use PNG image files, you can use the NewSpriteFromImage shortcut function instead.
func NewSpriteFromImage ¶
NewSpriteFromImage creates a new Sprite object using the given PNG image file.
func NewSpriteFromSprite ¶
NewSpriteFromSprite creates a new Sprite object that uses the same image data as the supplied Sprite object. This can serve to save a lot of GPU memory when dealing with Sprite objects that use image data.
func (*Sprite) Position ¶
Position returns the X and Y position of the bottom-left corner of the Sprite object.
func (*Sprite) SetPosition ¶
SetPosition sets the position of the Sprite object relative to the bottom- left corner.
func (*Sprite) SetScaling ¶
SetScaling sets the scaling factor of the Sprite object. For instance, an x and y scale value of two will make the Sprite object twice as large.
type Text ¶
type Text struct {
// contains filtered or unexported fields
}
Text is an object that represents drawable text.
func NewText ¶
NewText creates a new Text object. The x and y positions represent the left and bottom of text without tails.
func (*Text) SetColor ¶
SetColor sets the color of the Text object. The default is black (0, 0, 0, 255).
func (*Text) SetMessage ¶
SetMessage changes the message displayed by the Text object.
func (*Text) SetPosition ¶
SetPosition sets the Text object's position to the specified point.
type TickEventResponder ¶
type TickEventResponder interface {
OnTick()
}
TickEventResponder is an interface that requires methods that allow an EventManager to call on the OnTick method with every tick of the EventManager. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.
type WindowFocusEventResponder ¶
type WindowFocusEventResponder interface {
OnWindowFocus(focused bool)
}
WindowFocusEventResponder is an interface that requires methods that allow an EventManager to call on the OnWindowFocus method of an object when the user changes the focus of a window. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.
type WindowResizeEventResponder ¶
type WindowResizeEventResponder interface {
OnWindowResize(width, height int)
}
WindowResizeEventResponder is an interface that requires methods that allow an EventManager to call on the OnWindowResize method of an object when the user changes the size of a window. Objects that implement this interface will automatically be called when appropriate after being added to an EventManager.