Utilities

package
v0.0.0-...-b5f20da Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 17, 2020 License: Apache-2.0, MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const INITSTATE = "00000\n"
View Source
const PORT = 8080
View Source
const (
	TextSizeScale = 0.75
)

Variables

View Source
var (
	GamepadSDLIDs   map[int]string
	SmartServIPAddr string
)
View Source
var (
	AllKeys = []ebiten.Key{
		ebiten.Key0,
		ebiten.Key1,
		ebiten.Key2,
		ebiten.Key3,
		ebiten.Key4,
		ebiten.Key5,
		ebiten.Key6,
		ebiten.Key7,
		ebiten.Key8,
		ebiten.Key9,
		ebiten.KeyA,
		ebiten.KeyB,
		ebiten.KeyC,
		ebiten.KeyD,
		ebiten.KeyE,
		ebiten.KeyF,
		ebiten.KeyG,
		ebiten.KeyH,
		ebiten.KeyI,
		ebiten.KeyJ,
		ebiten.KeyK,
		ebiten.KeyL,
		ebiten.KeyM,
		ebiten.KeyN,
		ebiten.KeyO,
		ebiten.KeyP,
		ebiten.KeyQ,
		ebiten.KeyR,
		ebiten.KeyS,
		ebiten.KeyT,
		ebiten.KeyU,
		ebiten.KeyV,
		ebiten.KeyW,
		ebiten.KeyX,
		ebiten.KeyY,
		ebiten.KeyZ,
		ebiten.KeyApostrophe,
		ebiten.KeyBackslash,
		ebiten.KeyBackspace,
		ebiten.KeyCapsLock,
		ebiten.KeyComma,
		ebiten.KeyDelete,
		ebiten.KeyDown,
		ebiten.KeyEnd,
		ebiten.KeyEnter,
		ebiten.KeyEqual,
		ebiten.KeyEscape,
		ebiten.KeyF1,
		ebiten.KeyF2,
		ebiten.KeyF3,
		ebiten.KeyF4,
		ebiten.KeyF5,
		ebiten.KeyF6,
		ebiten.KeyF7,
		ebiten.KeyF8,
		ebiten.KeyF9,
		ebiten.KeyF10,
		ebiten.KeyF11,
		ebiten.KeyF12,
		ebiten.KeyGraveAccent,
		ebiten.KeyHome,
		ebiten.KeyInsert,
		ebiten.KeyKP0,
		ebiten.KeyKP1,
		ebiten.KeyKP2,
		ebiten.KeyKP3,
		ebiten.KeyKP4,
		ebiten.KeyKP5,
		ebiten.KeyKP6,
		ebiten.KeyKP7,
		ebiten.KeyKP8,
		ebiten.KeyKP9,
		ebiten.KeyKPAdd,
		ebiten.KeyKPDecimal,
		ebiten.KeyKPDivide,
		ebiten.KeyKPEnter,
		ebiten.KeyKPEqual,
		ebiten.KeyKPMultiply,
		ebiten.KeyKPSubtract,
		ebiten.KeyLeft,
		ebiten.KeyLeftBracket,
		ebiten.KeyMenu,
		ebiten.KeyMinus,
		ebiten.KeyNumLock,
		ebiten.KeyPageDown,
		ebiten.KeyPageUp,
		ebiten.KeyPause,
		ebiten.KeyPeriod,
		ebiten.KeyPrintScreen,
		ebiten.KeyRight,
		ebiten.KeyRightBracket,
		ebiten.KeyScrollLock,
		ebiten.KeySemicolon,
		ebiten.KeySlash,
		ebiten.KeySpace,
		ebiten.KeyTab,
		ebiten.KeyUp,
		ebiten.KeyAlt,
		ebiten.KeyControl,
		ebiten.KeyShift}
)
View Source
var TrueTypeFont *truetype.Font

Functions

func CheckErr

func CheckErr(err error)

func DrawBoxToImage

func DrawBoxToImage(img *ebiten.Image, x, y, w, h float64, col color.Color)

func DrawLine

func DrawLine(img *ebiten.Image, pnt1, pnt2 *Point, w float64, col color.Color)

func Get1zu1Mapper

func Get1zu1Mapper(length int) map[int]int

func GetRandomFloat

func GetRandomFloat(l, u float64) float64

func GetRandomInt

func GetRandomInt(l, u float64) int

func GetRandomPos

func GetRandomPos(x, y, w, h int) (int, int)

func GetRandomPosInScreen

func GetRandomPosInScreen(W, H int) (int, int)

func GetRandomPosOutScreen

func GetRandomPosOutScreen(W, H int) (int, int)

func GetSizeForText

func GetSizeForText(str string, maxWidth, maxHeight int) (size float64)

func GetStartPos4P

func GetStartPos4P(ID int, ScreenWidth, ScreenHeight, WallDis float64) (float64, float64, int)

