Documentation ¶
Index ¶
- Constants
- Variables
- type AnimatedImage
- type BGChangeEvent
- type BranchingDialogueEvent
- type BranchingJumpEvent
- type Character
- type CharacterAddShaderEvent
- type CharacterMoveEvent
- type CharacterRemoveEvent
- type CharacterViewEvent
- type ComplexEvent
- type DialogueEvent
- type Event
- func NewBGChangeEventFromPath(imagepath string, moveParam MoveParam, imageloader ImageLoader, ...) Event
- func NewBranchingDialogueEvent(name, sceneKey string, options map[string]string) Event
- func NewBranchingJumpEvent(SceneDataKey string, BranchingJump map[string]int) Event
- func NewCharacterAddEvent(name string, moveParam *MoveParam, scaleParam *ScaleParam) Event
- func NewCharacterAddShaderEvent(name string, shaderParam *ShaderParam) Event
- func NewCharacterMoveEvent(name string, moveParam MoveParam) Event
- func NewCharacterRemoveEvent(name string) Event
- func NewDialogueEvent(name, dialogue string, fontface font.Face) Event
- func NewOptionSelectEvent(question string, options ...string) Event
- type GetLayouter
- type ImageLoader
- type MovableImage
- func (e *MovableImage) AddAnimation(animation ...*MoveAnimation)
- func (e *MovableImage) Draw(screen *ebiten.Image)
- func (e *MovableImage) GetPos() (float64, float64)
- func (e *MovableImage) GetSize() (float64, float64)
- func (e *MovableImage) ReplaceCurrentAnim(animation *MoveAnimation)
- func (e *MovableImage) SetPos(x, y float64)
- func (e *MovableImage) Update()
- type MovableImageParams
- type MoveAnimation
- type MoveParam
- type OptionPickerState
- type OptionSelectEvent
- type ScaleParam
- type Scene
- func (g *Scene) AddViewableCharacters(name string, moveParam *MoveParam, scaleParam *ScaleParam)
- func (g *Scene) Draw(screen *ebiten.Image)
- func (g *Scene) GetSceneData(key string) any
- func (g *Scene) RemoveVieableCharacter(characterName string)
- func (g *Scene) SetLayouter(getLayouter GetLayouter)
- func (g *Scene) SetSceneData(key string, value any)
- func (g *Scene) Update() error
- type ShaderParam
- type ShaderPool
- type SubState
- type TxtBgGetter
Constants ¶
const DARKER_SHADER = "DARKER_SHADER"
const GRAYSCALE_SHADER = "DARKER_SHADER"
const INVERT_SHADER = "INVERT_SHADER"
const PALETTESWAPBRG_SHADER = "BRG_SHADER"
const SEPIA_SHADER = "SEPIA_SHADER"
Variables ¶
var DarkerShader []byte
var ( // the default font used for many things. Overwrite this var // to use different font DefaultFont font.Face )
var GrayscaleShader []byte
var InvertShader []byte
var PaletteSwapBrgShader []byte
var SepiaShader []byte
var ShaderNotFoundError = errors.New("Shader Not Found")
Functions ¶
This section is empty.
Types ¶
type AnimatedImage ¶
type AnimatedImage struct { *MovableImage SubImageStartX int SubImageStartY int SubImageWidth int SubImageHeight int FrameCount int // Move to next frame everytime counter reach this number Modulo int Done func() // contains filtered or unexported fields }
for image that do animation with frame
func (*AnimatedImage) Draw ¶
func (e *AnimatedImage) Draw(screen *ebiten.Image)
func (*AnimatedImage) Update ¶
func (a *AnimatedImage) Update()
type BGChangeEvent ¶
type BGChangeEvent struct { // start position Sx float64 Sy float64 // target position Tx float64 Ty float64 Speed float64 Shader *ebiten.Shader // contains filtered or unexported fields }
this event change background of the scene and animate it a bit
func (*BGChangeEvent) Execute ¶
func (b *BGChangeEvent) Execute(scene *Scene)
type BranchingDialogueEvent ¶
type BranchingDialogueEvent struct { Name string SceneDataKey string BranchingStruct map[string]string }
create branching dialogue based on SceneDataKey. this code assume the value of SceneData is string if no matching string data is found it will show empty string
func (*BranchingDialogueEvent) Execute ¶
func (b *BranchingDialogueEvent) Execute(scene *Scene)
type BranchingJumpEvent ¶
jump
func (*BranchingJumpEvent) Execute ¶
func (c *BranchingJumpEvent) Execute(scene *Scene)
type Character ¶
type Character struct { Name string Img *MovableImage }
func NewCharacter ¶
func NewCharacter(name, imgpath string, loader ImageLoader) *Character
func (*Character) AddAnimation ¶
func (c *Character) AddAnimation(ma *MoveAnimation)
type CharacterAddShaderEvent ¶
type CharacterAddShaderEvent struct { Name string Shader *ebiten.Shader }
func (*CharacterAddShaderEvent) Execute ¶
func (s *CharacterAddShaderEvent) Execute(Scene *Scene)
type CharacterMoveEvent ¶
func (*CharacterMoveEvent) Execute ¶
func (s *CharacterMoveEvent) Execute(scene *Scene)
type CharacterRemoveEvent ¶
type CharacterRemoveEvent struct {
Name string
}
func (*CharacterRemoveEvent) Execute ¶
func (s *CharacterRemoveEvent) Execute(Scene *Scene)
type CharacterViewEvent ¶
type CharacterViewEvent struct { Name string MoveParam *MoveParam ScaleParam *ScaleParam }
func (*CharacterViewEvent) Execute ¶
func (s *CharacterViewEvent) Execute(Scene *Scene)
type ComplexEvent ¶
type ComplexEvent struct {
Events []Event
}
complex event is event that is complex, we use it if we want to do several things in single click like change bg and show dialoge at the same time
func (*ComplexEvent) Execute ¶
func (c *ComplexEvent) Execute(scene *Scene)
type DialogueEvent ¶
event that shows dialogue/monologue. The location of the Name and text will follow Layouter on the scene.
Name is character name who tells the Dialogue. It does not need to be registered on AvailableCharacter on Scene. it can be made empty string
Dialogue is the text shown.
func (*DialogueEvent) Execute ¶
func (b *DialogueEvent) Execute(scene *Scene)
type Event ¶
type Event interface { // do something on the screen Execute(scene *Scene) }
This is something that must happened in a scene, whether they are dialogue. moving image, some fancy stuff
func NewBGChangeEventFromPath ¶
func NewBGChangeEventFromPath(imagepath string, moveParam MoveParam, imageloader ImageLoader, shader *ShaderParam) Event
func NewBranchingJumpEvent ¶
func NewCharacterAddEvent ¶
func NewCharacterAddEvent(name string, moveParam *MoveParam, scaleParam *ScaleParam) Event
even to add character to the scene. name is character name that's already registered on characters field on scene moveParam determine how the character should get into scene scaleParam determine how
func NewCharacterAddShaderEvent ¶
func NewCharacterAddShaderEvent(name string, shaderParam *ShaderParam) Event
add shader to a character, set shaderparam to nil if you want to remove any shader
func NewCharacterMoveEvent ¶
func NewCharacterRemoveEvent ¶
func NewOptionSelectEvent ¶
create OptionSelectEvent
type GetLayouter ¶
type GetLayouter interface { // return width and height of the scene GetLayout() (width, height int) // return the starting text position where the box containing name of the character appear on the scene // return negative number if no such box needed GetNamePosition() (x, y int) // get the starting position of the text GetTextPosition() (x, y int) }
type ImageLoader ¶
type MovableImage ¶
type MovableImage struct { ScaleParam *ScaleParam // animation stuff CurrMove *MoveAnimation AnimationQueue []*MoveAnimation Shader *ebiten.Shader // contains filtered or unexported fields }
an image that you can move
func NewMovableImage ¶
func NewMovableImage(image *ebiten.Image, param *MovableImageParams) *MovableImage
func (*MovableImage) AddAnimation ¶
func (e *MovableImage) AddAnimation(animation ...*MoveAnimation)
func (*MovableImage) Draw ¶
func (e *MovableImage) Draw(screen *ebiten.Image)
func (*MovableImage) GetPos ¶
func (e *MovableImage) GetPos() (float64, float64)
func (*MovableImage) GetSize ¶
func (e *MovableImage) GetSize() (float64, float64)
func (*MovableImage) ReplaceCurrentAnim ¶
func (e *MovableImage) ReplaceCurrentAnim(animation *MoveAnimation)
replace current animation with new one
func (*MovableImage) SetPos ¶
func (e *MovableImage) SetPos(x, y float64)
this function is to immediately move the image to pos x,y
func (*MovableImage) Update ¶
func (e *MovableImage) Update()
type MovableImageParams ¶
type MovableImageParams struct { MoveParam MoveParam ScaleParam *ScaleParam ShaderOptions *ShaderParam }
func NewMovableImageParams ¶
func NewMovableImageParams() *MovableImageParams
func (*MovableImageParams) WithMoveParam ¶
func (p *MovableImageParams) WithMoveParam(param MoveParam) *MovableImageParams
func (*MovableImageParams) WithScale ¶
func (p *MovableImageParams) WithScale(param *ScaleParam) *MovableImageParams
func (*MovableImageParams) WithShader ¶
func (p *MovableImageParams) WithShader(param *ShaderParam) *MovableImageParams
type MoveAnimation ¶
type MoveAnimation struct { Speed float64 SleepPre time.Duration SleepPost time.Duration DoneFunc func() // contains filtered or unexported fields }
struct to represent movement of an image
type OptionPickerState ¶
func (*OptionPickerState) Draw ¶
func (s *OptionPickerState) Draw(screen *ebiten.Image)
func (*OptionPickerState) InitYStart ¶
func (s *OptionPickerState) InitYStart()
init the y location of option buttons
func (*OptionPickerState) Update ¶
func (s *OptionPickerState) Update()
type OptionSelectEvent ¶
Event that SHOWS you selection option substate, by default using OptionPickerState
func (*OptionSelectEvent) Execute ¶
func (b *OptionSelectEvent) Execute(scene *Scene)
type ScaleParam ¶
type Scene ¶
type Scene struct { EventIndex int Events []Event CurrentBg *MovableImage // text stuff TxtBg *ebiten.Image CurCharName string CurDialog string FontFace font.Face SceneData map[string]any //characters/sprite stuff // Characters used in the scene Characters []*Character // Characters viewable in the scene // Any character that needs to be shown will be moved here ViewableCharacters []*Character //substates and its management CurrentSubState SubState OptionPikerSubstate SubState // this function is executed after the scene complete Done func() // contains filtered or unexported fields }
Scene is whatever happened on the screen. It has several Event that is loaded in order It implement Draw(*ebiten.Image) and Update() so it should be simple to be splashed into default ebitengine projects.
use some statemanagement framework like github.com/joelschutz/stagehand to manage state/scene better
func (*Scene) AddViewableCharacters ¶
func (g *Scene) AddViewableCharacters(name string, moveParam *MoveParam, scaleParam *ScaleParam)
copy Character from Character to ViewableCharacter
func (*Scene) GetSceneData ¶
func (*Scene) RemoveVieableCharacter ¶
remove character from ViewableCharacter
func (*Scene) SetLayouter ¶
func (g *Scene) SetLayouter(getLayouter GetLayouter)
func (*Scene) SetSceneData ¶
type ShaderParam ¶
type ShaderParam struct { Shader *ebiten.Shader ShaderName string }
parameter to use shader. You can fill Shader or Shadername and the function that takes it will determine wheter to assign shader directly or uses shader already registered on shaderpool
type ShaderPool ¶
type ShaderPool struct {
// contains filtered or unexported fields
}
pool that store compiled shader. It is a singleton register new shader here so you can use it alongside ShaderParam
func (*ShaderPool) GetShader ¶
func (s *ShaderPool) GetShader(name string) (*ebiten.Shader, error)
func (*ShaderPool) RegisterShader ¶
func (s *ShaderPool) RegisterShader(name string, shader *ebiten.Shader)
type TxtBgGetter ¶
type TxtBgGetter interface {
GetTxtBg() *ebiten.Image
}