Documentation ¶
Index ¶
- Constants
- func Clamp(num, low, hi float64) float64
- func Clamp01(num float64) float64
- func Delay(s uint32)
- func NewRect(x, y, w, h float64) *sdl.Rect
- func NewSdlColor(r, g, b, a float64) sdl.Color
- func R256() float64
- func RandIntN(i float64) float64
- func Sign(s float64) float64
- func Wrap(num, low, hi float64) float64
- type Colour
- type Context
- func (c *Context) Clear()
- func (c *Context) Destroy()
- func (c *Context) DrawCircle(x, y, radius float64)
- func (c *Context) DrawFillCircle(x, y, radius float64)
- func (c *Context) DrawText(x, y, scale float64, text string)
- func (c *Context) Elapsed() float64
- func (c *Context) Line(x0, y0, x1, y1 float64)
- func (c *Context) Point(x0, y0 float64)
- func (c *Context) PointScale(x0, y0, scale float64)
- func (c *Context) PollQuitandKeys() (running bool, keys KeyStatus)
- func (c *Context) Present()
- func (c *Context) SetDrawColor(rgba Colour)
- func (c *Context) Triangle(x0, y0, x1, y1, x2, y2 float64)
- type KeyStatus
- type P2D
- type P3D
- type Sprite
- type SpriteSheet
- type TransformFunc
- type V2D
- type V3D
- type ZBuffer
Constants ¶
const NEGINF float64 = -1000000
NEGINF - helper const = -1_000_000
const PI = 3.141592
PI constant
Variables ¶
This section is empty.
Functions ¶
func NewSdlColor ¶
NewSdlColor - takes floats and returs an sdl suitalbe color object
Types ¶
type Colour ¶
Colour struct for float64 colour values
func (Colour) ToSDLColor ¶
ToSDLColor - returns a sdl.Color struct from a Colour struct
type Context ¶
type Context struct { WindowTitle string WinWidth float64 WinHeight float64 Window *sdl.Window Renderer *sdl.Renderer Blocks float64 ScrnWidth float64 ScrnHeight float64 // contains filtered or unexported fields }
Context - contains context object for game engine
func New ¶
func New(b, sw, sh float64, title string, tf TransformFunc) *Context
New - create the GameEngine and initialises
func (*Context) DrawCircle ¶
DrawCircle - draws circle using point function
func (*Context) DrawFillCircle ¶
DrawFillCircle - draws filled circle using point function
func (*Context) Point ¶
Point - Draws a blocky point transformed to screen with optional transform applied from func stored in Context
func (*Context) PointScale ¶
PointScale - Draws a blocky point but scaled down by a factore (used mainly in text drawing) (blocks)
func (*Context) PollQuitandKeys ¶
PollQuitandKeys - checks for events. Returns running=True and a Key struct
func (*Context) SetDrawColor ¶
SetDrawColor for next use to Colour struct
type KeyStatus ¶
type KeyStatus struct { Key string // key pressed as string Pressed bool Released bool Repeating bool Modifier uint16 Event bool }
KeyStatus - Struct holding key status information
type Sprite ¶
Sprite struct
func NewSprite ¶
NewSprite - loads and builds a new sprite given a filename. Returns pointer to sprite structure
func (*Sprite) DrawPartialSprite ¶
DrawPartialSprite - draws a rectangle from a sprite at x,y given offset ox and oy into sprite size w, h. No bounds checking
func (*Sprite) DrawSprite ¶
DrawSprite - at x,y location
func (*Sprite) SampleSprite ¶
SampleSprite - Samples from normal x, y of sprite
type SpriteSheet ¶
type SpriteSheet struct { Sheet *Sprite SpritesPerRow float64 SpritesPerCol float64 SpriteW float64 SpriteH float64 }
SpriteSheet -
func NewSpriteSheet ¶
func NewSpriteSheet(filename string, NumPerCol, NumPerRow float64) (sh *SpriteSheet, err error)
NewSpriteSheet -
func (*SpriteSheet) DrawSpriteFromSheet ¶
func (s *SpriteSheet) DrawSpriteFromSheet(c *Context, x, y, row, col float64)
DrawSpriteFromSheet - given x and y coord draws the sprite from row x col of spritesheet
func (*SpriteSheet) DrawSpriteFromSheetI ¶
func (s *SpriteSheet) DrawSpriteFromSheetI(c *Context, x, y, i float64)
DrawSpriteFromSheetI - indexes spritesheet as linear array.
type TransformFunc ¶
TransformFunc - type of function to modify Point drawing
type ZBuffer ¶
type ZBuffer struct {
// contains filtered or unexported fields
}
ZBuffer struct
func NewZBuffer ¶
NewZBuffer returns a pointer to a initilised and cleared z buffer
func (*ZBuffer) SetIfNearer ¶
SetIfNearer - sets z buffer to depth d if is nearer than prev val. Returns true or false