Documentation ¶
Index ¶
- Constants
- Variables
- func CenterCursor(uiController *UIController, center bool)
- func Collision(obj1 *BasicObject, obj2 *BasicObject) bool
- func DrawLine(dst *ebiten.Image, x1, y1, x2, y2 float64, clr color.Color, camera *Camera)
- func LoadDefaultFonts(uiController *UIController)
- func PrepareTileSet(tilemap *Map)
- func RenderTextToImage(text []string, w, h int, fntSize float64, fnt *truetype.Font, ...) *ebiten.Image
- func SetCustomCursor(uiController *UIController, width, height, sx, sy int, ...)
- type Action
- type Animation
- func (a Animation) CurrentFrame() int
- func (a Animation) IsPaused() bool
- func (a *Animation) Pause()
- func (a *Animation) Play()
- func (a *Animation) Reset()
- func (a *Animation) Resume()
- func (a *Animation) ReturnImageParts() *BasicImageParts
- func (a *Animation) SetAnimationSpeed(s int)
- func (a *Animation) SetCurrentFrame(frame int)
- func (a *Animation) SetForward()
- func (a *Animation) SetFrameSpeed(speed int)
- func (a *Animation) SetReverse()
- func (a *Animation) Stop()
- func (a *Animation) Update()
- type AudioPlayer
- func (p *AudioPlayer) AddSongFromBytes(name string, fb []byte) error
- func (p *AudioPlayer) AddSongFromFile(name, filelocation string) error
- func (p *AudioPlayer) AddSoundEffectFromBytes(name string, fb []byte, volume float64) error
- func (p *AudioPlayer) AddSoundEffectFromFile(name, filelocation string, volume float64) error
- func (p *AudioPlayer) IsMusicMuted() bool
- func (p *AudioPlayer) IsSEMuted() bool
- func (p *AudioPlayer) MuteAll(m bool)
- func (p *AudioPlayer) MuteMusic(m bool)
- func (p *AudioPlayer) MuteSE(m bool)
- func (p *AudioPlayer) PlaySE(se string) error
- func (p *AudioPlayer) ReturnSongPlayer(name string) *audio.Player
- func (p *AudioPlayer) Update() error
- func (p *AudioPlayer) UpdateVolumeIfNeeded()
- type BaseGameState
- type BasicImageParts
- func (b *BasicImageParts) Dst(i int) (x0, y0, x1, y1 int)
- func (b *BasicImageParts) Len() int
- func (b *BasicImageParts) ReturnSourceRect() image.Rectangle
- func (b *BasicImageParts) ReverseX(reverse bool)
- func (b *BasicImageParts) SetDestinationDimensions(width, height int)
- func (b *BasicImageParts) SetScale(op *ebiten.DrawImageOptions)
- func (b *BasicImageParts) Src(i int) (x0, y0, x1, y1 int)
- func (b BasicImageParts) SubImage(img *ebiten.Image) *ebiten.Image
- type BasicObject
- func (obj *BasicObject) AddAngle(inc float64)
- func (obj *BasicObject) AddPosition(vX, vY float64)
- func (obj *BasicObject) AddX(vX float64)
- func (obj *BasicObject) AddY(vY float64)
- func (obj *BasicObject) Bottom() float64
- func (obj *BasicObject) BottomNoCenter() float64
- func (obj *BasicObject) Contains(srcX, srcY float64) bool
- func (obj *BasicObject) ContainsNoCenter(srcX, srcY float64) bool
- func (obj *BasicObject) Draw(screen *ebiten.Image) error
- func (obj BasicObject) GetAngle() float64
- func (obj *BasicObject) GetHealth() float64
- func (obj BasicObject) GetHeight() int
- func (obj BasicObject) GetHeightF() float64
- func (obj BasicObject) GetID() xid.ID
- func (obj BasicObject) GetIDasString() string
- func (obj BasicObject) GetPosition() (float64, float64)
- func (obj BasicObject) GetSize() (int, int)
- func (obj *BasicObject) GetSpeed() float64
- func (obj *BasicObject) GetVelocity() (float64, float64)
- func (obj BasicObject) GetWidth() int
- func (obj BasicObject) GetWidthF() float64
- func (obj BasicObject) GetX() float64
- func (obj BasicObject) GetY() float64
- func (obj *BasicObject) Left() float64
- func (obj *BasicObject) LeftNoCenter() float64
- func (obj BasicObject) ReturnVectorPosition() Vector2d
- func (obj *BasicObject) Right() float64
- func (obj *BasicObject) RightNoCenter() float64
- func (obj *BasicObject) SetAngle(angle float64)
- func (obj *BasicObject) SetCentered(isCentered bool)
- func (obj *BasicObject) SetCollision2D(isCircle bool)
- func (obj *BasicObject) SetID()
- func (obj *BasicObject) SetPosition(x, y float64)
- func (obj *BasicObject) SetSize(width, height int)
- func (obj *BasicObject) SetX(x float64)
- func (obj *BasicObject) SetY(y float64)
- func (obj *BasicObject) Top() float64
- func (obj *BasicObject) TopNoCenter() float64
- func (obj *BasicObject) Update()
- type BasicUIElement
- type Button
- type Camera
- func (c Camera) ApplyCameraTransform(op *ebiten.DrawImageOptions, applyZoom bool)
- func (c *Camera) Center(x, y float64)
- func (c *Camera) CenterX(x float64)
- func (c *Camera) CenterY(y float64)
- func (c *Camera) ChangeZoom()
- func (c *Camera) DrawCameraTransform(op *ebiten.DrawImageOptions)
- func (c *Camera) DrawCameraTransformIgnoreZoom(op *ebiten.DrawImageOptions)
- func (c *Camera) FollowObject(player GameObject, bounds bool)
- func (c *Camera) FollowObjectInBounds(player GameObject)
- func (c *Camera) FollowObjectNoBounds(player GameObject)
- func (c *Camera) FollowPlayer(player GameObject, worldWidth, worldHeight float64)
- func (c *Camera) GetDestination() (float64, float64)
- func (c Camera) GetOffsetX() float64
- func (c Camera) GetOffsetY() float64
- func (c Camera) GetScreenCoords(x, y float64) (float64, float64)
- func (c *Camera) GetX() float64
- func (c *Camera) GetY() float64
- func (c Camera) OnScreen(x, y float64, w, h int) bool
- func (c Camera) Position() (x, y float64)
- func (c *Camera) SetBounds(lowerX, upperX, lowerY, upperY float64)
- func (c *Camera) SetClamp(clamp bool)
- func (c *Camera) SetDimensions(width, height float64)
- func (c *Camera) SetOffsetX(offset float64)
- func (c *Camera) SetOffsetY(offset float64)
- func (c *Camera) SetPosition(x, y float64)
- func (c *Camera) SetShakeRadius(radius float64)
- func (c *Camera) SetSpeed(s float64)
- func (c *Camera) SetX(x float64)
- func (c *Camera) SetY(y float64)
- func (c *Camera) SetZoom(zoom float64)
- func (c *Camera) SetZoomGradual(zoom, speed float64)
- func (c *Camera) Shake()
- func (c *Camera) StartShaking(r float64)
- func (c *Camera) TransformMatrix() *ebiten.DrawImageOptions
- func (c *Camera) Update()
- func (c *Camera) ZoomIn()
- func (c *Camera) ZoomOut()
- type Cursor
- type Frame
- type Game
- func (g *Game) Draw(screen *ebiten.Image)
- func (g Game) GetGameState() GameState
- func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)
- func (g *Game) LoadAudio(gFunction GameLoadAudioFunction)
- func (g *Game) LoadImages(gFunction GameLoadImagesFunction)
- func (g Game) ScreenHeight() int
- func (g Game) ScreenSize() (w, h int)
- func (g Game) ScreenWidth() int
- func (g *Game) SetGameDrawLoop(gFunction GameDrawHelperFunction)
- func (g *Game) SetGameState(gs GameState)
- func (g *Game) SetGameStateLoop(gFunction GameHelperFunction)
- func (g *Game) SetMobile(m bool)
- func (g *Game) SetPauseState(gs GameState)
- func (g *Game) ToggleFullscreen()
- func (g *Game) UnPause()
- func (g *Game) Update(screen *ebiten.Image) error
- type GameData
- type GameDrawHelperFunction
- type GameHelperFunction
- type GameLoadAudioFunction
- type GameLoadImagesFunction
- type GameMode
- type GameObject
- type GamePad
- type GamePadManager
- type GameState
- type GameStateMsg
- type GameValuePair
- type GameValueType
- type HUD
- type ImageManager
- func (im *ImageManager) AddImage(name string, image *ebiten.Image)
- func (im *ImageManager) AddImageFromBytes(name string, b []byte) error
- func (im *ImageManager) AddImageFromFile(name string, path string) error
- func (im *ImageManager) LoadImageFromFile(name string, path string) error
- func (im *ImageManager) ReturnImage(name string) *ebiten.Image
- type InputController
- func (ic *InputController) Button(name string) Button
- func (ic *InputController) GetGameMouseCoords(camera *Camera) (x, y float64)
- func (ic *InputController) GetGameMouseCoordsNoZoom(camera *Camera) (x, y float64)
- func (ic *InputController) GetMouseCoords() (float64, float64)
- func (ic *InputController) LeftClick() MouseState
- func (ic *InputController) MouseButton(name string) MouseButton
- func (ic *InputController) MouseWheelDown() bool
- func (ic *InputController) MouseWheelUp() bool
- func (ic *InputController) RegisterButton(name string, triggerKeys ...ebiten.Key)
- func (ic *InputController) RegisterMouseButton(name string, buttons ...ebiten.MouseButton)
- func (ic *InputController) RightClick() MouseState
- func (ic *InputController) Update()
- type JukeBox
- type KeyManager
- type KeyState
- type Layer
- type Line
- type Map
- type MapObject
- type Menu
- func (m *Menu) AddElement(element []UIElement, action []func())
- func (m *Menu) Draw(screen *ebiten.Image, camera *Camera)
- func (m *Menu) PressSelected()
- func (m *Menu) ReturnSelected() (int, int)
- func (m *Menu) SelectHorizontal(id int)
- func (m *Menu) SelectVertical(id int)
- func (m *Menu) SetBackground(src *ebiten.Image, imgParts *BasicImageParts)
- func (m *Menu) SetPadding(x, y int)
- func (m *Menu) Update(input *InputController, offsetX, offsetY float64)
- type MenuElement
- type Modifier
- type Mouse
- type MouseButton
- type MouseState
- type PlayerHub
- type Point
- type Property
- type Rectangle
- type SpriteSheet
- type TextArea
- type TextBox
- type TextElement
- func NewTextElement(x, y float64, w, h int, fnt *truetype.Font, text []string, ...) *TextElement
- func NewTextElementCentered(x, y float64, w, h int, fnt *truetype.Font, text []string, ...) *TextElement
- func NewTextElementStationary(x, y float64, w, h int, fnt *truetype.Font, text []string, ...) *TextElement
- func (t *TextElement) Draw(screen *ebiten.Image, camera *Camera) error
- func (t *TextElement) DrawApplyZoom(screen *ebiten.Image) error
- func (t *TextElement) DrawPosition(screen *ebiten.Image, camera *Camera) error
- func (t *TextElement) Hide()
- func (t *TextElement) Highlighted() bool
- func (t *TextElement) ReturnText() string
- func (t *TextElement) SetCentered(c bool)
- func (t *TextElement) SetColor(color color.Color)
- func (t *TextElement) SetDropShadow(drop bool)
- func (t *TextElement) SetFontSize(fntSize float64)
- func (t *TextElement) SetHighlightColor(c color.Color)
- func (t *TextElement) SetPosition(x, y float64)
- func (t *TextElement) SetText(text []string)
- func (t *TextElement) SetTextColor(c color.Color)
- func (t *TextElement) Show()
- func (t *TextElement) UnHighlighted() bool
- func (t *TextElement) Update()
- type Tile
- type TileLayer
- type TileMap
- type TileSet
- type UIController
- func (ui *UIController) ActivateMenu(name string)
- func (ui *UIController) ActiveMenu() string
- func (ui *UIController) AddFont(fntName string, tt *truetype.Font)
- func (ui *UIController) AddFontFile(fntName, fntFileLoc string) error
- func (ui *UIController) AddFontFromBytes(fntName string, bytes []byte) error
- func (ui *UIController) AddMenu(name string, menu *Menu)
- func (ui *UIController) AddTextDisplay(name string, textElement *TextElement)
- func (ui *UIController) DeActivateMenu(name string)
- func (ui UIController) Draw(screen *ebiten.Image, camera *Camera) error
- func (ui *UIController) HideMouse()
- func (ui *UIController) HideTextElement(name string)
- func (ui *UIController) LoadDefaultFonts()
- func (ui *UIController) ReturnFont(name string) *truetype.Font
- func (ui *UIController) SetCustomCursor(width, height, sx, sy int, spritesheet *ebiten.Image)
- func (ui *UIController) ShowMouse()
- func (ui *UIController) ShowTextElement(name string)
- func (ui *UIController) TextElementExists(name string) bool
- func (ui *UIController) ToggleMenu(name string)
- func (ui *UIController) Update()
- func (ui *UIController) UpdateTextPosition(name string, x, y float64)
- func (ui *UIController) WriteText(text []string, name, font string, x, y float64, w, h int, ...)
- type UIElement
- type UINumberDisplay
- type UINumberDisplayInt
- type UITextDisplay
- type Vector2d
- func (v *Vector2d) Add(other Vector2d)
- func (v Vector2d) Angle(u Vector2d) float64
- func (v Vector2d) Cross(other Vector2d) float64
- func (v Vector2d) Crossf(other float64) Vector2d
- func (v *Vector2d) Div(other float64)
- func (v Vector2d) Dot(other Vector2d) float64
- func (v Vector2d) Length() float64
- func (v Vector2d) LengthSquared() float64
- func (v *Vector2d) Limit(limit float64)
- func (v Vector2d) Minus(v2 Vector2d) *Vector2d
- func (v *Vector2d) Mul(other float64)
- func (v *Vector2d) Normalize()
- func (v Vector2d) Normalized() *Vector2d
- func (v Vector2d) Plus(v2 Vector2d) *Vector2d
- func (v *Vector2d) Sub(other Vector2d)
- func (v *Vector2d) Subf(number float64)
- func (v Vector2d) Times(r float64) *Vector2d
- func (v Vector2d) ToString() string
Constants ¶
const ( CursorCrosshair = iota CursorPointer )
Types of cursors
const ( FntRegular string = "FontGoRegular" FntMono = "FontGoMono" FntBold = "FontGoBold" FntItalic = "FontGoItalic" FntBoldItalic = "FontGoBoldItalic" FntMonoBold = "FontMonoBold" FntMonoItalic = "FontMonoItalic" FntMonoBoldItalic = "FontMonoBoldItalic" )
Available Go Fonts
const ( //GameStateMsgNone is the default empty message GameStateMsgNone GameStateMsg = "" //GameStateMsgPause pauses the game GameStateMsgPause = "Paused" //GameStateMsgUnPause resumes the game from a paused state GameStateMsgUnPause = "UnPaused" //GameStateMsgNotStarted is used to call the game init GameStateMsgNotStarted = "Game Not Init" )
const ( // KeyStateUp is a state for when the key is not currently being pressed KeyStateUp = iota // KeyStateDown is a state for when the key is currently being pressed KeyStateDown // KeyStateJustDown is a state for when a key was just pressed KeyStateJustDown // KeyStateJustUp is a state for when a key was just released KeyStateJustUp )
const ( // MouseStateUp is a state for when the key is not currently being pressed MouseStateUp = iota // MouseStateDown is a state for when the key is currently being pressed MouseStateDown // MouseStateJustDown is a state for when a key was just pressed MouseStateJustDown // MouseStateJustUp is a state for when a key was just released MouseStateJustUp // MouseStateWheel is a state for when the mouse wheel is moved MouseStateWheel )
Variables ¶
var ( // Move is an action representing mouse movement Move = Action(0) // Press is an action representing a mouse press/click Press = Action(1) // Release is an action representing a mouse a release Release = Action(2) // Neutral represents a neutral action Neutral = Action(99) // Shift represents the shift modifier. // It is triggered when the shift key is pressed simultaneously with another key Shift = Modifier(0x0001) // Control represents the control modifier // It is triggered when the ctrl key is pressed simultaneously with another key Control = Modifier(0x0002) // Alt represents the alt modifier // It is triggered when the alt key is pressed simultaneously with another key Alt = Modifier(0x0004) // Super represents the super modifier // (Windows key on Microsoft Windows, Command key on Apple OSX, and varies on Linux) // It is triggered when the super key is pressed simultaneously with another key Super = Modifier(0x0008) )
var Pixel *ebiten.Image
Pixel is a 1x1 white pixel that can be used for simple drawing
Functions ¶
func CenterCursor ¶
func CenterCursor(uiController *UIController, center bool)
CenterCursor sets whether the cursor is centered or not
func Collision ¶
func Collision(obj1 *BasicObject, obj2 *BasicObject) bool
Collision returns true if two given BasicObjects are overlapping
func DrawLine ¶
DrawLine draws a line segment on the given destination dst.
DrawLine is intended to be used mainly for debugging or prototyping purpose.
func LoadDefaultFonts ¶
func LoadDefaultFonts(uiController *UIController)
LoadDefaultFonts adds the Go supplied fonts to the tentsuyu UIController
func PrepareTileSet ¶
func PrepareTileSet(tilemap *Map)
PrepareTileSet imports the tileset image, and sets LastGID and Rows for easier calculation
func RenderTextToImage ¶
func RenderTextToImage(text []string, w, h int, fntSize float64, fnt *truetype.Font, textColor color.Color) *ebiten.Image
RenderTextToImage takes a given slice of strings and returns a pointer to an ebiten.Image
func SetCustomCursor ¶
func SetCustomCursor(uiController *UIController, width, height, sx, sy int, spritesheet *ebiten.Image)
SetCustomCursor to allow for drawing your own cursor object
Types ¶
type Animation ¶
type Animation struct { ImageParts *BasicImageParts SpriteSheet *SpriteSheet Frames []int LoopCompleted bool Repeating bool // contains filtered or unexported fields }
Animation is used to control animation frames
func NewAnimation ¶
func NewAnimation(spriteSheet *SpriteSheet, frames []int, speed int) *Animation
NewAnimation takes a spritesheet, []int of frames to play, and speed to return an Animation
func (Animation) CurrentFrame ¶
CurrentFrame returns the current frame of the animation
func (*Animation) ReturnImageParts ¶
func (a *Animation) ReturnImageParts() *BasicImageParts
ReturnImageParts of the current animation
func (*Animation) SetAnimationSpeed ¶
SetAnimationSpeed changes the speed of the animation to the passed value
func (*Animation) SetCurrentFrame ¶
SetCurrentFrame of the current animation
func (*Animation) SetForward ¶
func (a *Animation) SetForward()
SetForward tells the animation to play normally. This should only be necessary after calling SetReverse()
func (*Animation) SetFrameSpeed ¶
SetFrameSpeed of the current animation
func (*Animation) SetReverse ¶
func (a *Animation) SetReverse()
SetReverse tells the animation to play in reverse
type AudioPlayer ¶
type AudioPlayer struct {
// contains filtered or unexported fields
}
AudioPlayer represents the current audio state.
func NewAudioPlayer ¶
func NewAudioPlayer() (*AudioPlayer, error)
NewAudioPlayer returns a new AudioPlayer
func (*AudioPlayer) AddSongFromBytes ¶
func (p *AudioPlayer) AddSongFromBytes(name string, fb []byte) error
AddSongFromBytes takes the byte slice of the song file
func (*AudioPlayer) AddSongFromFile ¶
func (p *AudioPlayer) AddSongFromFile(name, filelocation string) error
AddSongFromFile to the AudioPlayer
func (*AudioPlayer) AddSoundEffectFromBytes ¶
func (p *AudioPlayer) AddSoundEffectFromBytes(name string, fb []byte, volume float64) error
AddSoundEffectFromBytes adds a new sound effect file from a byte slice
func (*AudioPlayer) AddSoundEffectFromFile ¶
func (p *AudioPlayer) AddSoundEffectFromFile(name, filelocation string, volume float64) error
AddSoundEffectFromFile adds a SE of the given name and volume at the file location.
func (*AudioPlayer) IsMusicMuted ¶
func (p *AudioPlayer) IsMusicMuted() bool
IsMusicMuted returns true if the music is muted for the AudioPlayer
func (*AudioPlayer) IsSEMuted ¶
func (p *AudioPlayer) IsSEMuted() bool
IsSEMuted returns true if the sound effects are muted for the AudioPlayer
func (*AudioPlayer) MuteAll ¶
func (p *AudioPlayer) MuteAll(m bool)
MuteAll sets the mute state of both SoundEffects and Music
func (*AudioPlayer) MuteMusic ¶
func (p *AudioPlayer) MuteMusic(m bool)
MuteMusic sets the mute state of Music
func (*AudioPlayer) MuteSE ¶
func (p *AudioPlayer) MuteSE(m bool)
MuteSE sets the mute state of SoundEffects
func (*AudioPlayer) PlaySE ¶
func (p *AudioPlayer) PlaySE(se string) error
PlaySE playes the sound effect with the given name
func (*AudioPlayer) ReturnSongPlayer ¶
func (p *AudioPlayer) ReturnSongPlayer(name string) *audio.Player
ReturnSongPlayer returns the player for the song audio
func (*AudioPlayer) Update ¶
func (p *AudioPlayer) Update() error
Update isn't currently used for the AudioPlayer TODO: Implement this ... if necessary
func (*AudioPlayer) UpdateVolumeIfNeeded ¶
func (p *AudioPlayer) UpdateVolumeIfNeeded()
UpdateVolumeIfNeeded should be used to listen to changing the volume level TODO: Implement this
type BaseGameState ¶
type BaseGameState struct {
GameStateMessage GameStateMsg
}
BaseGameState implements the basic methods to satisfy the GameState interface
func NewBaseGameState ¶
func NewBaseGameState() *BaseGameState
NewBaseGameState returns a BaseGameState with default GameStateMessage
func (*BaseGameState) Draw ¶
func (b *BaseGameState) Draw(g *Game) error
Draw is a dummy method for BaseGameState
func (*BaseGameState) Msg ¶
func (b *BaseGameState) Msg() GameStateMsg
Msg returns the GameStateMessage of the BaseGameState
func (*BaseGameState) SetMsg ¶
func (b *BaseGameState) SetMsg(g GameStateMsg)
SetMsg sets the GameStateMessage of BaseGameState to the passed parameter
func (*BaseGameState) Update ¶
func (b *BaseGameState) Update(g *Game) error
Update is a dummy method for BaseGameState
type BasicImageParts ¶
type BasicImageParts struct {
Width, Height, Sx, Sy, DestWidth, DestHeight int
Reverse bool
SourceRect *image.Rectangle
}
BasicImageParts is easy to set up basic sprite image
func BasicImagePartsFromSpriteSheet ¶
func BasicImagePartsFromSpriteSheet(spriteSheet *SpriteSheet, frame int) *BasicImageParts
BasicImagePartsFromSpriteSheet creates a BasicImageParts from a passed spritesheet on the passed frame. This is helpful to easily get the correct sx,sy,w,h without manually typing it in every time.
func NewBasicImageParts ¶
func NewBasicImageParts(sx, sy, width, height int) *BasicImageParts
NewBasicImageParts returns a pointer to new BasicImageParts
func (*BasicImageParts) Dst ¶
func (b *BasicImageParts) Dst(i int) (x0, y0, x1, y1 int)
Dst we just make it 1:1
func (*BasicImageParts) ReturnSourceRect ¶
func (b *BasicImageParts) ReturnSourceRect() image.Rectangle
ReturnSourceRect returns the image.Rectangle for the subImage in ebtien This replaces the overall ImageParts struct
func (*BasicImageParts) ReverseX ¶
func (b *BasicImageParts) ReverseX(reverse bool)
ReverseX flips the image
func (*BasicImageParts) SetDestinationDimensions ¶
func (b *BasicImageParts) SetDestinationDimensions(width, height int)
SetDestinationDimensions can be used to set the size the image should be drawn to the screen
func (*BasicImageParts) SetScale ¶
func (b *BasicImageParts) SetScale(op *ebiten.DrawImageOptions)
SetScale sets the scale of the DrawImageOptions based on the given DestHeight and DestWidth of the BasicImageParts
func (*BasicImageParts) Src ¶
func (b *BasicImageParts) Src(i int) (x0, y0, x1, y1 int)
Src cuts out the specified rectangle from the source image to display the sprite
func (BasicImageParts) SubImage ¶
func (b BasicImageParts) SubImage(img *ebiten.Image) *ebiten.Image
SubImage returns the sub image of the passed ebiten.Image based on the BasicImageParts properties Reduces the amount of coding needed in the actual game to get to drawing the image
type BasicObject ¶
type BasicObject struct {
Angle, Speed, PrevX, PrevY float64
VX, VY float64
NotCentered bool
Width, Height int
WidthF, HeightF float64
ID xid.ID
Velocity *Vector2d
Position *Vector2d
// contains filtered or unexported fields
}
BasicObject is the bare implementation of a GameObject
func NewBasicObject ¶
func NewBasicObject(x, y float64, w, h int) *BasicObject
NewBasicObject returns a new oject
func (*BasicObject) AddAngle ¶
func (obj *BasicObject) AddAngle(inc float64)
AddAngle adds the provided increment to the angle RADIAN
func (*BasicObject) AddPosition ¶
func (obj *BasicObject) AddPosition(vX, vY float64)
AddPosition increases X and Y position by vX and vY respectively
func (*BasicObject) BottomNoCenter ¶
func (obj *BasicObject) BottomNoCenter() float64
BottomNoCenter edge of the rectangle
func (*BasicObject) Contains ¶
func (obj *BasicObject) Contains(srcX, srcY float64) bool
Contains returns true if the given point is withing the rectangle of the object
func (*BasicObject) ContainsNoCenter ¶
func (obj *BasicObject) ContainsNoCenter(srcX, srcY float64) bool
ContainsNoCenter returns true if the given point is withing the rectangle of the object
func (*BasicObject) Draw ¶
func (obj *BasicObject) Draw(screen *ebiten.Image) error
Draw for GameObject This should be overriden by user
func (*BasicObject) GetHealth ¶
func (obj *BasicObject) GetHealth() float64
GetHealth should return BasicObject Health
func (BasicObject) GetHeightF ¶
func (obj BasicObject) GetHeightF() float64
GetHeightF returns height as a float64
func (BasicObject) GetID ¶
func (obj BasicObject) GetID() xid.ID
GetID returns the guid of the Basic Object
func (BasicObject) GetIDasString ¶
func (obj BasicObject) GetIDasString() string
GetIDasString returns the string representation of the guid
func (BasicObject) GetPosition ¶
func (obj BasicObject) GetPosition() (float64, float64)
GetPosition returns the x,y coords
func (BasicObject) GetSize ¶
func (obj BasicObject) GetSize() (int, int)
GetSize returns width and height
func (*BasicObject) GetSpeed ¶
func (obj *BasicObject) GetSpeed() float64
GetSpeed returns the BasicObject speed
func (*BasicObject) GetVelocity ¶
func (obj *BasicObject) GetVelocity() (float64, float64)
GetVelocity returns Vx and Vy of the BasicObject
func (BasicObject) GetWidthF ¶
func (obj BasicObject) GetWidthF() float64
GetWidthF returns width as a float64
func (*BasicObject) LeftNoCenter ¶
func (obj *BasicObject) LeftNoCenter() float64
LeftNoCenter edge of the rectangle
func (BasicObject) ReturnVectorPosition ¶
func (obj BasicObject) ReturnVectorPosition() Vector2d
ReturnVectorPosition returns the X,Y position as a vector2d This is useful for vector math
func (*BasicObject) RightNoCenter ¶
func (obj *BasicObject) RightNoCenter() float64
RightNoCenter edge of the rectangle
func (*BasicObject) SetAngle ¶
func (obj *BasicObject) SetAngle(angle float64)
SetAngle of BasicObject
func (*BasicObject) SetCentered ¶
func (obj *BasicObject) SetCentered(isCentered bool)
SetCentered of the object. If true the object coords refer to the center of the object. If false the object coords refer to the top left of the object.
func (*BasicObject) SetCollision2D ¶
func (obj *BasicObject) SetCollision2D(isCircle bool)
SetCollision2D will allow the object to use more advanced collision functions
func (*BasicObject) SetID ¶
func (obj *BasicObject) SetID()
SetID sets the BasicObject's ID to a new guid
func (*BasicObject) SetPosition ¶
func (obj *BasicObject) SetPosition(x, y float64)
SetPosition of x,y
func (*BasicObject) SetSize ¶
func (obj *BasicObject) SetSize(width, height int)
SetSize with width , height
func (*BasicObject) TopNoCenter ¶
func (obj *BasicObject) TopNoCenter() float64
TopNoCenter edge of the rectangle
func (*BasicObject) Update ¶
func (obj *BasicObject) Update()
Update for GameObject This should be overriden by user
type BasicUIElement ¶
type BasicUIElement struct { *BasicObject // contains filtered or unexported fields }
BasicUIElement is so I don't have to rewrite the same functions
func NewBasicUIElement ¶
func NewBasicUIElement(x, y float64, w, h int) *BasicUIElement
NewBasicUIElement creates a BasicUIElement
func (*BasicUIElement) AddPosition ¶
func (u *BasicUIElement) AddPosition(x, y float64)
AddPosition adds the specified values to the x and y position
func (*BasicUIElement) Contains ¶
func (u *BasicUIElement) Contains(x, y float64) bool
Contains the specified x and y position
func (*BasicUIElement) Highlighted ¶
func (u *BasicUIElement) Highlighted() bool
Highlighted returns if the element is Highlighted
func (BasicUIElement) Size ¶
func (u BasicUIElement) Size() (int, int)
Size returns the elements size
func (*BasicUIElement) UnHighlighted ¶
func (u *BasicUIElement) UnHighlighted() bool
UnHighlighted returns if the element is Highlighted
type Button ¶
type Button struct { Triggers []ebiten.Key Name string // contains filtered or unexported fields }
A Button is an input which can be either JustPressed, JustReleased or Down. Common uses would be for, a jump key or an action key.
func NewButton ¶
func NewButton(name string, triggerKeys []ebiten.Key, input *InputController) Button
NewButton creates a new button
func (Button) JustPressed ¶
JustPressed checks whether an input was pressed in the previous frame.
func (Button) JustReleased ¶
JustReleased checks whether an input was released in the previous frame.
type Camera ¶
type Camera struct {
Width, Height, Zoom, ScreenWidth, ScreenHeight float64
FreeFloating bool
MaxZoomOut, MaxZoomIn float64
// contains filtered or unexported fields
}
Camera is the entity that follows our player so he doesn't walk off screen
func CreateCamera ¶
CreateCamera intializes a camera struct
func (Camera) ApplyCameraTransform ¶
ApplyCameraTransform applies the camera's position to the DrawImageOptions, bool toggles whether zoom is applied or not
func (*Camera) ChangeZoom ¶
func (c *Camera) ChangeZoom()
ChangeZoom increments or decrements the camera zoom level
func (*Camera) DrawCameraTransform ¶
func (c *Camera) DrawCameraTransform(op *ebiten.DrawImageOptions)
DrawCameraTransform appls the TransformMatrix of the camera to the specified image options This translates the opposite direction of the TransformMatrix
func (*Camera) DrawCameraTransformIgnoreZoom ¶
func (c *Camera) DrawCameraTransformIgnoreZoom(op *ebiten.DrawImageOptions)
DrawCameraTransformIgnoreZoom is same as DrawCameraTransform minus the zoom
func (*Camera) FollowObject ¶
func (c *Camera) FollowObject(player GameObject, bounds bool)
FollowObject follows the given GameObject either within or without bounds
func (*Camera) FollowObjectInBounds ¶
func (c *Camera) FollowObjectInBounds(player GameObject)
FollowObjectInBounds follows the given GameObject within the bounds of the camera
func (*Camera) FollowObjectNoBounds ¶
func (c *Camera) FollowObjectNoBounds(player GameObject)
FollowObjectNoBounds follows the given GameObject without boundaries
func (*Camera) FollowPlayer ¶
func (c *Camera) FollowPlayer(player GameObject, worldWidth, worldHeight float64)
FollowPlayer follows the specified character (in this case the player)
func (*Camera) GetDestination ¶
GetDestination of camera (x,y)
func (Camera) GetOffsetX ¶
GetOffsetX returns the camera X offset position
func (Camera) GetOffsetY ¶
GetOffsetY returns the camera Y offset position
func (Camera) GetScreenCoords ¶
GetScreenCoords returns where the passed coords would be on the screen space
func (*Camera) SetDimensions ¶
SetDimensions sets the width and height of the camera
func (*Camera) SetOffsetX ¶
SetOffsetX sets the offset X
func (*Camera) SetOffsetY ¶
SetOffsetY sets the offset Y
func (*Camera) SetPosition ¶
SetPosition by passing both x and y coordinates of the camera
func (*Camera) SetShakeRadius ¶
SetShakeRadius for the camera shake
func (*Camera) SetZoomGradual ¶
SetZoomGradual zooms into the passed zoom value and a given speed TODO: Implement this
func (*Camera) StartShaking ¶
StartShaking begins the camera shake with the passed intensity
func (*Camera) TransformMatrix ¶
func (c *Camera) TransformMatrix() *ebiten.DrawImageOptions
TransformMatrix of the camera (currently for concept purposes only... but is correct)
type Cursor ¶
type Cursor struct { *BasicObject *BasicImageParts // contains filtered or unexported fields }
Cursor represents the player's mouse position
type Frame ¶
type Frame struct { Filename string `json:"filename"` Frame map[string]int `json:"frame"` // x, y, w, h Rotated bool `json:"rotated"` Trimmed bool `json:"trimmed"` SpriteSourceSize map[string]int `json:"spriteSourceSize"` SourceSize map[string]int `json:"sourceSize"` Pivot map[string]float64 `json:"pivot"` }
Frame represents a single frame of a spritesheet
type Game ¶
type Game struct { PausedState GameState GameData *GameData Screen *ebiten.Image DefaultCamera *Camera UIController *UIController Random *rand.Rand Input *InputController ImageManager *ImageManager GameStateLoop GameHelperFunction GameDrawLoop GameDrawHelperFunction AudioPlayer *AudioPlayer AdditionalCameras map[string]*Camera IsMobile bool // contains filtered or unexported fields }
Game represents, well... the game
func (*Game) Draw ¶
func (g *Game) Draw(screen *ebiten.Image)
Draw draws the game screen. Draw is called every frame (typically 1/60[s] for 60Hz display).
func (*Game) Layout ¶
Layout takes the outside size (e.g., the window size) and returns the (logical) screen size. If you don't have to adjust the screen size with the outside size, just return a fixed size.
func (*Game) LoadAudio ¶
func (g *Game) LoadAudio(gFunction GameLoadAudioFunction)
LoadAudio will set the audioLoadedCh to the passed GameHelperFunction This is used to load audio before a gamestate is set
func (*Game) LoadImages ¶
func (g *Game) LoadImages(gFunction GameLoadImagesFunction)
LoadImages will set the imageLoadedCh to the passed GameHlperFunction This is used to load images before a gamestate is set
func (Game) ScreenHeight ¶
ScreenHeight returns the height of the game screen
func (Game) ScreenSize ¶
ScreenSize returns the width and height of the game screen
func (Game) ScreenWidth ¶
ScreenWidth returns the width of the game screen
func (*Game) SetGameDrawLoop ¶
func (g *Game) SetGameDrawLoop(gFunction GameDrawHelperFunction)
SetGameDrawLoop allows the user to add a final draw over the game screen no matter what state the game is in.
func (*Game) SetGameStateLoop ¶
func (g *Game) SetGameStateLoop(gFunction GameHelperFunction)
SetGameStateLoop should be a switch statement telling the game when to switch to what gamestate This is where your gamestate logic will exist
func (*Game) SetMobile ¶
SetMobile tells the game if it's on mobile or not This is useful to know whether to check for touches or keys
func (*Game) SetPauseState ¶
SetPauseState of the game This changes the PausedState to the current GameState then switches to the passed GameState. Used to preserve the current game state
func (*Game) ToggleFullscreen ¶
func (g *Game) ToggleFullscreen()
ToggleFullscreen toggles the game in or out of full screen
type GameData ¶
type GameData struct { Settings map[string]*GameValuePair // contains filtered or unexported fields }
GameData holds the various data to be passed between game states
func (*GameData) SetCurrentScore ¶
SetCurrentScore sets the current score of the game
func (*GameData) SetHighScore ¶
SetHighScore compares the given score to current highscore and updates if it's greater
func (*GameData) TimeInMilliseconds ¶
TimeInMilliseconds returns the current time in seconds
func (*GameData) TimeInSecond ¶
TimeInSecond returns the current time in seconds
type GameDrawHelperFunction ¶
type GameDrawHelperFunction func(*ebiten.Image) error
GameDrawHelperFunction is meant to draw something on the passed ebiten.Image
type GameHelperFunction ¶
type GameHelperFunction func() error
GameHelperFunction is a function that takes no parameters and returns an error
type GameLoadAudioFunction ¶
type GameLoadAudioFunction func() *AudioPlayer
GameLoadAudioFunction returns an AudioPlayer and is used to load new audio into the game
type GameLoadImagesFunction ¶
type GameLoadImagesFunction func() *ImageManager
GameLoadImagesFunction returns an ImageManager which is used to load new images into the game
type GameObject ¶
type GameObject interface { GetPosition() (float64, float64) SetPosition(float64, float64) GetWidth() int GetHeight() int //Update() Draw(*ebiten.Image) error Contains(float64, float64) bool GetHealth() float64 GetAngle() float64 GetVelocity() (float64, float64) }
GameObject is any renderable object
type GamePadManager ¶
type GamePadManager struct {
GamePads []*GamePad
}
GamePadManager contains all the available gamepads
func NewGamePadManager ¶
func NewGamePadManager() *GamePadManager
NewGamePadManager returns an empty GamePadManager
type GameState ¶
type GameState interface { Update(*Game) error Draw(*Game) error Msg() GameStateMsg SetMsg(GameStateMsg) }
GameState represents what all game states must conform to
type GameValuePair ¶
type GameValuePair struct { Name string ValueType GameValueType ValueText string ValueInt int ValueFloat float64 }
GameValuePair is used to add settings and various values to the GameData structure
type GameValueType ¶
type GameValueType int
GameValueType is the available types of values use in the GameValuePair struct
const ( //GameValueText means the value is a string GameValueText GameValueType = iota //GameValueInt means the value is an integer GameValueInt //GameValueFloat means the value is a float64 GameValueFloat )
type HUD ¶
type HUD struct {
// contains filtered or unexported fields
}
HUD represents the player's Heads Up Display
func (*HUD) AddBottomLeft ¶
AddBottomLeft of the HUD
func (*HUD) AddBottomRight ¶
AddBottomRight of the HUD
type ImageManager ¶
type ImageManager struct {
Images map[string]*ebiten.Image
}
ImageManager is a struct containing a map of named ebiten.Images
func NewImageManager ¶
func NewImageManager() *ImageManager
NewImageManager creates a new pointer to ImageManager
func (*ImageManager) AddImage ¶
func (im *ImageManager) AddImage(name string, image *ebiten.Image)
AddImage adds an ebiten.Image to the map with a given name
func (*ImageManager) AddImageFromBytes ¶
func (im *ImageManager) AddImageFromBytes(name string, b []byte) error
AddImageFromBytes adds in the image based on a byte slice Very helpful with using file2byteslice by HajimeHoshi
func (*ImageManager) AddImageFromFile ¶
func (im *ImageManager) AddImageFromFile(name string, path string) error
AddImageFromFile loads the given image at "path" with "name"
func (*ImageManager) LoadImageFromFile ¶
func (im *ImageManager) LoadImageFromFile(name string, path string) error
LoadImageFromFile [Deprecated - use AddImageFromFile]
func (*ImageManager) ReturnImage ¶
func (im *ImageManager) ReturnImage(name string) *ebiten.Image
ReturnImage retrieves the specified image name
type InputController ¶
type InputController struct { Mouse *Mouse // contains filtered or unexported fields }
InputController controls all input for the game
func NewInputController ¶
func NewInputController() *InputController
NewInputController returns a new InputController
func (*InputController) Button ¶
func (ic *InputController) Button(name string) Button
Button retrieves a Button with a specified name.
func (*InputController) GetGameMouseCoords ¶
func (ic *InputController) GetGameMouseCoords(camera *Camera) (x, y float64)
GetGameMouseCoords returns the game coords based on the camera position and zoom
func (*InputController) GetGameMouseCoordsNoZoom ¶
func (ic *InputController) GetGameMouseCoordsNoZoom(camera *Camera) (x, y float64)
GetGameMouseCoordsNoZoom is the same as GetGameMouseCoords but ignores the camera's zoom level (useful for drawing the cursor)
func (*InputController) GetMouseCoords ¶
func (ic *InputController) GetMouseCoords() (float64, float64)
GetMouseCoords returns the ebiten mouse coords
func (*InputController) LeftClick ¶
func (ic *InputController) LeftClick() MouseState
LeftClick returns the Mouse left click button
func (*InputController) MouseButton ¶
func (ic *InputController) MouseButton(name string) MouseButton
MouseButton retrieves a Button with a specified name.
func (*InputController) MouseWheelDown ¶
func (ic *InputController) MouseWheelDown() bool
MouseWheelDown returns true if the user is scrolling down
func (*InputController) MouseWheelUp ¶
func (ic *InputController) MouseWheelUp() bool
MouseWheelUp returns true if the user is scrolling up
func (*InputController) RegisterButton ¶
func (ic *InputController) RegisterButton(name string, triggerKeys ...ebiten.Key)
RegisterButton registers a new button input.
func (*InputController) RegisterMouseButton ¶
func (ic *InputController) RegisterMouseButton(name string, buttons ...ebiten.MouseButton)
RegisterMouseButton adds the mouse button to the game with the given name
func (*InputController) RightClick ¶
func (ic *InputController) RightClick() MouseState
RightClick returns the Mouse left click button
type JukeBox ¶
type JukeBox struct { AudioPlayer *AudioPlayer SongList []string CurrSong string NextSong string PrevSong string BGDefaultVol float64 CurrVol float64 // contains filtered or unexported fields }
JukeBox is used to control BG Music at least. Possible SE support
func CreateJukeBox ¶
func CreateJukeBox(audioPlayer *AudioPlayer, musicList []string) *JukeBox
CreateJukeBox from passed audioplayer, music and sound effect lists
func (*JukeBox) ContinuousPlay ¶
ContinuousPlay of the song based on passed song name
func (*JukeBox) CurrentSongName ¶
CurrentSongName returns the name of the song that is currently being played
type KeyManager ¶
type KeyManager struct {
// contains filtered or unexported fields
}
KeyManager tracks which keys are pressed and released at the current point of time.
func (*KeyManager) AddKey ¶
func (km *KeyManager) AddKey(k ebiten.Key)
AddKey adds the ebiten.Key to the list of keys being managed
func (*KeyManager) Get ¶
func (km *KeyManager) Get(k ebiten.Key) KeyState
Get retrieves a keys state.
func (*KeyManager) Set ¶
func (km *KeyManager) Set(k ebiten.Key, state bool)
Set is used for updating whether or not a key is held down, or not held down.
type KeyState ¶
type KeyState struct {
// contains filtered or unexported fields
}
KeyState is used for detecting the state of a key press.
func (KeyState) JustPressed ¶
JustPressed returns whether a key was just pressed
func (KeyState) JustReleased ¶
JustReleased returns whether a key was just released
type Layer ¶
type Layer struct { Name string `json:"name"` Type string `json:"type"` X int `json:"x"` Y int `json:"y"` Width int `json:"width"` Height int `json:"height"` Data []int `json:"data"` Opacity int `json:"opacity"` Visible bool `json:"visible"` Properties []*Property `json:"properties"` DrawOrder string `json:"draworder"` Objects []*MapObject `json:"objects"` }
Layer represents a Tiled Layer
type Line ¶
type Line struct {
X1, Y1, X2, Y2, Angle, Length float64
}
Line represents a line from (X1,Y1) to (X2,Y2)
func NewLineFromTo ¶
NewLineFromTo returns a Line beginning at (fromX,fromY) to (toX,toY)
func (Line) CalculateAngle ¶
CalculateAngle returns the line's angle
func (Line) CalculateLength ¶
CalculateLength returns the line's length
type Map ¶
type Map struct { Width int `json:"width"` Height int `json:"height"` Layers []*Layer `json:"layers"` Orientation string `json:"orientation"` TileWidth int `json:"tilewidth"` TileHeight int `json:"tileheight"` TileSets []*TileSet `json:"tilesets"` Properties []*Property `json:"properties"` Version int `json:"version"` }
Map represents an entire Tiled map
func ReadMapfromByte ¶
ReadMapfromByte reads an entire Map struct from a byte slice
func ReadMapfromString ¶
ReadMapfromString reads an entire Map struct from a given string (represented by json)
type MapObject ¶
type MapObject struct { Height int `json:"height"` ID int `json:"id"` Name string `json:"name"` Rotation float64 `json:"rotation"` Type string `json:"type"` Visible bool `json:"visible"` Width int `json:"width"` X float64 `json:"x"` Y float64 `json:"y"` }
MapObject is a representation of the Tiled Object
type Menu ¶
type Menu struct { Elements [][]*MenuElement Active bool Name string // contains filtered or unexported fields }
Menu is a collection of MenuElements
func (*Menu) AddElement ¶
AddElement adds a new Line of UIElements
func (*Menu) PressSelected ¶
func (m *Menu) PressSelected()
PressSelected exectures the Action of the currently selected option
func (*Menu) ReturnSelected ¶
ReturnSelected returns the Row and Col int of the current selected option
func (*Menu) SelectHorizontal ¶
SelectHorizontal moves the selection alrong the x-axis
func (*Menu) SelectVertical ¶
SelectVertical move the selection along the y-axis
func (*Menu) SetBackground ¶
func (m *Menu) SetBackground(src *ebiten.Image, imgParts *BasicImageParts)
SetBackground image for menu
func (*Menu) SetPadding ¶
SetPadding of the menus x and y values
func (*Menu) Update ¶
func (m *Menu) Update(input *InputController, offsetX, offsetY float64)
Update the menu
type MenuElement ¶
type MenuElement struct { UIElement Action func() Selectable bool // contains filtered or unexported fields }
MenuElement represents a single element/option within a menu
func (*MenuElement) Hide ¶
func (m *MenuElement) Hide(h bool)
Hide takes a bool and sets the hidden variable
func (*MenuElement) SetAction ¶
func (m *MenuElement) SetAction(function func())
SetAction of the MenuElement
func (*MenuElement) SetCentered ¶
func (m *MenuElement) SetCentered(c bool)
SetCentered centers the MenuElement based on bool value c
func (*MenuElement) Update ¶
func (m *MenuElement) Update(input *InputController, offsetX, offsetY float64) bool
Update the MenuElement
type Mouse ¶
type Mouse struct {
X, Y float64
// contains filtered or unexported fields
}
Mouse represents the cursor
func (*Mouse) AddKey ¶
func (m *Mouse) AddKey(k ebiten.MouseButton)
AddKey adds the ebiten.Key to the list of keys being managed
func (*Mouse) Get ¶
func (m *Mouse) Get(k ebiten.MouseButton) MouseState
Get retrieves a keys state.
func (*Mouse) GetGameMouseCoordsNoZoom ¶
GetGameMouseCoordsNoZoom is the same as GetGameMouseCoords but ignores the camera's zoom level (useful for drawing the cursor)
func (*Mouse) IsScrollDown ¶
IsScrollDown returns true if the user is scrolling down on the mouse wheel
func (*Mouse) IsScrollUp ¶
IsScrollUp returns true if the user is scrolling up on the mouse wheel
type MouseButton ¶
type MouseButton struct { Name string Triggers []ebiten.MouseButton // contains filtered or unexported fields }
MouseButton is a representation of one of the mouse buttons
func (MouseButton) Down ¶
func (b MouseButton) Down() bool
Down checks whether the current input is being held down.
func (MouseButton) JustPressed ¶
func (b MouseButton) JustPressed() bool
JustPressed checks whether an input was pressed in the previous frame.
func (MouseButton) JustReleased ¶
func (b MouseButton) JustReleased() bool
JustReleased checks whether an input was released in the previous frame.
type MouseState ¶
type MouseState struct {
// contains filtered or unexported fields
}
MouseState is used for detecting the state of a key press.
func (MouseState) Down ¶
func (key MouseState) Down() bool
Down returns wether a key is being pressed
func (MouseState) JustPressed ¶
func (key MouseState) JustPressed() bool
JustPressed returns whether a key was just pressed
func (MouseState) JustReleased ¶
func (key MouseState) JustReleased() bool
JustReleased returns whether a key was just released
type PlayerHub ¶
type PlayerHub struct {
// contains filtered or unexported fields
}
PlayerHub stores all connections to the game
type Property ¶
type Property struct { Name string `json:"name"` PropType string `json:"type"` Value string `json:"value"` }
Property of the layer/tile from Tiled
type Rectangle ¶
Rectangle used for collision checks
type SpriteSheet ¶
type SpriteSheet struct { Frames []Frame `json:"frames"` // contains filtered or unexported fields }
SpriteSheet holds all frames of a spritesheet from a json
func NewSpriteSheet ¶
func NewSpriteSheet(imageWidth, imageHeight, frameWidth, frameHeight, paddingWidth, paddingHeight int) *SpriteSheet
NewSpriteSheet returns a SpriteSheet struct with just a basic
func ReadSpriteSheet ¶
func ReadSpriteSheet(filename string) *SpriteSheet
ReadSpriteSheet reads a json file and returns a SpriteSheet struct
func ReadSpriteSheetJSON ¶
func ReadSpriteSheetJSON(jsonByte []byte) *SpriteSheet
ReadSpriteSheetJSON from a byte slice
func (SpriteSheet) ReturnImageParts ¶
func (s SpriteSheet) ReturnImageParts(f int) *BasicImageParts
ReturnImageParts returns the BasicImageParts at the given frame of the animation.
type TextArea ¶
type TextArea struct { *BasicObject *TextElement Selected bool Lines int }
TextArea represents a typeable area
func NewTextArea ¶
func NewTextArea(x, y float64, w, h, lines int, font *truetype.Font, textColor color.Color, fntSize float64) *TextArea
NewTextArea returns a TextArea
func (*TextArea) NewLine ¶
func (ta *TextArea) NewLine()
NewLine adds a new line, removes the first element and shifts all the elements up
func (*TextArea) ReturnLastEntered ¶
ReturnLastEntered Returns the line that was just entered
func (*TextArea) Update ¶
func (ta *TextArea) Update(input *InputController)
Update the TextArea. If it's selected you can type in the area
type TextBox ¶
type TextBox struct { *BasicUIElement Text *TextElement Selected bool // contains filtered or unexported fields }
TextBox represents a large text area
func NewTextBox ¶
func NewTextBox(x, y float64, w, h int, font *truetype.Font, text []string, textColor color.Color, fntSize float64) *TextBox
NewTextBox returns a pointer to a TextBox struct using the given parameters
func (*TextBox) Update ¶
func (tb *TextBox) Update(input *InputController)
Update the TextBox checkts whether it is selecter and what keystrokes have happened
type TextElement ¶
type TextElement struct { Name string Stationary bool *BasicUIElement // contains filtered or unexported fields }
TextElement contains the font, text, and position of that current text element
func NewTextElement ¶
func NewTextElement(x, y float64, w, h int, fnt *truetype.Font, text []string, textColor color.Color, fntSize float64) *TextElement
NewTextElement returns a new TextElement and creates the image
func NewTextElementCentered ¶
func NewTextElementStationary ¶
func NewTextElementStationary(x, y float64, w, h int, fnt *truetype.Font, text []string, textColor color.Color, fntSize float64) *TextElement
NewTextElementStationary returns a new TextElement and creates the image
func (*TextElement) Draw ¶
func (t *TextElement) Draw(screen *ebiten.Image, camera *Camera) error
Draw the TextElement
func (*TextElement) DrawApplyZoom ¶
func (t *TextElement) DrawApplyZoom(screen *ebiten.Image) error
DrawApplyZoom the TextElement
func (*TextElement) DrawPosition ¶
func (t *TextElement) DrawPosition(screen *ebiten.Image, camera *Camera) error
DrawPosition applies the camera transform to the text element
func (*TextElement) Highlighted ¶
func (t *TextElement) Highlighted() bool
Highlighted sets the TextElement to its highlighted color
func (*TextElement) ReturnText ¶
func (t *TextElement) ReturnText() string
ReturnText returns the text for debugging
func (*TextElement) SetCentered ¶
func (t *TextElement) SetCentered(c bool)
SetCentered sets whether the TextElement is centered with bool value c
func (*TextElement) SetColor ¶
func (t *TextElement) SetColor(color color.Color)
SetColor of the TextElement
func (*TextElement) SetDropShadow ¶
func (t *TextElement) SetDropShadow(drop bool)
SetDropShadow of the TextElement. If true then a second outline will be drawn.
func (*TextElement) SetFontSize ¶
func (t *TextElement) SetFontSize(fntSize float64)
SetFontSize of the TextElement
func (*TextElement) SetHighlightColor ¶
func (t *TextElement) SetHighlightColor(c color.Color)
SetHighlightColor sets the color of the text element when it's highlighted
func (*TextElement) SetPosition ¶
func (t *TextElement) SetPosition(x, y float64)
SetPosition of TextElement to given x,y coords
func (*TextElement) SetText ¶
func (t *TextElement) SetText(text []string)
SetText of the TextElement
func (*TextElement) SetTextColor ¶
func (t *TextElement) SetTextColor(c color.Color)
SetTextColor sets the color of the text element
func (*TextElement) UnHighlighted ¶
func (t *TextElement) UnHighlighted() bool
UnHighlighted returns the TextElement to its original color
type Tile ¶
type Tile struct { Image *ebiten.Image Collide bool Gid int ImageName string *BasicImageParts *BasicObject }
Tile is a renderable tile used by the game
func (*Tile) DetermineTileSet ¶
DetermineTileSet of the given tile based on the GID
func (*Tile) Draw ¶
func (t *Tile) Draw(screen *ebiten.Image, imageManager *ImageManager) error
Draw a single renderable Tile
type TileLayer ¶
type TileLayer struct { Data []*Tile DrawOrder int Collide bool Above bool Name string IsImageLayer bool ImageName string X, Y float64 Width, Height int Properties []*Property }
TileLayer is the renderable layer used by the game
func (*TileLayer) Draw ¶
func (tl *TileLayer) Draw(screen *ebiten.Image, imageManager *ImageManager) error
Draw the entire TileLayer
type TileMap ¶
TileMap is the renderable map used by the game
func CreateTileMap ¶
CreateTileMap creates a renderable TileMap
func CreateTileMapFromFile ¶
CreateTileMapFromFile creates a new TileMap based on the given filelocation
func (*TileMap) Draw ¶
func (tm *TileMap) Draw(screen *ebiten.Image, imageManager *ImageManager) error
Draw the entire TileMap
type TileSet ¶
type TileSet struct { FirstGID int `json:"firstgid"` ImageName string `json:"image"` ImageWidth int `json:"imagewidth"` ImageHeight int `json:"imageheight"` Margin int `json:"margin"` Name string `json:"name"` Properties []*Property `json:"properties"` Spacing int `json:"spacing"` TileWidth int `json:"tilewidth"` TileHeight int `json:"tileheight"` Columns int `json:"columns"` TileCount int `json:"tilecount"` Image *ebiten.Image Rows, LastGID int }
TileSet represents a Tiled TileSet
type UIController ¶
type UIController struct { Cursor *Cursor DrawCursor bool // contains filtered or unexported fields }
UIController controls all UI elements
func NewUIController ¶
func NewUIController(input *InputController) *UIController
NewUIController creates a default UI controller
func (*UIController) ActivateMenu ¶
func (ui *UIController) ActivateMenu(name string)
ActivateMenu activates specified menu
func (*UIController) ActiveMenu ¶
func (ui *UIController) ActiveMenu() string
ActiveMenu returns the name of the active menu. Returns "None Active" if there is no active menu.
func (*UIController) AddFont ¶
func (ui *UIController) AddFont(fntName string, tt *truetype.Font)
AddFont adds the given font with the given name to the ui fonts list
func (*UIController) AddFontFile ¶
func (ui *UIController) AddFontFile(fntName, fntFileLoc string) error
AddFontFile adds a new truetype font from the given file location with the given name
func (*UIController) AddFontFromBytes ¶
func (ui *UIController) AddFontFromBytes(fntName string, bytes []byte) error
AddFontFromBytes adds the font through a byte slice
func (*UIController) AddMenu ¶
func (ui *UIController) AddMenu(name string, menu *Menu)
AddMenu to the UIController
func (*UIController) AddTextDisplay ¶
func (ui *UIController) AddTextDisplay(name string, textElement *TextElement)
AddTextDisplay adds the passed TextElement with the given name to the UIController
func (*UIController) DeActivateMenu ¶
func (ui *UIController) DeActivateMenu(name string)
DeActivateMenu deactivates specified menu
func (UIController) Draw ¶
func (ui UIController) Draw(screen *ebiten.Image, camera *Camera) error
Draw all ui elements
func (*UIController) HideMouse ¶
func (ui *UIController) HideMouse()
HideMouse both custom and default
func (*UIController) HideTextElement ¶
func (ui *UIController) HideTextElement(name string)
HideTextElement hides the named element
func (*UIController) LoadDefaultFonts ¶
func (ui *UIController) LoadDefaultFonts()
LoadDefaultFonts is a method that loads the Go fonts into the UIController.
func (*UIController) ReturnFont ¶
func (ui *UIController) ReturnFont(name string) *truetype.Font
ReturnFont returns the truetype font with the specified name
func (*UIController) SetCustomCursor ¶
func (ui *UIController) SetCustomCursor(width, height, sx, sy int, spritesheet *ebiten.Image)
SetCustomCursor allows the addition of a cursor image
func (*UIController) ShowMouse ¶
func (ui *UIController) ShowMouse()
ShowMouse shows the mouse, custom or default
func (*UIController) ShowTextElement ¶
func (ui *UIController) ShowTextElement(name string)
ShowTextElement shows the named element
func (*UIController) TextElementExists ¶
func (ui *UIController) TextElementExists(name string) bool
TextElementExists returns true if the given name is found in the UIController's text elements
func (*UIController) ToggleMenu ¶
func (ui *UIController) ToggleMenu(name string)
ToggleMenu if the menu is on it turns off else it turns on
func (*UIController) UpdateTextPosition ¶
func (ui *UIController) UpdateTextPosition(name string, x, y float64)
UpdateTextPosition sets the position of the named text element
type UIElement ¶
type UIElement interface { Update() Draw(*ebiten.Image, *Camera) error Highlighted() bool UnHighlighted() bool AddPosition(float64, float64) SetPosition(float64, float64) Size() (int, int) SetSize(int, int) Contains(float64, float64) bool SetHighlightColor(color.Color) }
UIElement is the interface for all UI elements
type UINumberDisplay ¶
type UINumberDisplay struct { *TextElement // contains filtered or unexported fields }
UINumberDisplay allows a pointer to a float64 that updates and draws a TextElement on update
func NewUINumberDisplay ¶
func NewUINumberDisplay(number *float64, x, y float64, w, h int, font *truetype.Font, textColor color.Color, fntSize float64) *UINumberDisplay
NewUINumberDisplay creates a new UINumberDisplay
func NewUINumberDisplayStationary ¶
func NewUINumberDisplayStationary(number *float64, x, y float64, w, h int, font *truetype.Font, textColor color.Color) *UINumberDisplay
NewUINumberDisplayStationary creates a new UINumberDisplay
type UINumberDisplayInt ¶
type UINumberDisplayInt struct { *TextElement // contains filtered or unexported fields }
UINumberDisplayInt allows a pointer to an integer that updates and draws a TextElement on update
func NewUINumberDisplayInt ¶
func NewUINumberDisplayInt(number *int, x, y float64, w, h int, font *truetype.Font, fntSize float64, textColor color.Color) *UINumberDisplayInt
NewUINumberDisplayInt creates a new UINumberDisplayInt
type UITextDisplay ¶
type UITextDisplay struct { *TextElement // contains filtered or unexported fields }
UITextDisplay shows a changable text element on the display
type Vector2d ¶
type Vector2d struct {
X, Y float64
}
Vector2d represents a 2 dimensional vector
func (Vector2d) LengthSquared ¶
LengthSquared returns the magnitude before square root function
func (*Vector2d) Normalize ¶
func (v *Vector2d) Normalize()
Normalize the vector by making it equal to magnitude of 1
func (Vector2d) Normalized ¶
Normalized returns a new normalized Vector2d
Source Files ¶
- animation.go
- audio.go
- basicimageparts.go
- button.go
- camera.go
- cursor.go
- fonts.go
- game.go
- gamedata.go
- gameobject.go
- gamepad.go
- gamestate.go
- hud.go
- imagemanager.go
- input_data.go
- inputcontroller.go
- keys.go
- line.go
- menu.go
- mouse.go
- mousebutton.go
- network.go
- rectangle.go
- spritesheet.go
- tentsuyu.go
- textarea.go
- textbox.go
- textelement.go
- texttoimage.go
- tilemap.go
- ui.go
- vectors.go