tentsuyu

package module
Version: v0.2.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2021 License: Apache-2.0 Imports: 40 Imported by: 7

README

Tentsuyu

This is an extension on top of Ebiten. Tentsuyu is a tempura dipping sauce, so I thought the name was appropriate. This came from another project I was working on and decided to pull ou the portions that could be reusable for other games using ebiten. This is very much a work in progress and mainly used for my personal projects.

Features

  • Camera
  • Input Manager
  • HUD
  • UI Controller
    • Menus
    • Text
    • Drawn Cursor
    • Very basic "text box"
  • Tile Map implementation
    • Reads JSON files from Tiled editor
      • Currently only one format, this needs to be expanded
  • Image Manager (track 'textures')
  • GameObject interface
    • Basic Object implementation
    • Basic Image Options implementation
  • Starter Game Struct

Documentation

Index

Constants

View Source
const (
	CursorCrosshair = iota
	CursorPointer
)

Types of cursors

View Source
const (
	FntRegular        string = "FontGoRegular"
	FntMono                  = "FontGoMono"
	FntBold                  = "FontGoBold"
	FntItalic                = "FontGoItalic"
	FntBoldItalic            = "FontGoBoldItalic"
	FntMonoBold              = "FontMonoBold"
	FntMonoItalic            = "FontMonoItalic"
	FntMonoBoldItalic        = "FontMonoBoldItalic"
)

Available Go Fonts

View Source
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"
)
View Source
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
)
View Source
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

View Source
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)
)
View Source
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

func DrawLine(dst *ebiten.Image, x1, y1, x2, y2 float64, clr color.Color, camera *Camera)

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 Action

type Action int

Action corresponds to a control action such as move, press, release

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

func (a Animation) CurrentFrame() int

CurrentFrame returns the current frame of the animation

func (Animation) IsPaused

func (a Animation) IsPaused() bool

IsPaused returns true if the animation is paused

func (*Animation) Pause

func (a *Animation) Pause()

Pause the animation

func (*Animation) Play

func (a *Animation) Play()

Play the animation

func (*Animation) Reset

func (a *Animation) Reset()

Reset the animation to the starting point

func (*Animation) Resume

func (a *Animation) Resume()

Resume playing the animation

func (*Animation) ReturnImageParts

func (a *Animation) ReturnImageParts() *BasicImageParts

ReturnImageParts of the current animation

func (*Animation) SetAnimationSpeed

func (a *Animation) SetAnimationSpeed(s int)

SetAnimationSpeed changes the speed of the animation to the passed value

func (*Animation) SetCurrentFrame

func (a *Animation) SetCurrentFrame(frame int)

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

func (a *Animation) SetFrameSpeed(speed int)

SetFrameSpeed of the current animation

func (*Animation) SetReverse

func (a *Animation) SetReverse()

SetReverse tells the animation to play in reverse

func (*Animation) Stop

func (a *Animation) Stop()

Stop the animation

func (*Animation) Update

func (a *Animation) Update()

Update the animation if not paused

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) Len

func (b *BasicImageParts) Len() int

Len returns 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) AddX

func (obj *BasicObject) AddX(vX float64)

AddX adds to the x value

func (*BasicObject) AddY

func (obj *BasicObject) AddY(vY float64)

AddY adds to the y value

func (*BasicObject) Bottom

func (obj *BasicObject) Bottom() float64

Bottom edge of the rectangle

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) GetAngle

func (obj BasicObject) GetAngle() float64

GetAngle of BasicObject

func (*BasicObject) GetHealth

func (obj *BasicObject) GetHealth() float64

GetHealth should return BasicObject Health

func (BasicObject) GetHeight

func (obj BasicObject) GetHeight() int

GetHeight returns height

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) GetWidth

func (obj BasicObject) GetWidth() int

GetWidth returns width

func (BasicObject) GetWidthF

func (obj BasicObject) GetWidthF() float64

GetWidthF returns width as a float64

func (BasicObject) GetX

func (obj BasicObject) GetX() float64

GetX returns the x coords

func (BasicObject) GetY

func (obj BasicObject) GetY() float64

GetY returns the y coords

func (*BasicObject) Left

func (obj *BasicObject) Left() float64

Left edge of the rectangle

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) Right

func (obj *BasicObject) Right() float64

Right edge of the rectangle

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) SetX

func (obj *BasicObject) SetX(x float64)

SetX of the position

func (*BasicObject) SetY

func (obj *BasicObject) SetY(y float64)

SetY of the position

func (*BasicObject) Top

func (obj *BasicObject) Top() float64

Top edge of the rectangle

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) Down