func GetWHForText

func GetWHForText(str string, size float64) (float64, float64)

func ImgToEbitenImg

func ImgToEbitenImg(img *image.Image) *ebiten.Image

func Init

func Init(path string)

func InitAudioContext

func InitAudioContext()

func InitControlls

func InitControlls(ControllerThresh float64, playerNum int) (error, *[]*Controller)

func InitIcons

func InitIcons(path string, sizes []int, fileformat string) (error, []image.Image)

func IsInsideBox

func IsInsideBox(bx, by, bw, bh, ox, oy, ow, oh float64) bool

func LoadEbitenImg

func LoadEbitenImg(path string) *ebiten.Image

func LoadImg

func LoadImg(path string) (error, *image.Image)

func LoadMapper

func LoadMapper(path string) map[int]int

func MakePopUpAt

func MakePopUpAt(screen *ebiten.Image, str string, x, y int, size float64, textCol, backCol color.RGBA)

func MaxFloat

func MaxFloat(vals ...float64) float64

func OnAcceptData

func OnAcceptData(c evio.Conn, in []byte) (out []byte, action evio.Action)

func OnConnectionClosed

func OnConnectionClosed(c evio.Conn, err error) (action evio.Action)

func OnNewConnection

func OnNewConnection(c evio.Conn) (out []byte, opts evio.Options, action evio.Action)

func PrintTextAt

func PrintTextAt(screen *ebiten.Image, str string, x, y int, r, g, b uint8, size float64)

func SaveMapper

func SaveMapper(path string, mapper map[int]int)

func UpdateControlls

func UpdateControlls()

Types

type AudioPlayer

type AudioPlayer struct {
	// contains filtered or unexported fields
}

AudioPlayer represents the current audio state.

func NewPlayer

func NewPlayer(filename string) (*AudioPlayer, error)

func (*AudioPlayer) Close

func (p *AudioPlayer) Close() error

func (*AudioPlayer) Play

func (p *AudioPlayer) Play() error

type Button

type Button struct {
	Img *ImageObj

	LPressed, RPressed, LastL, LastR, Active bool

	Data interface{}
	// contains filtered or unexported fields
}

func GetButton

func GetButton(img *ImageObj, onPressLeft func(b *Button), onPressRight func(b *Button)) *Button

func GetButtonWithText

func GetButtonWithText(img *ImageObj, str string, textCol color.RGBA, onPressLeft func(b *Button), onPressRight func(b *Button)) *Button

func GetButtonWithTextBack

func GetButtonWithTextBack(str string, X, Y, W, H float64, textCol, backCol color.RGBA, onPressLeft func(b *Button), onPressRight func(b *Button)) *Button

func GetButtonWithTextOnyl

func GetButtonWithTextOnyl(str string, X, Y, W, H float64, textCol color.RGBA, onPressLeft func(b *Button), onPressRight func(b *Button)) *Button

func (*Button) Draw

func (b *Button) Draw(screen *ebiten.Image)

func (*Button) Update

func (b *Button) Update()

type ButtonEventListener

type ButtonEventListener interface {
	GetButton() int
	OnButtonUp()
	OnButtonDown()
}

type Controller

type Controller struct {
	Id, Name string
	Buttons  map[int]float64
	Mapper   map[int]int

	AxisStandard map[int]float64
	AxisValues   []float64

	Down []int

	SmartPhoneConn *SmartPhoneConn
	// contains filtered or unexported fields
}

func (*Controller) GetAxisValue

func (c *Controller) GetAxisValue(idx1, idx2 int) float64

func (*Controller) GetButtonValue

func (c *Controller) GetButtonValue(idx int) float64

func (*Controller) GetInfos

func (c *Controller) GetInfos() (out string)

func (*Controller) GetListenedBtns

func (c *Controller) GetListenedBtns() []int

func (*Controller) LoadConfig

func (c *Controller) LoadConfig(path string)

func (*Controller) RegisterButtonEventListener

func (c *Controller) RegisterButtonEventListener(listener ButtonEventListener)

func (*Controller) RegisterDirectionEventListener

func (c *Controller) RegisterDirectionEventListener(listener DirectionEventListener)

func (*Controller) ResetButtonEventListener

func (c *Controller) ResetButtonEventListener()

func (*Controller) ResetDirectionEventListener

func (c *Controller) ResetDirectionEventListener()

func (*Controller) SaveConfig

func (c *Controller) SaveConfig(path string)

func (*Controller) SetMapper

func (c *Controller) SetMapper(oldidx, newidx int)

func (*Controller) UpdateAll

func (c *Controller) UpdateAll() (int, int)

func (*Controller) UpdateController

func (c *Controller) UpdateController()

func (*Controller) UpdateControllerAll

func (c *Controller) UpdateControllerAll()

func (*Controller) UpdateControllerButtons

