Documentation ¶
Index ¶
- Constants
- func CheckBoxHit(entity1, entity2 Hitter) bool
- func CheckBoxHitDebug(entity1, entity2 Hitter) bool
- func CheckPixelHit(entity1, entity2 Hitter) bool
- func RGBAPixels2Mask(rgbaData []int, w, h int32) ([]bool, error)
- func RGBAPixels2Surface(rgbaData []int, w, h int32) (*sdl.Surface, error)
- func RGBAPixels2Texture(rend *sdl.Renderer, rgbaData []int, w, h int32) (*sdl.Texture, error)
- func SetScalingQuality(quality ScreenScalingQuality) func(*Screen)
- func SetVSync(enabled bool) func(*Screen)
- func Surface2Texture(rend *sdl.Renderer, surf *sdl.Surface) (*sdl.Texture, error)
- type Box
- type Color
- type Counter
- type DrawFunc
- type Drawer
- type Entity
- type EntityService
- type EntityStrip
- type Hitter
- type KBState
- type KeyboardEventFunc
- type ProjectXYFunc
- type Screen
- func (s *Screen) ClearDrawFunc()
- func (s *Screen) ClearFuncs()
- func (s *Screen) ClearKeyDownFunc()
- func (s *Screen) ClearKeyUpFunc()
- func (s *Screen) ClearUpdateFunc()
- func (s *Screen) Close()
- func (s *Screen) Destroy()
- func (s *Screen) GetKBState() *KBState
- func (s *Screen) Rend() *sdl.Renderer
- func (s *Screen) Run()
- func (s *Screen) SetBackgroundColor(r, b, g, a uint8)
- func (s *Screen) SetDrawFunc(f DrawFunc)
- func (s *Screen) SetKeyDownFunc(f KeyboardEventFunc)
- func (s *Screen) SetKeyUpFunc(f KeyboardEventFunc)
- func (s *Screen) SetUpdateFunc(f UpdateFunc)
- type ScreenHint
- type ScreenScalingQuality
- type Sprite
- type SpriteAtlas
- type SpriteMap
- type SpriteMapKey
- type State
- type StripDirection
- type TextEntity
- type UpdateFunc
Constants ¶
const ( // KEYUP represents the Key Up state KEYUP uint8 = 0 // KEYDOWN represents the Key Down or pressed state KEYDOWN uint8 = 1 )
Variables ¶
This section is empty.
Functions ¶
func CheckBoxHit ¶
CheckBoxHit checks if any part of the two EntitState boxes overlap
func CheckBoxHitDebug ¶
CheckBoxHitDebug checks if any part of the two EntitState boxes overlap
func CheckPixelHit ¶
CheckPixelHit checks if any pixels in the two EntityStates overlap
func RGBAPixels2Mask ¶
RGBAPixels2Mask takes an array of RGBA pixel data and returns a collision mask
func RGBAPixels2Surface ¶
RGBAPixels2Surface takes an array of RGBA pixel data and returns a Surface
func RGBAPixels2Texture ¶
RGBAPixels2Texture takes an array of RGBA pixel data and returns a Texture
func SetScalingQuality ¶
func SetScalingQuality(quality ScreenScalingQuality) func(*Screen)
SetScalingQuality sets the scaling quality of the screen
Types ¶
type Color ¶
type Color struct {
R, G, B, A uint32
}
Color meets the color.Color interface required for CreateRGBSurface
func HexColorToRGBA ¶
HexColorToRGBA converts a colour stored in an int to RGBA values
type Counter ¶
Counter hold various runtie countners
func (*Counter) FrameEnd ¶
func (c *Counter) FrameEnd()
FrameEnd indicates the rendering frame has ended
func (*Counter) FrameStart ¶
func (c *Counter) FrameStart()
FrameStart indicates a rendering frame as started
type DrawFunc ¶
type DrawFunc func()
DrawFunc is the function that will be called during the draw phase
type Drawer ¶
type Drawer interface {
Draw()
}
Drawer represents an item that can be drawn on the screen
type Entity ¶
type Entity struct { // Virtaul game position X, Y, Z float32 Scale float32 Sprite *Sprite // ProjectXYFunc ProjectXYFunc Visible bool // contains filtered or unexported fields }
Entity is a item that can be displayed on the screen and tested for collision
func (*Entity) ClearProjectXYFunc ¶
func (e *Entity) ClearProjectXYFunc()
ClearProjectXYFunc restores the default virutal game to screen coord calculation
func (*Entity) SetProjectXYFunc ¶
func (e *Entity) SetProjectXYFunc(f ProjectXYFunc)
SetProjectXYFunc overrides the default virutal game to screen coord calculation
type EntityService ¶
type EntityService struct {
// contains filtered or unexported fields
}
EntityService builds new Entities with preset default values
func NewEntityService ¶
func NewEntityService() *EntityService
NewEntityService returns a new EntityService
func (*EntityService) NewEntity ¶
func (es *EntityService) NewEntity() *Entity
NewEntity returns a new Entity with the preset defaults
func (*EntityService) NewTextEntity ¶
func (es *EntityService) NewTextEntity() *TextEntity
NewTextEntity returns a new TextEntity with the preset defaults
func (*EntityService) SetScale ¶
func (es *EntityService) SetScale(scale float32)
SetScale sets the default Scale
func (*EntityService) SetXYProjection ¶
func (es *EntityService) SetXYProjection(projectXY ProjectXYFunc)
SetXYProjection sets the default XY projection
type EntityStrip ¶
type EntityStrip struct { // Virtaul game position X, Y, Z float32 Scale float32 Sprites []*Sprite // contains filtered or unexported fields }
EntityStrip is a strip of items that can be displayed on the screen and tested for collision
func (*EntityStrip) ClearProjectXYFunc ¶
func (e *EntityStrip) ClearProjectXYFunc()
ClearProjectXYFunc restores the default virutal game to screen coord calculation
func (*EntityStrip) SetPos ¶
func (e *EntityStrip) SetPos(x, y, z int32)
SetPos sets the position of the Entity
func (*EntityStrip) SetProjectXYFunc ¶
func (e *EntityStrip) SetProjectXYFunc(f ProjectXYFunc)
SetProjectXYFunc overrides the default virutal game to screen coord calculation
func (*EntityStrip) SetSprite ¶
func (e *EntityStrip) SetSprite(index int, sprite *Sprite)
SetSprite sets the Sprite the Entity will display
type KBState ¶
type KBState struct {
// contains filtered or unexported fields
}
KBState represents the state of the keyboard
type KeyboardEventFunc ¶
type KeyboardEventFunc func(e *sdl.KeyboardEvent)
KeyboardEventFunc is the function that will be called when a keyboard event occurs
type ProjectXYFunc ¶
ProjectXYFunc definces a function that projects of virtaul Game X/Y coords to Screen coords
type Screen ¶
type Screen struct {
// contains filtered or unexported fields
}
Screen represents a 2d window as shown on the screen
func NewScreen ¶
func NewScreen(width, height int, title string, hints ...ScreenHint) (*Screen, error)
NewScreen returns a newly initialisd screen in Windowed mode
func (*Screen) ClearDrawFunc ¶
func (s *Screen) ClearDrawFunc()
ClearDrawFunc clears the function that will be called during the draw phase
func (*Screen) ClearKeyDownFunc ¶
func (s *Screen) ClearKeyDownFunc()
ClearKeyDownFunc clears the function that will be called whena key is pressed
func (*Screen) ClearKeyUpFunc ¶
func (s *Screen) ClearKeyUpFunc()
ClearKeyUpFunc clears the function that will be called when a key is released
func (*Screen) ClearUpdateFunc ¶
func (s *Screen) ClearUpdateFunc()
ClearUpdateFunc clears the function that will be called during the update phase
func (*Screen) GetKBState ¶
GetKBState allows access to the current state of the keyboard
func (*Screen) SetBackgroundColor ¶
SetBackgroundColor sets the background color drawn on the screen
func (*Screen) SetDrawFunc ¶
SetDrawFunc sets the function that will be called during the draw phase
func (*Screen) SetKeyDownFunc ¶
func (s *Screen) SetKeyDownFunc(f KeyboardEventFunc)
SetKeyDownFunc sets the function that will be called whena key is pressed
func (*Screen) SetKeyUpFunc ¶
func (s *Screen) SetKeyUpFunc(f KeyboardEventFunc)
SetKeyUpFunc sets the function that will be called when a key is released
func (*Screen) SetUpdateFunc ¶
func (s *Screen) SetUpdateFunc(f UpdateFunc)
SetUpdateFunc sets the function that will be called during the update phase
type ScreenHint ¶
type ScreenHint func(*Screen)
ScreenHint represtents configuration options when creating a new screen
type ScreenScalingQuality ¶
type ScreenScalingQuality int
ScreenScalingQuality represent the scaling method
const ( // ScreenScalingNearestPixel - nearest pixel sampling ScreenScalingNearestPixel ScreenScalingQuality = iota // ScreenScalingLinear - linear filtering (supported by OpenGL and Direct3D) ScreenScalingLinear // ScreenScalingAnistropic - anisotropic filtering (supported by Direct3D) ScreenScalingAnistropic )
type Sprite ¶
type Sprite struct {
// contains filtered or unexported fields
}
Sprite represents a single object on the screen
type SpriteAtlas ¶
type SpriteAtlas struct {
// contains filtered or unexported fields
}
SpriteAtlas comprises multiple images tiled into a larger image. These images can be retrieved via their coordinates
func NewSpriteAtlas ¶
func NewSpriteAtlas(rend *sdl.Renderer) *SpriteAtlas
NewSpriteAtlas returns a new SpriteAtlas
func (*SpriteAtlas) DrawTileAt ¶
func (sa *SpriteAtlas) DrawTileAt(tileX, tileY, screenX, screenY int32, scale float32)
DrawTileAt draws a specific tile at the given location
func (*SpriteAtlas) LoadRGBAPixels ¶
func (sa *SpriteAtlas) LoadRGBAPixels(pixels []int, pixelsPitch, tilePitch, tileHeight int32) error
LoadRGBAPixels loads the Sprite using an array of 32-bit pixels containing RGBA values
type SpriteMap ¶
type SpriteMap struct {
// contains filtered or unexported fields
}
SpriteMap contains a map of individual Sprites that can be retrieved using an SpriteMapKey
func (*SpriteMap) AddSprite ¶
func (a *SpriteMap) AddSprite(key SpriteMapKey, sprite *Sprite)
AddSprite adds a Sprite to the SpriteMap against the specified SpriteMapKey
func (*SpriteMap) GetSprite ¶
func (a *SpriteMap) GetSprite(key SpriteMapKey) *Sprite
GetSprite gets the Sprite at the SpriteMap position specified by the SpriteMapKey
type SpriteMapKey ¶
type SpriteMapKey int
SpriteMapKey is used to retrieve a specific Sprite from the SpriteMap
type StripDirection ¶
type StripDirection int
StripDirection represents the direction in which the Sprites will be drawn.
const ( // Left2RightStrip draws from left to right Left2RightStrip StripDirection = iota // Top2BottomStrip draws from top to bootm Top2BottomStrip )
type TextEntity ¶
type TextEntity struct { // Virtaul game position X, Y, Z float32 Scale float32 // ProjectXYFunc ProjectXYFunc Visible bool // contains filtered or unexported fields }
TextEntity is a item that can be displayed on the screen and tested for collision
func (*TextEntity) ClearProjectXYFunc ¶
func (e *TextEntity) ClearProjectXYFunc()
ClearProjectXYFunc restores the default virutal game to screen coord calculation
func (*TextEntity) LoadAtlas ¶
func (e *TextEntity) LoadAtlas(atlas *SpriteAtlas, keys map[rune]int32, fontWidth int32)
LoadAtlas sets the Sprite the Entity will display
func (*TextEntity) SetPos ¶
func (e *TextEntity) SetPos(x, y, z int32)
SetPos sets the position of the Entity
func (*TextEntity) SetProjectXYFunc ¶
func (e *TextEntity) SetProjectXYFunc(f ProjectXYFunc)
SetProjectXYFunc overrides the default virutal game to screen coord calculation
func (*TextEntity) SetText ¶
func (e *TextEntity) SetText(value string)
SetText sets the text that will be displayed
type UpdateFunc ¶
UpdateFunc is the function that will be called during the update phase