func (b Button) Down() bool

Down checks whether the current input is being held down.

func (Button) JustPressed

func (b Button) JustPressed() bool

JustPressed checks whether an input was pressed in the previous frame.

func (Button) JustReleased

func (b Button) JustReleased() bool

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

func CreateCamera(width, height float64) *Camera

CreateCamera intializes a camera struct

func (Camera) ApplyCameraTransform

func (c Camera) ApplyCameraTransform(op *ebiten.DrawImageOptions, applyZoom bool)

ApplyCameraTransform applies the camera's position to the DrawImageOptions, bool toggles whether zoom is applied or not

func (*Camera) Center

func (c *Camera) Center(x, y float64)

Center camera on point

func (*Camera) CenterX

func (c *Camera) CenterX(x float64)

CenterX centers camera X position

func (*Camera) CenterY

func (c *Camera) CenterY(y float64)

CenterY centers camera Y position

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

func (c *Camera) GetDestination() (float64, float64)

GetDestination of camera (x,y)

func (Camera) GetOffsetX

func (c Camera) GetOffsetX() float64

GetOffsetX returns the camera X offset position

func (Camera) GetOffsetY

func (c Camera) GetOffsetY() float64

GetOffsetY returns the camera Y offset position

func (Camera) GetScreenCoords

func (c Camera) GetScreenCoords(x, y float64) (float64, float64)

GetScreenCoords returns where the passed coords would be on the screen space

func (*Camera) GetX

func (c *Camera) GetX() float64

GetX returns the camera X position

func (*Camera) GetY

func (c *Camera) GetY() float64

GetY returns the camera Y position

func (Camera) OnScreen

func (c Camera) OnScreen(x, y float64, w, h int) bool

OnScreen determines if the given position is within the camera viewport

func (Camera) Position

func (c Camera) Position() (x, y float64)

Position of the camera

func (*Camera) SetBounds

func (c *Camera) SetBounds(lowerX, upperX, lowerY, upperY float64)

SetBounds that the camera operates in

func (*Camera) SetClamp

func (c *Camera) SetClamp(clamp bool)

SetClamp sets whether the camera takes the floor of its coordinates

func (*Camera) SetDimensions

func (c *Camera) SetDimensions(width, height float64)

SetDimensions sets the width and height of the camera

func (*Camera) SetOffsetX

func (c *Camera) SetOffsetX(offset float64)

SetOffsetX sets the offset X

func (*Camera) SetOffsetY

func (c *Camera) SetOffsetY(offset float64)

SetOffsetY sets the offset Y

func (*Camera) SetPosition

func (c *Camera) SetPosition(x, y float64)

SetPosition by passing both x and y coordinates of the camera

func (*Camera) SetShakeRadius

func (c *Camera) SetShakeRadius(radius float64)

SetShakeRadius for the camera shake

func (*Camera) SetSpeed

func (c *Camera) SetSpeed(s float64)

SetSpeed that the camera moves at

func (*Camera) SetX

func (c *Camera) SetX(x float64)

SetX position of the camera

func (*Camera) SetY

func (c *Camera) SetY(y float64)

SetY position of the camera

func (*Camera) SetZoom

func (c *Camera) SetZoom(zoom float64)

SetZoom of the camera

func (*Camera) SetZoomGradual

func (c *Camera) SetZoomGradual(zoom, speed float64)

SetZoomGradual zooms into the passed zoom value and a given speed TODO: Implement this

func (*Camera) Shake

func (c *Camera) Shake()

Shake shakes the camera

func (*Camera) StartShaking

func (c *Camera) StartShaking(r float64)

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)

func (*Camera) Update

func (c *Camera) Update()

Update the camera

func (*Camera) ZoomIn

func (c *Camera) ZoomIn()

ZoomIn move the camera closer towards the player

func (*Camera) ZoomOut

func (c *Camera) ZoomOut()

ZoomOut moves the camera further away from the player

type Cursor

type Cursor struct {
	*BasicObject
	*BasicImageParts
	// contains filtered or unexported fields
}

Cursor represents the player's mouse position

func NewCursor

func NewCursor(screenWidth, screenHeight float64, spritesheet *ebiten.Image) *Cursor

NewCursor creates the cursor... should be called during game set up

func (*Cursor) Draw

func (c *Cursor) Draw(screen *ebiten.Image) error

Draw the cursor

func (*Cursor) SetStyle

func (c *Cursor) SetStyle(cursorstyle int)

SetStyle of the cursor: center or top corner

func (*Cursor) Update

func (c *Cursor) Update(mx, my float64)

Update sets the curosr 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 NewGame

