Documentation ¶
Index ¶
- type App
- func (app *App) AddWindowFlags(flags ...WindowFlag) *App
- func (app *App) After(seconds float64, afterFunction CronFunc)
- func (app *App) AreKeysDown(keys ...Key) bool
- func (app *App) Circle(position Vec2, radius float64, color color.RGBA, filled, hasAA bool) *Entity
- func (app *App) Close()
- func (app *App) DrawEntity(entity *Entity) error
- func (app *App) DrawFrame() error
- func (app *App) Entity(position Vec2) *Entity
- func (app *App) Every(seconds float64, everyFunc CronFunc)
- func (app *App) FillScreen(r, g, b, a uint8)
- func (app *App) FreeSprite(sprite *Sprite)
- func (app *App) FreeSprites() int
- func (app *App) GetClipboard() string
- func (app *App) GetFPS() float64
- func (app *App) GetMousePos() (int, int)
- func (app *App) GetWindowSize() (int32, int32)
- func (app *App) IsKeyDown(key Key) bool
- func (app *App) IsKeyJustDown(key Key) bool
- func (app *App) IsKeyJustUp(key Key) bool
- func (app *App) IsMouseButtonDown(button MouseButton) bool
- func (app *App) IsMouseButtonJustDown(button MouseButton) bool
- func (app *App) IsMouseButtonJustUp(button MouseButton) bool
- func (app *App) IsSpriteInUse(sprite *Sprite, exclude *Entity) bool
- func (app *App) Line(start, end Vec2, color color.RGBA, hasAA bool) *Entity
- func (app *App) LoadAudio(readCloser io.ReadCloser, inputFormat AudioFormat) (*Audio, error)
- func (app *App) LoadAudioFromData(data []byte, inputFormat AudioFormat) (*Audio, error)
- func (app *App) LoadAudioFromReader(reader io.Reader, inputFormat AudioFormat) (*Audio, error)
- func (app *App) LoadFont(path string, size int) (*Font, error)
- func (app *App) LoadFontFromData(data []byte, size int) (*Font, error)
- func (app *App) LoadFontFromReader(reader io.Reader, size int) (*Font, error)
- func (app *App) NewSpriteFromData(data []byte) (*Sprite, error)
- func (app *App) NewSpriteFromPath(path string) (*Sprite, error)
- func (app *App) NewSpriteFromReader(reader io.Reader) (*Sprite, error)
- func (app *App) NewSpriteFromSurface(surface *sdl.Surface) (*Sprite, error)
- func (app *App) Polygon(point1, point2, point3 Vec2, color color.RGBA, filled bool, hasAA bool) *Entity
- func (app *App) Rect(position Vec2, w, h float64, color color.RGBA, isFilled bool) *Entity
- func (app *App) Run() error
- func (app *App) SetAudioBufferNs(nanoseconds int64) *App
- func (app *App) SetAudioSampleRate(sampleRate int) *App
- func (app *App) SetClipboard(text string) error
- func (app *App) SetCloseFunc(newFunc OnCloseFunc) *App
- func (app *App) SetKeyEventFunc(newFunc OnKeyEventFunc) *App
- func (app *App) SetPixel(x, y int32, color color.RGBA)
- func (app *App) SetPostRenderFunc(newFunc PostRenderFunc) *App
- func (app *App) SetSwapInterval(interval int) error
- func (app *App) SetUpdateFunc(newFunc UpdateFunc) *App
- func (app *App) SetWindowFlags(flags ...WindowFlag) *App
- func (app *App) SetWindowSize(width, height int32) *App
- func (app *App) SetWindowTitle(title string) *App
- func (app *App) StopAudio() *App
- func (app *App) UnloadFontLibrary()
- type Audio
- type AudioFormat
- type BlendMode
- type ButtonInfo
- type Camera
- type CircleShape
- type CollisionInfo
- type CronFunc
- type Entity
- func (entity *Entity) CanCollide(state bool) *Entity
- func (entity *Entity) Collide() CollisionInfo
- func (entity *Entity) Destroy()
- func (entity *Entity) FlipHorizontal() *Entity
- func (entity *Entity) FlipNone() *Entity
- func (entity *Entity) FlipToggle(flip FlipDirection) *Entity
- func (entity *Entity) FlipVertical() *Entity
- func (entity *Entity) ParentTo(parent *Entity) *Entity
- func (entity *Entity) RemoveParent() *Entity
- func (entity *Entity) SetAngle(angle float64) *Entity
- func (entity *Entity) SetColor(color color.RGBA) *Entity
- func (entity *Entity) SetFlip(flip FlipDirection) *Entity
- func (entity *Entity) SetOpacity(opacity float64) *Entity
- func (entity *Entity) SetPivot(pivot Vec2) *Entity
- func (entity *Entity) SetPivotCentered(state bool) *Entity
- func (entity *Entity) SetScale(scale Vec2) *Entity
- func (entity *Entity) SetTexture(sprite *Sprite) *Entity
- func (entity *Entity) SetUpdateFunc(updateFunc EntityUpdateFunc) *Entity
- type EntityUpdateFunc
- type FlipDirection
- type Font
- type Key
- type KeyDirection
- type Line
- type MouseButton
- type OnCloseFunc
- type OnKeyEventFunc
- type Polygon
- type PostRenderFunc
- type QueuedFunc
- type Rectangle
- type Scene
- type Shape
- type Sprite
- type UpdateFunc
- type Vec2
- type WindowFlag
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct { Title string // Window title. Width int32 // Window width. Height int32 // Window height. Update UpdateFunc // Will be called every frame, receives the delta time in seconds. PostRender PostRenderFunc // Will be called after the rendering of all entities on a frame. OnClose OnCloseFunc // Will be called when the window should be closed. Should return whether the window should close or not. IgnoreClose bool // Specifies if the window should ignore quit events. Running bool // Specifies if the app is running or not. WindowFlags []WindowFlag // Window flags. DoClear bool // Do clear the previous frame before drawing the new frame? ClearColor color.RGBA // The color to clear the background of the new frame. Window *sdl.Window // SDL window. Time float64 // The amount of seconds since the app has started. PreviousFrameTime float64 // The time of the previous frame. DeltaTime float64 // The duration between two frames (delta time). SwapInterval int // OpenGL swap interval. Default: 1 (vsync). QueuedFunctions []*QueuedFunc // All functions that are queued to be called. Scene *Scene // The main scene of the app. Renderer *sdl.Renderer // SDL renderer. LoadedSprites []*Sprite // All loaded sprites. Camera *Camera // The main camera. ScaleQuality int // SDL scale quality. HeldKeys []Key // All keys that are currently held. Call app.IsKeyDown if you want to see if a key is down. JustDownKeys []Key // All keys that were pressed on this frame. JustUpKeys []Key // All keys that were released on this frame. OnKeyEvent OnKeyEventFunc // Function that is called when a key is down or up. DownMouseButtons []ButtonInfo // Pressed mouse buttons information. JustDownMouseButtons []ButtonInfo // Mouse buttons pressed on this frame information. JustUpMouseButtons []ButtonInfo // Mouse buttons released on this frame information. ScrollDeltaX float32 // Scrollwheel X delta. ScrollDeltaY float32 // Scrollwheel Y delta. IsScrolling bool // Is the mouse scrolling? SampleRate int // Audio sample rate (default: 44100). ResamplingQuality int // 1: high performance, low quality; 3-4: balanced (recommended); 6: high CPU usage; >6 super high CPU usage (default: 4) BufferNs int64 // The buffer size in nanoseconds (default: 48000000 (48ms)). }
func (*App) AddWindowFlags ¶
func (app *App) AddWindowFlags(flags ...WindowFlag) *App
Adds window flags. Default flags: WINDOW_SHOWN, WINDOW_OPENGL.
func (*App) After ¶
Runs a function after a specified amount of seconds. This is not precise, the functions are updated every frame. This will only start counting after app.Run has been called. The function receives the application it has been called from.
func (*App) AreKeysDown ¶
Checks if all passed keys are currently pressed.
func (*App) Circle ¶
Creates a new circle. radius: the radius of the circle. filled: specifies whether the circle is filled. hasAA: specifies whether the circle has antialiasing.
func (*App) Close ¶
func (app *App) Close()
Closes the window. This will work even if app.IgnoreClose is true.
func (*App) DrawEntity ¶
Blits an entity to the screen.
func (*App) FillScreen ¶
Fills the entire screen with an RGBA color.
func (*App) FreeSprite ¶
func (*App) FreeSprites ¶
Frees all loaded sprites. Returns the amount of free'd sprites.
func (*App) GetClipboard ¶
Returns the text in the OS clipboard.
func (*App) GetMousePos ¶
Get the mouse X and Y coordinates on screen.
func (*App) GetWindowSize ¶
Sets the window width and height.
func (*App) IsKeyJustDown ¶
Checks if a key was pressed on this frame.
func (*App) IsKeyJustUp ¶
Checks if a key was released on this frame.
func (*App) IsMouseButtonDown ¶
func (app *App) IsMouseButtonDown(button MouseButton) bool
Checks if a mouse button is currently pressed.
func (*App) IsMouseButtonJustDown ¶
func (app *App) IsMouseButtonJustDown(button MouseButton) bool
Checks if a mouse button is pressed on this frame.
func (*App) IsMouseButtonJustUp ¶
func (app *App) IsMouseButtonJustUp(button MouseButton) bool
Checks if a mouse button is released on this frame.
func (*App) LoadAudio ¶
func (app *App) LoadAudio(readCloser io.ReadCloser, inputFormat AudioFormat) (*Audio, error)
Loads an audio file from a ReadCloser. If the audio sample rate doesn't match the configured app sample rate, the file will be resampled.
func (*App) LoadAudioFromData ¶
func (app *App) LoadAudioFromData(data []byte, inputFormat AudioFormat) (*Audio, error)
Loads audio from bytes.
func (*App) LoadAudioFromReader ¶
func (*App) LoadFontFromData ¶
Loads a font from bytes.
func (*App) LoadFontFromReader ¶
func (*App) NewSpriteFromData ¶
Creates a new sprite from bytes.
func (*App) NewSpriteFromPath ¶
Loads a new sprite from path. This uses the file extension to identify the format.
func (*App) NewSpriteFromReader ¶
Creates a new sprite from a reader.
func (*App) NewSpriteFromSurface ¶
Creates a new sprite from an SDL surface.
func (*App) SetAudioBufferNs ¶
Sets the amount of nanoseconds in the audio buffer. Default: 48000000 (48ms)
func (*App) SetAudioSampleRate ¶
Sets the sample rate of the audio. Default: 44100.
func (*App) SetClipboard ¶
Sets text in the OS clipboard.
func (*App) SetCloseFunc ¶
func (app *App) SetCloseFunc(newFunc OnCloseFunc) *App
Sets the close function (called before the window closes).
func (*App) SetKeyEventFunc ¶
func (app *App) SetKeyEventFunc(newFunc OnKeyEventFunc) *App
Sets the post render function (called when the frame is finished rendering).
func (*App) SetPostRenderFunc ¶
func (app *App) SetPostRenderFunc(newFunc PostRenderFunc) *App
Sets the post render function (called when the frame is finished rendering).
func (*App) SetSwapInterval ¶
Sets the OpenGL swap interval.
func (*App) SetUpdateFunc ¶
func (app *App) SetUpdateFunc(newFunc UpdateFunc) *App
Sets the update function (called every frame).
func (*App) SetWindowFlags ¶
func (app *App) SetWindowFlags(flags ...WindowFlag) *App
Sets window flags. Default flags: WINDOW_SHOWN, WINDOW_OPENGL.
func (*App) SetWindowSize ¶
Sets the window width and height.
func (*App) SetWindowTitle ¶
Sets the title of the window.
func (*App) UnloadFontLibrary ¶
func (app *App) UnloadFontLibrary()
type Audio ¶
type Audio struct { Buffer *beep.Buffer // Audio buffer. LastPlayed float64 // The time when the audio was last played. // Volume of the audio. Use SetVolume to change the volume. // The volume is applied exponentially. Volume of 0 means no change. // Set Silent if you want to make the audio silent. Volume float64 // Natural Base for the volume exponentiation. The default is 2. // In order to adjust volume along decibells, pick 10 as the Base and set Volume to dB/10. Base float64 Silent bool // Specifies whether the audio should be silent. // contains filtered or unexported fields }
type AudioFormat ¶
type AudioFormat int
const ( AUDIO_MP3 AudioFormat = 0 // .mp3 files. AUDIO_FLAC AudioFormat = 1 // .flac files. AUDIO_WAV AudioFormat = 2 // .wav files. AUDIO_OGG AudioFormat = 3 // .ogg files. AUDIO_MOD AudioFormat = 4 // .mod files. )
type BlendMode ¶
type BlendMode int
Blend modes.
const ( BLENDMODE_NONE BlendMode = sdl.BLENDMODE_NONE // No blending. BLENDMODE_BLEND BlendMode = sdl.BLENDMODE_BLEND // Alpha blending. BLENDMODE_ADD BlendMode = sdl.BLENDMODE_ADD // Additive blending. BLENDMODE_MOD BlendMode = sdl.BLENDMODE_MOD // Color modulate. )
type ButtonInfo ¶
type ButtonInfo struct { MouseID uint32 // The ID of the mouse. Button MouseButton // The mouse button that is pressed. Clicks int // The amount of times the button has been clicked in a row (max: 255). }
type Camera ¶
type Camera struct { Position Vec2 // World position of the camera. Zoom float64 // Bigger value = bigger objects. Default: 1. }
func (*Camera) SetPosition ¶
Set the world position of the camera.
type CircleShape ¶
type CircleShape struct { HasAA bool // Is the circle antialiased? Filled bool // Is the circle filled? Radius float64 // contains filtered or unexported fields }
func (*CircleShape) Draw ¶
func (circle *CircleShape) Draw()
type CollisionInfo ¶
type CollisionInfo struct { ForwardPushX float64 // The amount to add to the X position to push the entity out of the collision to the forward. BackwardPushX float64 // The amount to add to the X position to push the entity out of the collision to the backward. TopPushY float64 // The amount to add to the Y position to push the entity out of the collision to the top. BottomPushY float64 // The amount to add to the Y position to push the entity out of the collision to the bottom. IsFalling bool // This is true if the entity isn't being pushed to the top. Entity *Entity // The entity this collision happened with. }
type CronFunc ¶
type CronFunc func(app *App)
This function receives the application it has been called from.
type Entity ¶
type Entity struct { Position Vec2 // The world position of the entity. Scene *Scene // The scene this entity is in. Texture *Sprite // The texture (sprite) of the entity. Shape Shape // The shape of the entity. This is ignored if a texture is set. Color color.RGBA // The color of the entity. This is ignored if a texture is set. Scale Vec2 // X and Y scale of the entity. Opacity float64 // Opacity of the entity between 0 and 1. Visible bool // Specifies if the entity should be rendered or not. Angle float64 // Rotation angle. Pivot Vec2 // Rotation pivot point. This is 0,0 by default. IsPivotCentered bool // Should the pivot point be centered? FlipDir FlipDirection // The flip direction of the texture. Default: FLIP_NONE. Width float64 // Width of the texture or shape. Height float64 // Height of the texture or shape. DoCollide bool // Can this entity collide with other entities? UpdateFunc EntityUpdateFunc // This function will be called before drawing the entity. Parent *Entity // The parent of this entity. // contains filtered or unexported fields }
func (*Entity) CanCollide ¶
Specifies whether the entity can collide with other entities or not.
func (*Entity) Collide ¶
func (entity *Entity) Collide() CollisionInfo
Checks collision with other entites. This feature is still experimental. Suitable for platformer games.
func (*Entity) Destroy ¶
func (entity *Entity) Destroy()
Removes this entity from the scene. This does not free the sprite
func (*Entity) FlipHorizontal ¶
Horizontally flips the texture of the entity.
func (*Entity) FlipToggle ¶
func (entity *Entity) FlipToggle(flip FlipDirection) *Entity
"Toggles" a flip direction of the entity.
func (*Entity) FlipVertical ¶
Vertically flips the texture of the entity.
func (*Entity) ParentTo ¶
Parents this entity to an another entity. Children will follow the parent's position.
func (*Entity) SetColor ¶
Sets the color of the entity. The color is ignored if the entity has a texture.
func (*Entity) SetFlip ¶
func (entity *Entity) SetFlip(flip FlipDirection) *Entity
Sets the flip direction of the entity.
func (*Entity) SetOpacity ¶
Sets the opacity of the entity. The opacity is a value from 0 to 1.
func (*Entity) SetPivotCentered ¶
Set the pivot point to be centered.
func (*Entity) SetTexture ¶
Sets the texture of the entity. If you don't need the old texture anymore, remember to free it with app.FreeSprite().
func (*Entity) SetUpdateFunc ¶
func (entity *Entity) SetUpdateFunc(updateFunc EntityUpdateFunc) *Entity
Sets the entity update function. It will be called every time before it gets drawn.
type EntityUpdateFunc ¶
type FlipDirection ¶
type FlipDirection int
const ( FLIP_NONE FlipDirection = 0 FLIP_HORIZONTAL FlipDirection = 1 FLIP_VERTICAL FlipDirection = 2 )
type Font ¶
type Font struct { Data *ttf.Font // SDL font data. Size int // Font size. WrapLength int // Wrap length, negative values = no wrap (default: -1) // contains filtered or unexported fields }
func (*Font) RenderString ¶
Renders a string to a sprite. You can use this to set the entity's texture.
type Key ¶
type Key int // Key.
Keyboard keys.
const ( KEY_UNKNOWN Key = sdl.K_UNKNOWN // "" (no name, empty string) KEY_RETURN Key = sdl.K_RETURN // "Return" (the Enter key (main keyboard)) KEY_ESCAPE Key = sdl.K_ESCAPE // "Escape" (the Esc key) KEY_BACKSPACE Key = sdl.K_BACKSPACE // "Backspace" KEY_TAB Key = sdl.K_TAB // "Tab" (the Tab key) KEY_SPACE Key = sdl.K_SPACE // "Space" (the Space Bar key(s)) KEY_EXCLAIM Key = sdl.K_EXCLAIM // "!" KEY_QUOTEDBL Key = sdl.K_QUOTEDBL // """ KEY_HASH Key = sdl.K_HASH // "#" KEY_PERCENT Key = sdl.K_PERCENT // "%" KEY_DOLLAR Key = sdl.K_DOLLAR // "$" KEY_AMPERSAND Key = sdl.K_AMPERSAND // "&" KEY_QUOTE Key = sdl.K_QUOTE // "'" KEY_LEFTPAREN Key = sdl.K_LEFTPAREN // "(" KEY_RIGHTPAREN Key = sdl.K_RIGHTPAREN // ")" KEY_ASTERISK Key = sdl.K_ASTERISK // "*" KEY_PLUS Key = sdl.K_PLUS // "+" KEY_COMMA Key = sdl.K_COMMA // "," KEY_MINUS Key = sdl.K_MINUS // "-" KEY_PERIOD Key = sdl.K_PERIOD // "." KEY_SLASH Key = sdl.K_SLASH // "/" KEY_0 Key = sdl.K_0 // "0" KEY_1 Key = sdl.K_1 // "1" KEY_2 Key = sdl.K_2 // "2" KEY_3 Key = sdl.K_3 // "3" KEY_4 Key = sdl.K_4 // "4" KEY_5 Key = sdl.K_5 // "5" KEY_6 Key = sdl.K_6 // "6" KEY_7 Key = sdl.K_7 // "7" KEY_8 Key = sdl.K_8 // "8" KEY_9 Key = sdl.K_9 // "9" KEY_COLON Key = sdl.K_COLON // ":" KEY_SEMICOLON Key = sdl.K_SEMICOLON // ";" KEY_LESS Key = sdl.K_LESS // "<" KEY_EQUALS Key = sdl.K_EQUALS // "=" KEY_GREATER Key = sdl.K_GREATER // ">" KEY_QUESTION Key = sdl.K_QUESTION // "?" KEY_AT Key = sdl.K_AT // "@" KEY_LEFTBRACKET Key = sdl.K_LEFTBRACKET // "[" KEY_BACKSLASH Key = sdl.K_BACKSLASH // "\" KEY_RIGHTBRACKET Key = sdl.K_RIGHTBRACKET // "]" KEY_CARET Key = sdl.K_CARET // "^" KEY_UNDERSCORE Key = sdl.K_UNDERSCORE // "_" KEY_BACKQUOTE Key = sdl.K_BACKQUOTE // "`" KEY_a Key = sdl.K_a // "A" KEY_b Key = sdl.K_b // "B" KEY_c Key = sdl.K_c // "C" KEY_d Key = sdl.K_d // "D" KEY_e Key = sdl.K_e // "E" KEY_f Key = sdl.K_f // "F" KEY_g Key = sdl.K_g // "G" KEY_h Key = sdl.K_h // "H" KEY_i Key = sdl.K_i // "I" KEY_j Key = sdl.K_j // "J" KEY_k Key = sdl.K_k // "K" KEY_l Key = sdl.K_l // "L" KEY_m Key = sdl.K_m // "M" KEY_n Key = sdl.K_n // "N" KEY_o Key = sdl.K_o // "O" KEY_p Key = sdl.K_p // "P" KEY_q Key = sdl.K_q // "Q" KEY_r Key = sdl.K_r // "R" KEY_s Key = sdl.K_s // "S" KEY_t Key = sdl.K_t // "T" KEY_u Key = sdl.K_u // "U" KEY_v Key = sdl.K_v // "V" KEY_w Key = sdl.K_w // "W" KEY_x Key = sdl.K_x // "X" KEY_y Key = sdl.K_y // "Y" KEY_z Key = sdl.K_z // "Z" KEY_CAPSLOCK Key = sdl.K_CAPSLOCK // "CapsLock" KEY_F1 Key = sdl.K_F1 // "F1" KEY_F2 Key = sdl.K_F2 // "F2" KEY_F3 Key = sdl.K_F3 // "F3" KEY_F4 Key = sdl.K_F4 // "F4" KEY_F5 Key = sdl.K_F5 // "F5" KEY_F6 Key = sdl.K_F6 // "F6" KEY_F7 Key = sdl.K_F7 // "F7" KEY_F8 Key = sdl.K_F8 // "F8" KEY_F9 Key = sdl.K_F9 // "F9" KEY_F10 Key = sdl.K_F10 // "F10" KEY_F11 Key = sdl.K_F11 // "F11" KEY_F12 Key = sdl.K_F12 // "F12" KEY_PRINTSCREEN Key = sdl.K_PRINTSCREEN // "PrintScreen" KEY_SCROLLLOCK Key = sdl.K_SCROLLLOCK // "ScrollLock" KEY_PAUSE Key = sdl.K_PAUSE // "Pause" (the Pause / Break key) KEY_INSERT Key = sdl.K_INSERT // "Insert" (insert on PC, help on some Mac keyboards (but does send code 73, not 117)) KEY_HOME Key = sdl.K_HOME // "Home" KEY_PAGEUP Key = sdl.K_PAGEUP // "PageUp" KEY_DELETE Key = sdl.K_DELETE // "Delete" KEY_END Key = sdl.K_END // "End" KEY_PAGEDOWN Key = sdl.K_PAGEDOWN // "PageDown" KEY_RIGHT Key = sdl.K_RIGHT // "Right" (the Right arrow key (navigation keypad)) KEY_LEFT Key = sdl.K_LEFT // "Left" (the Left arrow key (navigation keypad)) KEY_DOWN Key = sdl.K_DOWN // "Down" (the Down arrow key (navigation keypad)) KEY_UP Key = sdl.K_UP // "Up" (the Up arrow key (navigation keypad)) KEY_NUMLOCKCLEAR Key = sdl.K_NUMLOCKCLEAR // "Numlock" (the Num Lock key (PC) / the Clear key (Mac)) KEY_KP_DIVIDE Key = sdl.K_KP_DIVIDE // "Keypad /" (the / key (numeric keypad)) KEY_KP_MULTIPLY Key = sdl.K_KP_MULTIPLY // "Keypad *" (the * key (numeric keypad)) KEY_KP_MINUS Key = sdl.K_KP_MINUS // "Keypad -" (the - key (numeric keypad)) KEY_KP_PLUS Key = sdl.K_KP_PLUS // "Keypad +" (the + key (numeric keypad)) KEY_KP_ENTER Key = sdl.K_KP_ENTER // "Keypad Enter" (the Enter key (numeric keypad)) KEY_KP_1 Key = sdl.K_KP_1 // "Keypad 1" (the 1 key (numeric keypad)) KEY_KP_2 Key = sdl.K_KP_2 // "Keypad 2" (the 2 key (numeric keypad)) KEY_KP_3 Key = sdl.K_KP_3 // "Keypad 3" (the 3 key (numeric keypad)) KEY_KP_4 Key = sdl.K_KP_4 // "Keypad 4" (the 4 key (numeric keypad)) KEY_KP_5 Key = sdl.K_KP_5 // "Keypad 5" (the 5 key (numeric keypad)) KEY_KP_6 Key = sdl.K_KP_6 // "Keypad 6" (the 6 key (numeric keypad)) KEY_KP_7 Key = sdl.K_KP_7 // "Keypad 7" (the 7 key (numeric keypad)) KEY_KP_8 Key = sdl.K_KP_8 // "Keypad 8" (the 8 key (numeric keypad)) KEY_KP_9 Key = sdl.K_KP_9 // "Keypad 9" (the 9 key (numeric keypad)) KEY_KP_0 Key = sdl.K_KP_0 // "Keypad 0" (the 0 key (numeric keypad)) KEY_KP_PERIOD Key = sdl.K_KP_PERIOD // "Keypad ." (the . key (numeric keypad)) KEY_APPLICATION Key = sdl.K_APPLICATION // "Application" (the Application / Compose / Context Menu (Windows) key) KEY_POWER Key = sdl.K_POWER // "Power" (The USB document says this is a status flag, not a physical key - but some Mac keyboards do have a power key.) KEY_KP_EQUALS Key = sdl.K_KP_EQUALS // "Keypad =" (the = key (numeric keypad)) KEY_F13 Key = sdl.K_F13 // "F13" KEY_F14 Key = sdl.K_F14 // "F14" KEY_F15 Key = sdl.K_F15 // "F15" KEY_F16 Key = sdl.K_F16 // "F16" KEY_F17 Key = sdl.K_F17 // "F17" KEY_F18 Key = sdl.K_F18 // "F18" KEY_F19 Key = sdl.K_F19 // "F19" KEY_F20 Key = sdl.K_F20 // "F20" KEY_F21 Key = sdl.K_F21 // "F21" KEY_F22 Key = sdl.K_F22 // "F22" KEY_F23 Key = sdl.K_F23 // "F23" KEY_F24 Key = sdl.K_F24 // "F24" KEY_EXECUTE Key = sdl.K_EXECUTE // "Execute" KEY_HELP Key = sdl.K_HELP // "Help" KEY_MENU Key = sdl.K_MENU // "Menu" KEY_SELECT Key = sdl.K_SELECT // "Select" KEY_STOP Key = sdl.K_STOP // "Stop" KEY_AGAIN Key = sdl.K_AGAIN // "Again" (the Again key (Redo)) KEY_UNDO Key = sdl.K_UNDO // "Undo" KEY_CUT Key = sdl.K_CUT // "Cut" KEY_COPY Key = sdl.K_COPY // "Copy" KEY_PASTE Key = sdl.K_PASTE // "Paste" KEY_FIND Key = sdl.K_FIND // "Find" KEY_MUTE Key = sdl.K_MUTE // "Mute" KEY_VOLUMEUP Key = sdl.K_VOLUMEUP // "VolumeUp" KEY_VOLUMEDOWN Key = sdl.K_VOLUMEDOWN // "VolumeDown" KEY_KP_COMMA Key = sdl.K_KP_COMMA // "Keypad ," (the Comma key (numeric keypad)) KEY_KP_EQUALSAS400 Key = sdl.K_KP_EQUALSAS400 // "Keypad = (AS400)" (the Equals AS400 key (numeric keypad)) KEY_ALTERASE Key = sdl.K_ALTERASE // "AltErase" (Erase-Eaze) KEY_SYSREQ Key = sdl.K_SYSREQ // "SysReq" (the SysReq key) KEY_CANCEL Key = sdl.K_CANCEL // "Cancel" KEY_CLEAR Key = sdl.K_CLEAR // "Clear" KEY_PRIOR Key = sdl.K_PRIOR // "Prior" KEY_RETURN2 Key = sdl.K_RETURN2 // "Return" KEY_SEPARATOR Key = sdl.K_SEPARATOR // "Separator" KEY_OUT Key = sdl.K_OUT // "Out" KEY_OPER Key = sdl.K_OPER // "Oper" KEY_CLEARAGAIN Key = sdl.K_CLEARAGAIN // "Clear / Again" KEY_CRSEL Key = sdl.K_CRSEL // "CrSel" KEY_EXSEL Key = sdl.K_EXSEL // "ExSel" KEY_KP_00 Key = sdl.K_KP_00 // "Keypad 00" (the 00 key (numeric keypad)) KEY_KP_000 Key = sdl.K_KP_000 // "Keypad 000" (the 000 key (numeric keypad)) KEY_THOUSANDSSEPARATOR Key = sdl.K_THOUSANDSSEPARATOR // "ThousandsSeparator" (the Thousands Separator key) KEY_DECIMALSEPARATOR Key = sdl.K_DECIMALSEPARATOR // "DecimalSeparator" (the Decimal Separator key) KEY_CURRENCYUNIT Key = sdl.K_CURRENCYUNIT // "CurrencyUnit" (the Currency Unit key) KEY_CURRENCYSUBUNIT Key = sdl.K_CURRENCYSUBUNIT // "CurrencySubUnit" (the Currency Subunit key) KEY_KP_LEFTPAREN Key = sdl.K_KP_LEFTPAREN // "Keypad (" (the Left Parenthesis key (numeric keypad)) KEY_KP_RIGHTPAREN Key = sdl.K_KP_RIGHTPAREN // "Keypad )" (the Right Parenthesis key (numeric keypad)) KEY_KP_LEFTBRACE Key = sdl.K_KP_LEFTBRACE // "Keypad {" (the Left Brace key (numeric keypad)) KEY_KP_RIGHTBRACE Key = sdl.K_KP_RIGHTBRACE // "Keypad }" (the Right Brace key (numeric keypad)) KEY_KP_TAB Key = sdl.K_KP_TAB // "Keypad Tab" (the Tab key (numeric keypad)) KEY_KP_BACKSPACE Key = sdl.K_KP_BACKSPACE // "Keypad Backspace" (the Backspace key (numeric keypad)) KEY_KP_A Key = sdl.K_KP_A // "Keypad A" (the A key (numeric keypad)) KEY_KP_B Key = sdl.K_KP_B // "Keypad B" (the B key (numeric keypad)) KEY_KP_C Key = sdl.K_KP_C // "Keypad C" (the C key (numeric keypad)) KEY_KP_D Key = sdl.K_KP_D // "Keypad D" (the D key (numeric keypad)) KEY_KP_E Key = sdl.K_KP_E // "Keypad E" (the E key (numeric keypad)) KEY_KP_F Key = sdl.K_KP_F // "Keypad F" (the F key (numeric keypad)) KEY_KP_XOR Key = sdl.K_KP_XOR // "Keypad XOR" (the XOR key (numeric keypad)) KEY_KP_POWER Key = sdl.K_KP_POWER // "Keypad ^" (the Power key (numeric keypad)) KEY_KP_PERCENT Key = sdl.K_KP_PERCENT // "Keypad %" (the Percent key (numeric keypad)) KEY_KP_LESS Key = sdl.K_KP_LESS // "Keypad <" (the Less key (numeric keypad)) KEY_KP_GREATER Key = sdl.K_KP_GREATER // "Keypad >" (the Greater key (numeric keypad)) KEY_KP_AMPERSAND Key = sdl.K_KP_AMPERSAND // "Keypad &" (the & key (numeric keypad)) KEY_KP_DBLAMPERSAND Key = sdl.K_KP_DBLAMPERSAND // "Keypad &&" (the && key (numeric keypad)) KEY_KP_VERTICALBAR Key = sdl.K_KP_VERTICALBAR // "Keypad |" (the | key (numeric keypad)) KEY_KP_DBLVERTICALBAR Key = sdl.K_KP_DBLVERTICALBAR // "Keypad ||" (the || key (numeric keypad)) KEY_KP_COLON Key = sdl.K_KP_COLON // "Keypad :" (the : key (numeric keypad)) KEY_KP_HASH Key = sdl.K_KP_HASH // "Keypad #" (the # key (numeric keypad)) KEY_KP_SPACE Key = sdl.K_KP_SPACE // "Keypad Space" (the Space key (numeric keypad)) KEY_KP_AT Key = sdl.K_KP_AT // "Keypad @" (the @ key (numeric keypad)) KEY_KP_EXCLAM Key = sdl.K_KP_EXCLAM // "Keypad !" (the ! key (numeric keypad)) KEY_KP_MEMSTORE Key = sdl.K_KP_MEMSTORE // "Keypad MemStore" (the Mem Store key (numeric keypad)) KEY_KP_MEMRECALL Key = sdl.K_KP_MEMRECALL // "Keypad MemRecall" (the Mem Recall key (numeric keypad)) KEY_KP_MEMCLEAR Key = sdl.K_KP_MEMCLEAR // "Keypad MemClear" (the Mem Clear key (numeric keypad)) KEY_KP_MEMADD Key = sdl.K_KP_MEMADD // "Keypad MemAdd" (the Mem Add key (numeric keypad)) KEY_KP_MEMSUBTRACT Key = sdl.K_KP_MEMSUBTRACT // "Keypad MemSubtract" (the Mem Subtract key (numeric keypad)) KEY_KP_MEMMULTIPLY Key = sdl.K_KP_MEMMULTIPLY // "Keypad MemMultiply" (the Mem Multiply key (numeric keypad)) KEY_KP_MEMDIVIDE Key = sdl.K_KP_MEMDIVIDE // "Keypad MemDivide" (the Mem Divide key (numeric keypad)) KEY_KP_PLUSMINUS Key = sdl.K_KP_PLUSMINUS // "Keypad +/-" (the +/- key (numeric keypad)) KEY_KP_CLEAR Key = sdl.K_KP_CLEAR // "Keypad Clear" (the Clear key (numeric keypad)) KEY_KP_CLEARENTRY Key = sdl.K_KP_CLEARENTRY // "Keypad ClearEntry" (the Clear Entry key (numeric keypad)) KEY_KP_BINARY Key = sdl.K_KP_BINARY // "Keypad Binary" (the Binary key (numeric keypad)) KEY_KP_OCTAL Key = sdl.K_KP_OCTAL // "Keypad Octal" (the Octal key (numeric keypad)) KEY_KP_DECIMAL Key = sdl.K_KP_DECIMAL // "Keypad Decimal" (the Decimal key (numeric keypad)) KEY_KP_HEXADECIMAL Key = sdl.K_KP_HEXADECIMAL // "Keypad Hexadecimal" (the Hexadecimal key (numeric keypad)) KEY_LCTRL Key = sdl.K_LCTRL // "Left Ctrl" KEY_LSHIFT Key = sdl.K_LSHIFT // "Left Shift" KEY_LALT Key = sdl.K_LALT // "Left Alt" (alt, option) KEY_LGUI Key = sdl.K_LGUI // "Left GUI" (windows, command (apple), meta) KEY_RCTRL Key = sdl.K_RCTRL // "Right Ctrl" KEY_RSHIFT Key = sdl.K_RSHIFT // "Right Shift" KEY_RALT Key = sdl.K_RALT // "Right Alt" (alt, option) KEY_RGUI Key = sdl.K_RGUI // "Right GUI" (windows, command (apple), meta) KEY_MODE Key = sdl.K_MODE // "ModeSwitch" (I'm not sure if this is really not covered by any of the above, but since there's a special KMOD_MODE for it I'm adding it here) KEY_AUDIONEXT Key = sdl.K_AUDIONEXT // "AudioNext" (the Next Track media key) KEY_AUDIOPREV Key = sdl.K_AUDIOPREV // "AudioPrev" (the Previous Track media key) KEY_AUDIOSTOP Key = sdl.K_AUDIOSTOP // "AudioStop" (the Stop media key) KEY_AUDIOPLAY Key = sdl.K_AUDIOPLAY // "AudioPlay" (the Play media key) KEY_AUDIOMUTE Key = sdl.K_AUDIOMUTE // "AudioMute" (the Mute volume key) KEY_MEDIASELECT Key = sdl.K_MEDIASELECT // "MediaSelect" (the Media Select key) KEY_WWW Key = sdl.K_WWW // "WWW" (the WWW/World Wide Web key) KEY_MAIL Key = sdl.K_MAIL // "Mail" (the Mail/eMail key) KEY_CALCULATOR Key = sdl.K_CALCULATOR // "Calculator" (the Calculator key) KEY_COMPUTER Key = sdl.K_COMPUTER // "Computer" (the My Computer key) KEY_AC_SEARCH Key = sdl.K_AC_SEARCH // "AC Search" (the Search key (application control keypad)) KEY_AC_HOME Key = sdl.K_AC_HOME // "AC Home" (the Home key (application control keypad)) KEY_AC_BACK Key = sdl.K_AC_BACK // "AC Back" (the Back key (application control keypad)) KEY_AC_FORWARD Key = sdl.K_AC_FORWARD // "AC Forward" (the Forward key (application control keypad)) KEY_AC_STOP Key = sdl.K_AC_STOP // "AC Stop" (the Stop key (application control keypad)) KEY_AC_REFRESH Key = sdl.K_AC_REFRESH // "AC Refresh" (the Refresh key (application control keypad)) KEY_AC_BOOKMARKS Key = sdl.K_AC_BOOKMARKS // "AC Bookmarks" (the Bookmarks key (application control keypad)) KEY_BRIGHTNESSDOWN Key = sdl.K_BRIGHTNESSDOWN // "BrightnessDown" (the Brightness Down key) KEY_BRIGHTNESSUP Key = sdl.K_BRIGHTNESSUP // "BrightnessUp" (the Brightness Up key) KEY_DISPLAYSWITCH Key = sdl.K_DISPLAYSWITCH // "DisplaySwitch" (display mirroring/dual display switch, video mode switch) KEY_KBDILLUMTOGGLE Key = sdl.K_KBDILLUMTOGGLE // "KBDIllumToggle" (the Keyboard Illumination Toggle key) KEY_KBDILLUMDOWN Key = sdl.K_KBDILLUMDOWN // "KBDIllumDown" (the Keyboard Illumination Down key) KEY_KBDILLUMUP Key = sdl.K_KBDILLUMUP // "KBDIllumUp" (the Keyboard Illumination Up key) KEY_EJECT Key = sdl.K_EJECT // "Eject" (the Eject key) KEY_SLEEP Key = sdl.K_SLEEP // "Sleep" (the Sleep key) )
type KeyDirection ¶
type KeyDirection int // Key direction (up or down).
const ( KEYDIR_UP KeyDirection = 0 // Key is released. KEYDIR_DOWN KeyDirection = 1 // Key is pressed. )
type Line ¶
type Line struct { Start Vec2 // Start of the line in the world. End Vec2 // End of the line in the world. HasAA bool // Specifies if this line is antialiased. // contains filtered or unexported fields }
type MouseButton ¶
type MouseButton int
Mouse buttons.
const ( MBUTTON_LEFT MouseButton = sdl.BUTTON_LEFT // Left mouse button. MBUTTON_MIDDLE MouseButton = sdl.BUTTON_MIDDLE // Middle mouse button. MBUTTON_RIGHT MouseButton = sdl.BUTTON_RIGHT // Right mouse button. MBUTTON_X1 MouseButton = sdl.BUTTON_X1 // X1 mouse button. MBUTTON_X2 MouseButton = sdl.BUTTON_X2 // X2 mouse button. )
type OnCloseFunc ¶
type OnCloseFunc func() bool // Function that is called after the window closes. Should return whether the window should close or not.
type OnKeyEventFunc ¶
type OnKeyEventFunc func(key Key, direction KeyDirection, app *App) // Function that is called when a key is down or up. Receives the key, the direction and the app.
type Polygon ¶
type PostRenderFunc ¶
type PostRenderFunc func(app *App) // Function that is called at the end of drawing each frame.
type QueuedFunc ¶
type Rectangle ¶
type Shape ¶
type Shape interface {
Draw()
}
Entity shapes. It must implement Draw(), which will be called when the entity needs to be rendered to the screen.
type Sprite ¶
type Sprite struct { Surface *sdl.Surface // SDL surface. Tex *sdl.Texture // SDL texture. Width int32 // Width of the sprite. Height int32 // Height of the sprite. BlendMode sdl.BlendMode // Texture blend mode. }
func (*Sprite) LoadTexture ¶
Loads the texture from the surface, if it exists.
func (*Sprite) SetBlendMode ¶
Sets the sprite's blend mode. Available blend modes: BLENDMODE_NONE, BLENDMODE_BLEND, BLENDMODE_ADD, BLENDMODE_MOD.
type UpdateFunc ¶
type WindowFlag ¶
type WindowFlag int
const ( WINDOW_FULLSCREEN WindowFlag = sdl.WINDOW_FULLSCREEN // Fullscreen window. WINDOW_OPENGL WindowFlag = sdl.WINDOW_OPENGL // Window usable with OpenGL context. WINDOW_SHOWN WindowFlag = sdl.WINDOW_SHOWN // Window is visible. WINDOW_HIDDEN WindowFlag = sdl.WINDOW_HIDDEN // Window is not visible. WINDOW_BORDERLESS WindowFlag = sdl.WINDOW_BORDERLESS // No window decoration. WINDOW_RESIZABLE WindowFlag = sdl.WINDOW_RESIZABLE // Window can be resized. WINDOW_MINIMIZED WindowFlag = sdl.WINDOW_MINIMIZED // Window is minimized. WINDOW_MAXIMIZED WindowFlag = sdl.WINDOW_MAXIMIZED // Window is maximized. WINDOW_INPUT_GRABBED WindowFlag = sdl.WINDOW_INPUT_GRABBED // Window has grabbed input focus. WINDOW_INPUT_FOCUS WindowFlag = sdl.WINDOW_INPUT_FOCUS // Window has input focus. WINDOW_MOUSE_FOCUS WindowFlag = sdl.WINDOW_MOUSE_FOCUS // Window has mouse focus. WINDOW_FULLSCREEN_DESKTOP WindowFlag = sdl.WINDOW_FULLSCREEN_DESKTOP // Fullscreen window at the current desktop resolution. WINDOW_FOREIGN WindowFlag = sdl.WINDOW_FOREIGN // Window not created by SDL. WINDOW_ALLOW_HIGHDPI WindowFlag = sdl.WINDOW_ALLOW_HIGHDPI // Window should be created in high-DPI mode if supported (>= SDL 2.0.1). WINDOW_MOUSE_CAPTURE WindowFlag = sdl.WINDOW_MOUSE_CAPTURE // Window has mouse captured (unrelated to INPUT_GRABBED, >= SDL 2.0.4). WINDOW_ALWAYS_ON_TOP WindowFlag = sdl.WINDOW_ALWAYS_ON_TOP // Window should always be above others (X11 only, >= SDL 2.0.5). WINDOW_SKIP_TASKBAR WindowFlag = sdl.WINDOW_SKIP_TASKBAR // Window should not be added to the taskbar (X11 only, >= SDL 2.0.5). WINDOW_UTILITY WindowFlag = sdl.WINDOW_UTILITY // Window should be treated as a utility window (X11 only, >= SDL 2.0.5). WINDOW_TOOLTIP WindowFlag = sdl.WINDOW_TOOLTIP // Window should be treated as a tooltip (X11 only, >= SDL 2.0.5). WINDOW_POPUP_MENU WindowFlag = sdl.WINDOW_POPUP_MENU // Window should be treated as a popup menu (X11 only, >= SDL 2.0.5). WINDOW_VULKAN WindowFlag = sdl.WINDOW_VULKAN // Window usable for Vulkan surface (>= SDL 2.0.6). )