Documentation ¶
Overview ¶
Package graphic is using the sdl2 go interface from (c)https://github.com/veandco/go-sdl2/ under the BSD 3 License
Package graphic is using the sdl2 go interface from (c)https://github.com/veandco/go-sdl2/ under the BSD 3 License
Index ¶
- func InitLogger(logger *log.Logger, name string) error
- func NewFRect(x, y, w, h float32) sdl.FRect
- func NewRect(x, y, w, h int32) sdl.Rect
- type Config
- type Instance
- type Sprite
- type SpriteBaseConfig
- type SpriteConfig
- type Window
- func (window *Window) AddSprite(imgPath string, srcRect sdl.Rect) (int, error)
- func (window *Window) AddSpriteByID(spriteID int, srcRect sdl.Rect) int
- func (window *Window) Init(config WindowConfig) error
- func (window *Window) IsInit() bool
- func (window *Window) LoadAndDumpSprites(config []SpriteBaseConfig) (map[string]int, error)
- func (window *Window) LoadBackgroundImg(imgPath string) error
- func (window *Window) LoadSprites(config []SpriteBaseConfig) (map[string]int, error)
- func (window *Window) MoveView(x, y int32)
- func (window *Window) Quit()
- func (window *Window) Render() error
- func (window *Window) RenderBackground(w, h int32) error
- func (window *Window) SetView(x, y int32)
- type WindowConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func InitLogger ¶
InitLogger sets the logger output to a file in /tmp
Types ¶
type Config ¶
type Config struct { Window WindowConfig BaseSprites []SpriteBaseConfig }
Config data loaded form config json
type Instance ¶
Instance position Angle and the Center of an instance of a sprite
func (*Instance) ChangePosition ¶
ChangePosition moves the instance by x, y
func (*Instance) NewPosition ¶
NewPosition sets the position of this instance Center is the Center of the instances new position
type Sprite ¶
type Sprite struct {
// contains filtered or unexported fields
}
Sprite contains the texture a list of instances and a srcRect
func (*Sprite) NewInstance ¶
NewInstance adds a instance to the sprite and initializes the width and height of the dest rectAngle with the src rectAngle
type SpriteBaseConfig ¶
type SpriteBaseConfig struct { ImgPath string Sprites []SpriteConfig }
SpriteBaseConfig base config to create sprites on
type SpriteConfig ¶
SpriteConfig config for a sprite based on a SpriteBaseConfig obj
type Window ¶
type Window struct { Sprites []Sprite DrawColor struct { // contains filtered or unexported fields } Renderer *sdl.Renderer // contains filtered or unexported fields }
Window contains the information required to render a window with diffrent Sprites
func (*Window) AddSprite ¶
AddSprite adds another sprite which can be used be creating a instance of it see Sprite.NewInstance
func (*Window) AddSpriteByID ¶
AddSpriteByID adds another sprite with the same texture as sprite with id spriteID
func (*Window) Init ¶
func (window *Window) Init(config WindowConfig) error
New returns a Window object with initialized renderer and window note that Sprites have to be added manual
func (*Window) LoadAndDumpSprites ¶
func (window *Window) LoadAndDumpSprites(config []SpriteBaseConfig) (map[string]int, error)
LoadAndDumpSprites load new sprites and dump every old sprite and instance
func (*Window) LoadBackgroundImg ¶
LoadBackgroundImg loads an image and uses it as the background
func (*Window) LoadSprites ¶
func (window *Window) LoadSprites(config []SpriteBaseConfig) (map[string]int, error)
LoadSprites from config object returns map with sprite IDs linked to the sprite name
func (*Window) RenderBackground ¶
RenderBackground by rendering current instances to work instances have to be created and should probably be dumped along with the sprites
type WindowConfig ¶
type WindowConfig struct { Title string X, Y, Width, Height int32 WindowFlags, RendererFlags, FPS uint32 }
WindowConfig Render info for Window