func NewGame(screenWidth, screenHeight float64) (game *Game, err error)

NewGame returns a new Game while setting the width and height of the screen

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) GetGameState

func (g Game) GetGameState() GameState

GetGameState of the game

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)

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

func (g Game) ScreenHeight() int

ScreenHeight returns the height of the game screen

func (Game) ScreenSize

func (g Game) ScreenSize() (w, h int)

ScreenSize returns the width and height of the game screen

func (Game) ScreenWidth

func (g Game) ScreenWidth() int

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) SetGameState

func (g *Game) SetGameState(gs GameState)

SetGameState of the game

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

func (g *Game) SetMobile(m bool)

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

func (g *Game) SetPauseState(gs GameState)

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

func (*Game) UnPause

func (g *Game) UnPause()

UnPause switches back the the puasedState GameState of the Game

func (*Game) Update

func (g *Game) Update(screen *ebiten.Image) error

Update proceeds the game state. Update is called every tick (1/60 [s] by default).

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 NewGameData

func NewGameData() *GameData

NewGameData creates a new GameData

func (*GameData) SetCurrentScore

func (g *GameData) SetCurrentScore(score float64)

SetCurrentScore sets the current score of the game

func (*GameData) SetHighScore

func (g *GameData) SetHighScore(score float64)

SetHighScore compares the given score to current highscore and updates if it's greater

func (*GameData) TimeInMilliseconds

func (g *GameData) TimeInMilliseconds() int

TimeInMilliseconds returns the current time in seconds

func (*GameData) TimeInSecond

func (g *GameData) TimeInSecond() int

TimeInSecond returns the current time in seconds

func (*GameData) Update

func (g *GameData) Update()

Update GameData Ticks time ahead

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 GameMode

type GameMode int

GameMode represents the different game modes possible

const (
	GameModeNormal GameMode = iota
)

List of possible game modes

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 GamePad

type GamePad struct {
}

GamePad holds the relevant gamepad logic

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 GameStateMsg

type GameStateMsg string

GameStateMsg represents

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 NewHUD

func NewHUD(screenWidth, screenHeight float64) *HUD

NewHUD returns a new HUD object

func (*HUD) AddBottomLeft

func (hud *HUD) AddBottomLeft(element UIElement)

AddBottomLeft of the HUD

func (*HUD) AddBottomRight

func (hud *HUD) AddBottomRight(element UIElement)

AddBottomRight of the HUD

func (*HUD) AddTopLeft

func (hud *HUD) AddTopLeft(element UIElement)

AddTopLeft of the HUD

func (*HUD) AddTopRight

func (hud *HUD) AddTopRight(element UIElement)

AddTopRight of the hud

func (*HUD) Draw

func (hud *HUD) Draw(screen *ebiten.Image, camera *Camera)

Draw All elements

func (*HUD) Update

func (hud *HUD) Update()

Update updates the HUD....prevHealth

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

func (*InputController) Update

func (ic *InputController) Update()

Update InputController

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

func (j *JukeBox) ContinuousPlay(songName string)

ContinuousPlay of the song based on passed song name

func (*JukeBox) CurrentSongName

func (j *JukeBox) CurrentSongName() string

CurrentSongName returns the name of the song that is currently being played

func (*JukeBox) PlayBG

func (j *JukeBox) PlayBG()

PlayBG plays background music in the given order

func (*JukeBox) PlaySong

func (j *JukeBox) PlaySong(songName string, vol float64)

PlaySong with the given name at the passed volume

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 NewKeyManager

func NewKeyManager() *KeyManager

NewKeyManager creates a new KeyManager.

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) Down

func (key KeyState) Down() bool

Down returns wether a key is being pressed

func (KeyState) JustPressed

func (key KeyState) JustPressed() bool

JustPressed returns whether a key was just pressed

func (KeyState) JustReleased

func (key KeyState) JustReleased() bool

JustReleased returns whether a key was just released

func (*KeyState) State

func (key *KeyState) State() int

State returns the raw state of a key.

func (KeyState) Up

func (key KeyState) Up() bool

Up returns wheter a key is not being pressed

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

func NewLineFromTo(fromX, fromY, toX, toY float64) *Line

NewLineFromTo returns a Line beginning at (fromX,fromY) to (toX,toY)

func (Line) CalculateAngle

func (l Line) CalculateAngle() float64

CalculateAngle returns the line's angle

func (Line) CalculateLength

func (l Line) CalculateLength() float64

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 ReadMap

func ReadMap(filename string) *Map

ReadMap from JSON file and dump into Map

func ReadMapfromByte