func (c *Controller) UpdateControllerButtons(buttons ...int)

func (*Controller) UpdateKeyBoard

func (c *Controller) UpdateKeyBoard()

func (*Controller) UpdateKeyBoardAll

func (c *Controller) UpdateKeyBoardAll()

func (*Controller) UpdateKeys

func (c *Controller) UpdateKeys(keys ...int)

func (*Controller) UpdateListeners

func (c *Controller) UpdateListeners()

func (*Controller) UpdateOnlyNeeded

func (c *Controller) UpdateOnlyNeeded() (int, int)

func (*Controller) UpdateSmartPhone

func (c *Controller) UpdateSmartPhone()

func (*Controller) UseCurrentAxisValsAsStandard

func (c *Controller) UseCurrentAxisValsAsStandard()

type DirectionEventListener

type DirectionEventListener interface {
	GetAxis() (int, int, int, int)
	OnDirectionEvent(xdif, ydif float64)
}

type ImageObj

type ImageObj struct {
	Img               *ebiten.Image
	OriginalImg       *image.Image
	W, H, X, Y, Angle float64
}

func GetBarChart

func GetBarChart(Width, Heigth, X, Y float64, backCol color.Color, colors []color.RGBA, values ...float64) *ImageObj

func LoadImgObj

func LoadImgObj(path string, width, height, x, y, angle float64) *ImageObj

func (*ImageObj) Copy

func (obj *ImageObj) Copy() *ImageObj

func (*ImageObj) DrawImageObj

func (obj *ImageObj) DrawImageObj(screen *ebiten.Image)

func (*ImageObj) DrawImageObjAlpha

func (obj *ImageObj) DrawImageObjAlpha(screen *ebiten.Image, alpha float64)

func (*ImageObj) Print

func (obj *ImageObj) Print() string

type Params

type Params struct {
	// contains filtered or unexported fields
}

func (*Params) Get

func (p *Params) Get(key string) float64

func (*Params) GetS

func (p *Params) GetS(key string) string

func (*Params) LoadFromFile

func (p *Params) LoadFromFile(path string) error

func (*Params) Print

func (p *Params) Print() string

type Point

type Point struct {
	X, Y int
}

func CollidePnts

func CollidePnts(pnts1, pnts2 []*Point) (collPnts []*Point)

func (*Point) CollidesWithPnt

func (p *Point) CollidesWithPnt(pnt *Point) bool

func (*Point) CollidesWithPnts

func (p *Point) CollidesWithPnts(pnts []*Point) *Point

func (*Point) CollidesWithWall

func (p *Point) CollidesWithWall(XTiles, YTiles float64) bool

func (*Point) Copy

func (p *Point) Copy() *Point

func (*Point) Equals

func (p *Point) Equals(p2 *Point) bool

func (*Point) GetDisTo

func (p *Point) GetDisTo(p2 *Point) float64

func (*Point) IsContained

func (p *Point) IsContained(pnts []*Point) bool

func (*Point) Print

func (p *Point) Print() string

func (*Point) ToVector

func (p *Point) ToVector() *Physics.Vector

type Points

type Points []*Physics.Vector

func (*Points) Fill

func (ps *Points) Fill(screen *ebiten.Image, col color.Color)

type SmartPhoneConn

type SmartPhoneConn struct {
	Enc string
	// contains filtered or unexported fields
}

func (*SmartPhoneConn) EncToBool

func (c *SmartPhoneConn) EncToBool()

func (*SmartPhoneConn) IsDown

func (c *SmartPhoneConn) IsDown(i int) bool

func (*SmartPhoneConn) SetEnc

func (c *SmartPhoneConn) SetEnc(enc string)

type SmartPhoneServ

type SmartPhoneServ struct {
	Cons *[]*Controller
}
var (
	SPS_serv   *SmartPhoneServ
	IpToStruct map[string]*SmartPhoneConn
)

func NewSmartPhoneServ

func NewSmartPhoneServ(cons *[]*Controller) (*SmartPhoneServ, string)

func (*SmartPhoneServ) Run

func (s *SmartPhoneServ) Run()

type SnakeTiles

type SnakeTiles struct {
	Ts []*Point
}

func (*SnakeTiles) AddBack

func (t *SnakeTiles) AddBack(xdir, ydir, tiles int)

func (*SnakeTiles) AddFront

func (t *SnakeTiles) AddFront(xdir, ydir, tiles int)

func (*SnakeTiles) GetFirst

func (t *SnakeTiles) GetFirst() *Point

func (*SnakeTiles) GetLast

func (t *SnakeTiles) GetLast() *Point

func (*SnakeTiles) Print

func (t *SnakeTiles) Print() string

func (*SnakeTiles) RemBack

func (t *SnakeTiles) RemBack(tiles int)

func (*SnakeTiles) RemFront

func (t *SnakeTiles) RemFront(tiles int)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL