Documentation ¶
Index ¶
- type Camera
- type Font
- type Keyboard
- type Mouse
- func (m *Mouse) IsButtonDown(button input.MouseButton) bool
- func (m *Mouse) IsButtonPress(button input.MouseButton) bool
- func (m *Mouse) IsButtonRelease(button input.MouseButton) bool
- func (m *Mouse) IsButtonUp(button input.MouseButton) bool
- func (m *Mouse) IsClick(button input.MouseButton) (bool, int32, int32)
- func (m *Mouse) IsRelease(button input.MouseButton) (bool, int32, int32)
- func (m *Mouse) Pos() (int32, int32)
- func (m *Mouse) UpdateButton(button input.MouseButton, x, y int32, pressed bool)
- func (m *Mouse) UpdatePosition(x, y int32)
- type Player
- type SDL2
- func (s *SDL2) Close()
- func (s *SDL2) CreateWindow(x, y int32, title string) error
- func (s *SDL2) DisableCursor() error
- func (s *SDL2) EnableCursor() error
- func (s *SDL2) Init() error
- func (s *SDL2) NewAudioPlayer() (audio.Player, error)
- func (s *SDL2) NewCamera() (graphics.Camera, error)
- func (s *SDL2) NewFont(fontPath string, size int) (graphics.Font, error)
- func (s *SDL2) NewKeyboard() input.Keyboard
- func (s *SDL2) NewMouse() input.Mouse
- func (s *SDL2) NewTexture(imgPath string) (graphics.Texture, error)
- func (s *SDL2) NewTextureAtlas(imgPath string, splitX, splitY int32) (graphics.TextureAtlas, error)
- func (s *SDL2) PostDraw()
- func (s *SDL2) PreDraw() error
- func (s *SDL2) SetBackgroundColor(color *graphics.Color)
- func (s *SDL2) Update() error
- type Sound
- type Texture
- type TextureAtlas
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Camera ¶ added in v0.1.2
type Camera struct{}
Camera wraps methods used to alter the offsets of the current rendering context.
func (*Camera) ScaleX ¶ added in v0.1.2
ScaleX returns the current X-axis scale factor of the camera.
func (*Camera) ScaleY ¶ added in v0.1.2
ScaleY returns the current Y-axis scale factor of the camera.
func (*Camera) SetPosition ¶ added in v0.1.2
SetPosition sets the position of the camera relative to the world.
func (*Camera) SetScale ¶ added in v0.1.2
SetScale sets the scale factor of all rendering textures. This is multiplicative of the actual texture scale size.
type Font ¶
type Font struct {
// contains filtered or unexported fields
}
Font wraps an SDL TTF Font and allows drawing to screen.
type Keyboard ¶
type Keyboard struct {
// contains filtered or unexported fields
}
Keyboard wraps a map of SDL keys and their current states.
func (*Keyboard) IsKeyPress ¶
IsKeyPress returns true if the given key is pressed for the first time.
func (*Keyboard) IsKeyRelease ¶
IsKeyRelease returns true if the given key is release for the first time.
type Mouse ¶ added in v0.3.0
Mouse wraps a map of SDL Mouse Buttons and their current states as well as the current mouse position.
func (*Mouse) IsButtonDown ¶ added in v0.3.0
func (m *Mouse) IsButtonDown(button input.MouseButton) bool
IsButtonDown returns true if the given mouse button is pressed.
func (*Mouse) IsButtonPress ¶ added in v0.3.0
func (m *Mouse) IsButtonPress(button input.MouseButton) bool
IsButtonPress returns true if the given mouse button is pressed for the first time.
func (*Mouse) IsButtonRelease ¶ added in v0.3.0
func (m *Mouse) IsButtonRelease(button input.MouseButton) bool
IsButtonRelease returns true if the given mouse button is released for the first time.
func (*Mouse) IsButtonUp ¶ added in v0.3.0
func (m *Mouse) IsButtonUp(button input.MouseButton) bool
IsButtonUp returns true if the given mouse button is not pressed.
func (*Mouse) IsClick ¶ added in v0.3.0
IsClick returns true if the given mouse button is pressed for the first time as well as its clicked coordinates
func (*Mouse) IsRelease ¶ added in v0.3.0
IsRelease returns true if the given mouse button is released for the first time as well as its released coordinates
func (*Mouse) UpdateButton ¶ added in v0.3.0
func (m *Mouse) UpdateButton(button input.MouseButton, x, y int32, pressed bool)
UpdateButton updates the state of the given button to the mouse button state map.
func (*Mouse) UpdatePosition ¶ added in v0.3.0
UpdatePosition updates the mouse cursor position.
type Player ¶
type Player struct {
// contains filtered or unexported fields
}
Player wraps needed methods for the audio.Player interface.
type SDL2 ¶
type SDL2 struct {
// contains filtered or unexported fields
}
SDL2 implements the Driver interface.
func (*SDL2) CreateWindow ¶
CreateWindow starts a new window and renderer which is ready to draw to.
func (*SDL2) DisableCursor ¶ added in v0.3.2
DisableCursor disables rendering of the hardware cursor.
func (*SDL2) EnableCursor ¶ added in v0.3.2
EnableCursor enables rendering of the hardware cursor.
func (*SDL2) NewAudioPlayer ¶
NewAudioPlayer initializes the SDL mixer and returns a default Player. Player must be closed manually.
func (*SDL2) NewCamera ¶ added in v0.1.2
NewCamera sets the default offsets based on the current screen size.
func (*SDL2) NewKeyboard ¶
NewKeyboard sets up an empty map of key states.
func (*SDL2) NewTexture ¶
NewTexture loads an image as an SDL texture. Texture must be closed manually.
func (*SDL2) NewTextureAtlas ¶ added in v0.1.2
NewTextureAtlas loads an image as an SDL texture and splices it into separate rectangles for use in drawing.
func (*SDL2) SetBackgroundColor ¶
SetBackgroundColor sets the RGB value of the screen clear before each frame.
type Sound ¶
type Sound struct {
// contains filtered or unexported fields
}
Sound holds SDL chunk data for playback in use with the audio.Sound interface.
type Texture ¶
type Texture struct {
// contains filtered or unexported fields
}
Texture wraps an SDL Texture and allows writing to screen.
type TextureAtlas ¶ added in v0.1.2
type TextureAtlas struct {
// contains filtered or unexported fields
}
TextureAtlas wraps an SDL Texture. It splits the texture into tiles to allow for easy drawing of sprites in a spritesheet.
func (*TextureAtlas) Close ¶ added in v0.1.2
func (t *TextureAtlas) Close() error
Close releases the texture and the image from memory.
func (*TextureAtlas) Draw ¶ added in v0.1.2
Draw renders the texture of the given tile to the SDL renderer.
func (*TextureAtlas) Len ¶ added in v0.1.2
func (t *TextureAtlas) Len() int
Len returns the number of spliced tiles in the texture atlas.