func ReadMapfromByte(byteMap []byte) *Map

ReadMapfromByte reads an entire Map struct from a byte slice

func ReadMapfromString

func ReadMapfromString(jString string) *Map

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 struct {
	Elements [][]*MenuElement
	Active   bool
	Name     string
	// contains filtered or unexported fields
}

Menu is a collection of MenuElements

func NewMenu

func NewMenu(screenWidth, screenHeight float64) *Menu

NewMenu creates a new menu

func (m *Menu) AddElement(element []UIElement, action []func())

AddElement adds a new Line of UIElements

func (m *Menu) Draw(screen *ebiten.Image, camera *Camera)

Draw window

func (m *Menu) PressSelected()

PressSelected exectures the Action of the currently selected option

func (m *Menu) ReturnSelected() (int, int)

ReturnSelected returns the Row and Col int of the current selected option

func (m *Menu) SelectHorizontal(id int)

SelectHorizontal moves the selection alrong the x-axis

func (m *Menu) SelectVertical(id int)

SelectVertical move the selection along the y-axis

func (m *Menu) SetBackground(src *ebiten.Image, imgParts *BasicImageParts)

SetBackground image for menu

func (m *Menu) SetPadding(x, y int)

SetPadding of the menus x and y values

func (m *Menu) Update(input *InputController, offsetX, offsetY float64)

Update the menu

type MenuElement struct {
	UIElement
	Action     func()
	Selectable bool
	// contains filtered or unexported fields
}

MenuElement represents a single element/option within a menu

func (m *MenuElement) Hide(h bool)

Hide takes a bool and sets the hidden variable

func (m *MenuElement) SetAction(function func())

SetAction of the MenuElement

func (m *MenuElement) SetCentered(c bool)

SetCentered centers the MenuElement based on bool value c

func (m *MenuElement) Update(input *InputController, offsetX, offsetY float64) bool

Update the MenuElement

type Modifier

type Modifier int

Modifier represents a special key pressed along with another key

type Mouse

type Mouse struct {
	X, Y float64
	// contains filtered or unexported fields
}

Mouse represents the cursor

func NewMouse

func NewMouse() *Mouse

NewMouse returns a new pointer to a Mouse struct

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

func (m *Mouse) 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 (*Mouse) IsScrollDown

func (m *Mouse) IsScrollDown() bool

IsScrollDown returns true if the user is scrolling down on the mouse wheel

func (*Mouse) IsScrollUp

func (m *Mouse) IsScrollUp() bool

IsScrollUp returns true if the user is scrolling up on the mouse wheel

func (*Mouse) Set

func (m *Mouse) Set(key ebiten.MouseButton, state bool)

Set tells the mouse to press the selected mouse button

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

func (*MouseState) State

func (key *MouseState) State() int

State returns the raw state of a key.

func (MouseState) Up

func (key MouseState) Up() bool

Up returns wheter a key is not being pressed

type PlayerHub

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

PlayerHub stores all connections to the game

type Point

type Point struct {
	X, Y float64
}

Point represents a point in 2D space

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

type Rectangle struct {
	W, H int
	X, Y float64
}

Rectangle used for collision checks

func (*Rectangle) Bottom

func (rect *Rectangle) Bottom() float64

Bottom edge of the rectangle

func (*Rectangle) Contains

func (rect *Rectangle) Contains(srcX, srcY float64) bool

Contains returns true if the given point is withing the bounding box

func (*Rectangle) Left

func (rect *Rectangle) Left() float64

Left edge of the rectangle

func (*Rectangle) Right

func (rect *Rectangle) Right() float64

Right edge of the rectangle

func (*Rectangle) Top

func (rect *Rectangle) Top() float64

Top edge of the rectangle

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) AddLine

func (ta *TextArea) AddLine(text string)

AddLine adds a line of text to the TextArea as if it were entered

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

func (ta *TextArea) ReturnLastEntered() string

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) Draw

func (tb *TextBox) Draw(screen *ebiten.Image, camera *Camera) error

Draw the textbox

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 NewTextElementCentered(x, y float64, w, h int, fnt *truetype.Font, text []string, textColor color.Color, fntSize float64) *TextElement

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) Hide

func (t *TextElement) Hide()

Hide the TextElement

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) Show

func (t *TextElement) Show()

Show the TextElement

func (*TextElement) UnHighlighted

func (t *TextElement) UnHighlighted() bool

UnHighlighted returns the TextElement to its original color

func (*TextElement) Update

func (t *TextElement) Update()

Update TextElement

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

func (t *Tile) DetermineTileSet(tilemap *Map)

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

