canvas2d

package module
v0.0.0-...-76dbd87 Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2017 License: MIT Imports: 13 Imported by: 5

README

canvas2d

Lib to create 2d games with Go

To install use: go get -u github.com/WesleiRamos/canvas2d

Require:
gl https://github.com/go-gl/gl
glfw https://github.com/go-gl/glfw
gltext https://github.com/go-gl/gltext
go-winaudio https://bitbucket.org/StephenPatrick/go-winaudio

Agar.io clone

example1

FlappyBird clone

example2

Documentation

Index

Constants

View Source
const (
	KeyMinus        = int32(glfw.KeyMinus)
	KeyApostrophe   = int32(glfw.KeyApostrophe)
	KeySemicolon    = int32(glfw.KeySemicolon)
	KeyEqual        = int32(glfw.KeyEqual)
	KeyComma        = int32(glfw.KeyComma)
	KeyPeriod       = int32(glfw.KeyPeriod)
	KeySlash        = int32(glfw.KeySlash)
	KeyBackslash    = int32(glfw.KeyBackslash)
	KeyBackspace    = int32(glfw.KeyBackspace)
	KeyTab          = int32(glfw.KeyTab)
	KeyCapsLock     = int32(glfw.KeyCapsLock)
	KeySpace        = int32(glfw.KeySpace)
	KeyEnter        = int32(glfw.KeyEnter)
	KeyEscape       = int32(glfw.KeyEscape)
	KeyInsert       = int32(glfw.KeyInsert)
	KeyPrintScreen  = int32(glfw.KeyPrintScreen)
	KeyDelete       = int32(glfw.KeyDelete)
	KeyPageUp       = int32(glfw.KeyPageUp)
	KeyPageDown     = int32(glfw.KeyPageDown)
	KeyHome         = int32(glfw.KeyHome)
	KeyEnd          = int32(glfw.KeyEnd)
	KeyPause        = int32(glfw.KeyPause)
	KeyScrollLock   = int32(glfw.KeyScrollLock)
	KeyLeft         = int32(glfw.KeyLeft)
	KeyRight        = int32(glfw.KeyRight)
	KeyDown         = int32(glfw.KeyDown)
	KeyUp           = int32(glfw.KeyUp)
	KeyLeftBracket  = int32(glfw.KeyLeftBracket)
	KeyLeftShift    = int32(glfw.KeyLeftShift)
	KeyLeftControl  = int32(glfw.KeyLeftControl)
	KeyLeftSuper    = int32(glfw.KeyLeftSuper)
	KeyLeftAlt      = int32(glfw.KeyLeftAlt)
	KeyRightBracket = int32(glfw.KeyRightBracket)
	KeyRightShift   = int32(glfw.KeyRightShift)
	KeyRightControl = int32(glfw.KeyRightControl)
	KeyRightSuper   = int32(glfw.KeyRightSuper)
	KeyRightAlt     = int32(glfw.KeyRightAlt)
	Key0            = int32(glfw.Key0)
	Key1            = int32(glfw.Key1)
	Key2            = int32(glfw.Key2)
	Key3            = int32(glfw.Key3)
	Key4            = int32(glfw.Key4)
	Key5            = int32(glfw.Key5)
	Key6            = int32(glfw.Key6)
	Key7            = int32(glfw.Key7)
	Key8            = int32(glfw.Key8)
	Key9            = int32(glfw.Key9)
	KeyF1           = int32(glfw.KeyF1)
	KeyF2           = int32(glfw.KeyF2)
	KeyF3           = int32(glfw.KeyF3)
	KeyF4           = int32(glfw.KeyF4)
	KeyF5           = int32(glfw.KeyF5)
	KeyF6           = int32(glfw.KeyF6)
	KeyF7           = int32(glfw.KeyF7)
	KeyF8           = int32(glfw.KeyF8)
	KeyF9           = int32(glfw.KeyF9)
	KeyF10          = int32(glfw.KeyF10)
	KeyF11          = int32(glfw.KeyF11)
	KeyF12          = int32(glfw.KeyF12)
	KeyA            = int32(glfw.KeyA)
	KeyB            = int32(glfw.KeyB)
	KeyC            = int32(glfw.KeyC)
	KeyD            = int32(glfw.KeyD)
	KeyE            = int32(glfw.KeyE)
	KeyF            = int32(glfw.KeyF)
	KeyG            = int32(glfw.KeyG)
	KeyH            = int32(glfw.KeyH)
	KeyI            = int32(glfw.KeyI)
	KeyJ            = int32(glfw.KeyJ)
	KeyK            = int32(glfw.KeyK)
	KeyL            = int32(glfw.KeyL)
	KeyM            = int32(glfw.KeyM)
	KeyN            = int32(glfw.KeyN)
	KeyO            = int32(glfw.KeyO)
	KeyP            = int32(glfw.KeyP)
	KeyQ            = int32(glfw.KeyQ)
	KeyR            = int32(glfw.KeyR)
	KeyS            = int32(glfw.KeyS)
	KeyT            = int32(glfw.KeyT)
	KeyU            = int32(glfw.KeyU)
	KeyV            = int32(glfw.KeyV)
	KeyW            = int32(glfw.KeyW)
	KeyX            = int32(glfw.KeyX)
	KeyY            = int32(glfw.KeyY)
	KeyZ            = int32(glfw.KeyZ)
	KeyNumLock      = int32(glfw.KeyNumLock)
	KeyKPMultiply   = int32(glfw.KeyKPMultiply)
	KeyKPDivide     = int32(glfw.KeyKPDivide)
	KeyKPAdd        = int32(glfw.KeyKPAdd)
	KeyKPSubtract   = int32(glfw.KeyKPSubtract)
	KeyKP0          = int32(glfw.KeyKP0)
	KeyKP1          = int32(glfw.KeyKP1)
	KeyKP2          = int32(glfw.KeyKP2)
	KeyKP3          = int32(glfw.KeyKP3)
	KeyKP4          = int32(glfw.KeyKP4)
	KeyKP5          = int32(glfw.KeyKP5)
	KeyKP6          = int32(glfw.KeyKP6)
	KeyKP7          = int32(glfw.KeyKP7)
	KeyKP8          = int32(glfw.KeyKP8)
	KeyKP9          = int32(glfw.KeyKP9)
	KeyKPDecimal    = int32(glfw.KeyKPDecimal)
	KeyKPEnter      = int32(glfw.KeyKPEnter)
)