type TileMap struct {
	Layers                               []*TileLayer
	Width, Height, TileWidth, TileHeight int
}

TileMap is the renderable map used by the game

func CreateTileMap

func CreateTileMap(tilemap *Map) *TileMap

CreateTileMap creates a renderable TileMap

func CreateTileMapFromFile

func CreateTileMapFromFile(fileLocation string) *TileMap

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

func (*TileSet) ReturnImagePosition

func (ts *TileSet) ReturnImagePosition(gid int) (float64, float64)

ReturnImagePosition returns the image location within the 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) Update

func (ui *UIController) Update()

Update all ui elements

func (*UIController) UpdateTextPosition

func (ui *UIController) UpdateTextPosition(name string, x, y float64)

UpdateTextPosition sets the position of the named text element

func (*UIController) WriteText

func (ui *UIController) WriteText(text []string, name, font string, x, y float64, w, h int, textColor color.Color, fntSize float64)

WriteText creates a new TextElement

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

func (*UINumberDisplay) Update

func (nd *UINumberDisplay) Update()

Update 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

func NewUINumberDisplayIntStationary

func NewUINumberDisplayIntStationary(number *int, x, y float64, w, h int, font *truetype.Font, textColor color.Color, fntSize float64) *UINumberDisplayInt

NewUINumberDisplayIntStationary creates a new UINumberDisplayInt

func (*UINumberDisplayInt) Update

func (nd *UINumberDisplayInt) Update()

Update UINumberDisplay

type UITextDisplay

type UITextDisplay struct {
	*TextElement
	// contains filtered or unexported fields
}

UITextDisplay shows a changable text element on the display

func NewUITextDisplay

func NewUITextDisplay(text *string, x, y float64, w, h int, font *truetype.Font, textColor color.Color, fntSize float64) *UITextDisplay

NewUITextDisplay creates a new UITExtDisplay

func (*UITextDisplay) Update

func (td *UITextDisplay) Update()

Update UINumberDisplay

type Vector2d

type Vector2d struct {
	X, Y float64
}

Vector2d represents a 2 dimensional vector

func VectorAdd

func VectorAdd(v, u Vector2d) *Vector2d

VectorAdd adds vectors v and u

func VectorMul

func VectorMul(v Vector2d, r float64) *Vector2d

VectorMul multiples vector v by float r

func VectorSub

func VectorSub(v, u Vector2d) *Vector2d

VectorSub subtracts vectors v and u

func (*Vector2d) Add

func (v *Vector2d) Add(other Vector2d)

Add other vector to the vector

func (Vector2d) Angle

func (v Vector2d) Angle(u Vector2d) float64

Angle between two vectors

func (Vector2d) Cross

func (v Vector2d) Cross(other Vector2d) float64

Cross Product of two 2D Vectors

func (Vector2d) Crossf

func (v Vector2d) Crossf(other float64) Vector2d

Crossf is cross of Vector and float64

func (*Vector2d) Div

func (v *Vector2d) Div(other float64)

Div (ide) the vector by the other vector

func (Vector2d) Dot

func (v Vector2d) Dot(other Vector2d) float64

Dot product of vector with other vector

func (Vector2d) Length

func (v Vector2d) Length() float64

Length returns the vector magnitude

func (Vector2d) LengthSquared

func (v Vector2d) LengthSquared() float64

LengthSquared returns the magnitude before square root function

func (*Vector2d) Limit

func (v *Vector2d) Limit(limit float64)

Limit the vector to the given float

func (Vector2d) Minus

func (v Vector2d) Minus(v2 Vector2d) *Vector2d

Minus returns a new vector of the vector minus v2

func (*Vector2d) Mul

func (v *Vector2d) Mul(other float64)

Mul (tiply) the other vector with the vector

func (*Vector2d) Normalize

func (v *Vector2d) Normalize()

Normalize the vector by making it equal to magnitude of 1

func (Vector2d) Normalized

func (v Vector2d) Normalized() *Vector2d

Normalized returns a new normalized Vector2d

func (Vector2d) Plus

func (v Vector2d) Plus(v2 Vector2d) *Vector2d

Plus returns a new vector of the vector plus v2

func (*Vector2d) Sub

func (v *Vector2d) Sub(other Vector2d)

Sub (tract) other vector from the vector

func (*Vector2d) Subf

func (v *Vector2d) Subf(number float64)

Subf subtract float from the vector

func (Vector2d) Times

func (v Vector2d) Times(r float64) *Vector2d

Times returns a new vector of the vectors multiplied together

func (Vector2d) ToString

func (v Vector2d) ToString() string

ToString nicely formats the coords in written form

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to