Variables

This section is empty.

Functions

func DestroyImage

func DestroyImage(image Image)

func Random

func Random(min, max int) int

Types

type Audio

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

func NewAudio

func NewAudio(filepath string) *Audio

func (*Audio) IsPlaying

func (self *Audio) IsPlaying() bool

func (*Audio) Pause

func (self *Audio) Pause()

func (*Audio) Play

func (self *Audio) Play()

func (*Audio) Stop

func (self *Audio) Stop()

type Canvas

type Canvas struct {
	Width, Height int

	Window *glfw.Window
	// contains filtered or unexported fields
}

func NewCanvas

func NewCanvas(w, h int, title string) Canvas

func (Canvas) ApplicationExit

func (self Canvas) ApplicationExit()

func (*Canvas) DisableCursor

func (self *Canvas) DisableCursor()

func (*Canvas) EnableCursor

func (self *Canvas) EnableCursor()

func (Canvas) GetContext

func (self Canvas) GetContext() Context

func (*Canvas) OnKeyDown

func (self *Canvas) OnKeyDown(x KEY_PRESS)

func (*Canvas) OnKeyPress

func (self *Canvas) OnKeyPress(x KEY_PRESS)

func (*Canvas) OnKeyUp

func (self *Canvas) OnKeyUp(x KEY_PRESS)

func (*Canvas) OnMouseDown

func (self *Canvas) OnMouseDown(x MOUSE_PRESS)

func (*Canvas) OnMouseMove

func (self *Canvas) OnMouseMove(x MOUSE_MOVE)

func (*Canvas) OnMouseUp

func (self *Canvas) OnMouseUp(x MOUSE_PRESS)

func (*Canvas) OnWindowResize

func (self *Canvas) OnWindowResize(x WINDOW_RESIZE)

func (*Canvas) SetFullScreen

func (self *Canvas) SetFullScreen(full bool)

func (*Canvas) SetIcon

func (self *Canvas) SetIcon(iconpath string)

func (*Canvas) SetLoadResources

func (self *Canvas) SetLoadResources(x func())

func (*Canvas) SetLoopFunc

func (self *Canvas) SetLoopFunc(x func())

func (*Canvas) SetResizable

func (self *Canvas) SetResizable(b bool)

func (*Canvas) SetSwapInterval

func (self *Canvas) SetSwapInterval(i int)

func (*Canvas) Show

func (self *Canvas) Show()

type Clock

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

func NewClock

func NewClock() Clock

func (*Clock) DeltaTime

func (self *Clock) DeltaTime() float64

func (*Clock) FPS

func (self *Clock) FPS() int32

func (*Clock) Tick

func (self *Clock) Tick()

type Color

type Color struct {
	R, G, B, A float32
}

func NewColor

func NewColor(r, g, b float32, a ...float32) *Color

func (Color) RGBA

func (self Color) RGBA() (r, g, b, a float32)

type Context

type Context struct {
	Fill   fill
	Stroke stroke
}

func (Context) Background

func (self Context) Background(cor *Color)

Cor de fundo

func (*Context) DrawImage

func (self *Context) DrawImage(imagem *Image, p ...float32)

Desenha a imagem (na verdade é uma textura)

func (Context) Restore

func (self Context) Restore()

func (Context) Rotate

func (self Context) Rotate(angle float32)

func (Context) Translate

func (self Context) Translate(x, y float32)

type Font

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

func LoadFont

func LoadFont(file string, size int32) *Font

type Image

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

func LoadImage

func LoadImage(file string) *Image

func (Image) GetNumber

func (self Image) GetNumber() uint32

func (Image) GetSize

func (self Image) GetSize() (int32, int32)

func (*Image) SetImgNumber

func (self *Image) SetImgNumber(number uint32)

type KEY_PRESS

type KEY_PRESS func(key int32, mod int32)

type MOUSE_MOVE

type MOUSE_MOVE func(x, y float32)

type MOUSE_PRESS

type MOUSE_PRESS func(x, y float32, btn, mod int32)

type WINDOW_RESIZE

type WINDOW_RESIZE func(w, h int)

Directories

Path Synopsis
fps

Jump to

Keyboard shortcuts

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