resources

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KilledEnemies ConditionType = "killedEnemies"
	Active                      = "active"
	Inactive                    = "inactive"
)
View Source
const (
	AxisLeftX = iota
	AxisLeftY
	AxisRightX
	AxisRightY
	//
	ButtonBumperLeft
	ButtonBumperRight
	//
	ButtonTriggerLeft
	ButtonTriggerRight
	ButtonBack
	ButtonStart
	ButtonA
	ButtonB
	ButtonX
	ButtonY
)

Variables

View Source
var GamepadDefinitions = []GamepadDefinition{
	{
		Name:  "standard",
		Match: []string{},
		Map: GamepadMap{
			AxisLeftX:          int(ebiten.StandardGamepadAxisLeftStickHorizontal),
			AxisLeftY:          int(ebiten.StandardGamepadAxisLeftStickVertical),
			AxisRightX:         int(ebiten.StandardGamepadAxisRightStickHorizontal),
			AxisRightY:         int(ebiten.StandardGamepadAxisRightStickVertical),
			ButtonBumperLeft:   int(ebiten.StandardGamepadButtonFrontBottomLeft),
			ButtonBumperRight:  int(ebiten.StandardGamepadButtonFrontBottomRight),
			ButtonTriggerLeft:  int(ebiten.StandardGamepadButtonFrontTopLeft),
			ButtonTriggerRight: int(ebiten.StandardGamepadButtonFrontTopRight),
			ButtonBack:         int(ebiten.StandardGamepadButtonCenterLeft),
			ButtonStart:        int(ebiten.StandardGamepadButtonCenterRight),
			ButtonA:            int(ebiten.StandardGamepadButtonRightBottom),
			ButtonB:            int(ebiten.StandardGamepadButtonRightRight),
			ButtonX:            int(ebiten.StandardGamepadButtonRightTop),
			ButtonY:            int(ebiten.StandardGamepadButtonRightLeft),
		},
	},
}
View Source
var Volume float64 = 1.0

Functions

func AddGamepadDefinition

func AddGamepadDefinition(g GamepadDefinition)

func DrawArc

func DrawArc(screen *ebiten.Image, posX, posY float64, radius float64, start, end float64, color color.Color)

DrawArc is an inefficient pixel-based arc drawererer

func DrawTextOutline

func DrawTextOutline(text *etxt.Renderer, screen *ebiten.Image, str string, x, y int, scale int)

func GetAxis

func GetAxis(gamemap string, id int, which int) float64

func GetBestGamemap

func GetBestGamemap(id int) string

func GetButton

func GetButton(gamemap string, id int, which int) bool

func GetFunctionalGamepads

func GetFunctionalGamepads() (c []int)

func ReadClipboard

func ReadClipboard() string

func WriteClipboard

func WriteClipboard(text string)

Types

type ActorSpawn

type ActorSpawn struct {
	ID           string         `yaml:"id"`
	Spawn        [3]int         `yaml:"spawn,omitempty"`
	Type         string         `yaml:"type"`
	Sprite       string         `yaml:"sprite"`
	BulletGroups []*BulletGroup `yaml:"bullets,omitempty"`
	Interactive  *Interactive   `yaml:"interactive,omitempty"`
}

type Bullet

type Bullet struct {
	BulletType      *string  `yaml:"bulletType,omitempty"`
	Color           *[]int   `yaml:"color,omitempty"`
	Radius          *int     `yaml:"radius,omitempty"`
	Speed           *float64 `yaml:"speed,omitempty"`
	Acceleration    *float64 `yaml:"acceleration,omitempty"`
	AccelAccel      *float64 `yaml:"accelAccel,omitempty"`
	MinSpeed        *float64 `yaml:"minSpeed,omitempty"`
	MaxSpeed        *float64 `yaml:"maxSpeed,omitempty"`
	AngularVelocity *float64 `yaml:"angularVelocity,omitempty"`
	AimTime         *int     `yaml:"aimTime,omitempty"`
	AimDelay        *int     `yaml:"aimDelay,omitempty"`
	Damage          *int     `yaml:"damage,omitempty"`
}

Omits empty to allow for overriding from enemy definition

type BulletGroup

type BulletGroup struct {
	Alias         *string `yaml:"alias,omitempty"`
	Angle         *string `yaml:"angle,omitempty"`
	FixedAngle    *int    `yaml:"fixedAngle,omitempty"`
	BulletCount   *int    `yaml:"bulletCount,omitempty"`
	LastSpawnedAt *int    `yaml:"lastSpawnedAt,omitempty"`
	SpawnRate     *int    `yaml:"spawnRate,omitempty"`
	LoopCount     *int    `yaml:"loopCount,omitempty"`
	Bullet        *Bullet `yaml:"bullet,omitempty"`
}

func (*BulletGroup) UnmarshalYAML

func (m *BulletGroup) UnmarshalYAML(unmarshal func(interface{}) error) error

type ButtonItem

type ButtonItem struct {
	X, Y float64

	Text     string
	Callback func() bool
	// contains filtered or unexported fields
}

func (*ButtonItem) Activate

func (t *ButtonItem) Activate() bool

func (*ButtonItem) CheckState

func (t *ButtonItem) CheckState(x, y float64) bool

func (*ButtonItem) Draw

func (t *ButtonItem) Draw(ctx states.DrawContext)

func (*ButtonItem) Hidden

func (t *ButtonItem) Hidden() bool

func (*ButtonItem) Hovered

func (t *ButtonItem) Hovered() bool

func (*ButtonItem) SetHidden

func (t *ButtonItem) SetHidden(h bool)

type Cell

type Cell struct {
	Type rune `yaml:"-"` // I guess using runes is okay.
}

type ConditionDef

type ConditionDef struct {
	Type ConditionType `yaml:"type"`
	Args []string      `yaml:"args"`
}

type ConditionType

type ConditionType string

type Darkness

type Darkness struct {
	Fade     bool
	Duration time.Duration

	Fin bool
	// contains filtered or unexported fields
}

func (*Darkness) Done

func (d *Darkness) Done() bool

func (*Darkness) ID

func (d *Darkness) ID() string

func (*Darkness) Process

func (d *Darkness) Process(ctx states.DrawContext, opts *ebiten.DrawImageOptions)

type Enemy

type Enemy struct {
	Sprite       string         `yaml:"sprite"`
	Framerate    int            `yaml:"framerate"`
	Health       int            `yaml:"health"`
	Speed        int            `yaml:"speed"`
	Behavior     string         `yaml:"behavior"`
	Wander       bool           `yaml:"wander"`
	AlwaysShoot  bool           `yaml:"alwaysShoot"`
	Friendly     bool           `yaml:"friendly"`
	Bullets      []*BulletGroup `yaml:"bullets"`
	NextPhase    string         `yaml:"nextPhase"`
	SpawnOnDeath []string       `yaml:"spawnOnDeath"`
}

func (*Enemy) UnmarshalYAML

func (e *Enemy) UnmarshalYAML(unmarshal func(interface{}) error) error

type Fade

type Fade struct {
	Out      bool
	Alpha    float64
	Duration time.Duration

	ApplyToImage bool
	// contains filtered or unexported fields
}

func (*Fade) Done

func (f *Fade) Done() bool

func (*Fade) ID

func (f *Fade) ID() string

func (*Fade) Process

func (f *Fade) Process(ctx states.DrawContext, opts *ebiten.DrawImageOptions)

type GPT

type GPT struct {
	Key          string
	IsInitKey    bool   // If true, the key was from initialization
	SystemPrompt string // The prompt to use for the system
	MaxTokens    int    // 1-8192
	Model        string // "gpt-3.5-turbo-16k", "gpt-3.5-turbo" or "gpt-4"
	Style        string // the style of the translation
}

func InitGPT

func InitGPT(fs multipath.FS) *GPT

Does some set up for GPT

  • uses the gptKey variable that is set during release builds
  • or finds the api key from "assets/key.txt"
  • sets default values

func (*GPT) CheckKey

func (g *GPT) CheckKey() bool

func (*GPT) Fetch

func (g *GPT) Fetch(method, url string, requestBody *[]byte) ([]byte, error)

func (*GPT) GetKey

func (g *GPT) GetKey() string

func (*GPT) GetLocale

func (g *GPT) GetLocale(baseLocale *Locale, locale string) (*Locale, error)

func (*GPT) GetResponse

func (gpt *GPT) GetResponse(inputLocale *Locale, locale string) (Locale, error)

func (*GPT) SetKey

func (g *GPT) SetKey(key string)

type GPTRequestBody

type GPTRequestBody struct {
	Model    string        `json:"model"`
	Messages []MessageBody `json:"messages"`
}

type GPTResponse

type GPTResponse struct {
	Choices []struct {
		Message struct {
			Content string `yaml:"content"`
		} `yaml:"message"`
	} `yaml:"choices"`
}

type GamepadDefinition

type GamepadDefinition struct {
	Name  string     `yaml:"Name"`
	Match []string   `yaml:"Match"`
	Map   GamepadMap `yaml:"Map"`
}

type GamepadMap

type GamepadMap map[int]int

func GetGamemap

func GetGamemap(name string) GamepadMap

func (*GamepadMap) UnmarshalYAML

func (g *GamepadMap) UnmarshalYAML(unmarshal func(interface{}) error) error

type Hover

type Hover struct {
	Intensity float64
	Rate      float64
	// contains filtered or unexported fields
}

func (*Hover) Done

func (h *Hover) Done() bool

func (*Hover) ID

func (h *Hover) ID() string

func (*Hover) Process

func (h *Hover) Process(ctx states.DrawContext, opts *ebiten.DrawImageOptions)

type InputItem

type InputItem struct {
	X, Y        float64
	Width       float64
	Placeholder string

	Text     string
	Callback func() bool
	// contains filtered or unexported fields
}

func (*InputItem) Activate

func (t *InputItem) Activate() bool

func (*InputItem) CheckState

func (t *InputItem) CheckState(x, y float64) bool

func (*InputItem) Deactivate

func (t *InputItem) Deactivate()

func (*InputItem) Draw

func (t *InputItem) Draw(ctx states.DrawContext)

func (*InputItem) Hidden

func (t *InputItem) Hidden() bool

func (*InputItem) Hovered

func (t *InputItem) Hovered() bool

func (*InputItem) IsActive

func (t *InputItem) IsActive() bool

func (*InputItem) SetHidden

func (t *InputItem) SetHidden(h bool)

func (*InputItem) Update

func (t *InputItem) Update()

type Interactive

type Interactive struct {
	Map        *string         `yaml:"map,omitempty"`
	Conditions []*ConditionDef `yaml:"conditions,omitempty"`
	Linked     []string        `yaml:"linked,omitempty"`
	Collidable bool            `yaml:"collidable,omitempty"`
	Reversable bool            `yaml:"reversable"`
	Degrade    bool            `yaml:"degrade"`
	Active     bool            `yaml:"active"`
	Touchable  bool            `yaml:"touchable"`
	Health     int             `yaml:"health"`
	NPC        bool            `yaml:"npc"`
	Text       string          `yaml:"text"`
	RemoveVFX  []string        `yaml:"removeVFX,omitempty"`
	AddVFX     []string        `yaml:"addVFX,omitempty"`
}

type Layer

type Layer struct {
	Cells [][]Cell `yaml:"-"`
}

type Locale

type Locale map[string]string

func (*Locale) Get

func (l *Locale) Get(key string) string

type Map

type Map struct {
	Title        string
	Music        string             `yaml:"music"`
	Conditions   []*ConditionDef    `yaml:"conditions"`
	RuneMap      map[string]RuneDef `yaml:"runes"`
	Layers       []Layer            `yaml:"-"`
	Width        int                `yaml:"width"`
	Height       int                `yaml:"height"`
	SourceLayers []string           `yaml:"layers"`
	Actors       []ActorSpawn       `yaml:"actors"`
	VFX          []VFXDef           `yaml:"vfx"`
	Hints        []string           `yaml:"hints"`
	End          bool               `yaml:"end"`
}

func (*Map) UnmarshalYAML

func (m *Map) UnmarshalYAML(unmarshal func(interface{}) error) error
type MenuItem interface {
	Hovered() bool
	Draw(ctx states.DrawContext)
	CheckState(x, y float64) bool
	Activate() bool
	Hidden() bool
	SetHidden(bool)
}

type MessageBody

type MessageBody struct {
	Role    string `json:"role"`
	Content string `json:"content"`
}

type RuneDef

type RuneDef struct {
	Sprite    string `yaml:"sprite"`
	BlockView bool   `yaml:"blockView"`
	BlockMove bool   `yaml:"blockMove"`
	Wall      bool   `yaml:"wall"`
	Floor     bool   `yaml:"floor"`
	Isometric bool   `yaml:"isometric"`
	ID        string `yaml:"id,omitempty"`
}

type Song

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

func NewSong

func NewSong(rs io.ReadSeeker) (*Song, error)

func (*Song) Stream

func (s *Song) Stream() *vorbis.Stream

type Sound

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

func NewSound

func NewSound(data []byte) (*Sound, error)

func (*Sound) Play

func (s *Sound) Play(v float64) *audio.Player

type Sprite

type Sprite struct {
	Framerate int

	Loop    bool
	Reverse bool
	X, Y    float64

	Scale       float64
	Flipped     bool
	Interpolate bool
	Centered    bool
	Hidden      bool
	Options     ebiten.DrawImageOptions
	VFX         VFXList
	// contains filtered or unexported fields
}

func NewAnimatedSprite

func NewAnimatedSprite(images []*ebiten.Image) *Sprite

func NewAnimatedSpriteFromName

func NewAnimatedSpriteFromName(resources states.Resource, name string) *Sprite

func NewSprite

func NewSprite(image *ebiten.Image) *Sprite

func (*Sprite) AddImage

func (s *Sprite) AddImage(image *ebiten.Image)

func (*Sprite) Draw

func (s *Sprite) Draw(ctx states.DrawContext)

func (*Sprite) DrawWithOptions

func (s *Sprite) DrawWithOptions(ctx states.DrawContext, opts *ebiten.DrawImageOptions)

func (*Sprite) Frame

func (s *Sprite) Frame() int

func (*Sprite) Height

func (s *Sprite) Height() float64

func (*Sprite) Hit

func (s *Sprite) Hit(x, y float64) bool

func (*Sprite) Image

func (s *Sprite) Image() *ebiten.Image

func (*Sprite) Images

func (s *Sprite) Images() []*ebiten.Image

func (*Sprite) Reset

func (s *Sprite) Reset()

func (*Sprite) SetFrame

func (s *Sprite) SetFrame(frame int)

func (*Sprite) SetImage

func (s *Sprite) SetImage(image *ebiten.Image)

func (*Sprite) SetXY

func (s *Sprite) SetXY(x, y float64)

func (*Sprite) Update

func (s *Sprite) Update()

func (*Sprite) Width

func (s *Sprite) Width() float64

type SpriteItem

type SpriteItem struct {
	X, Y   float64
	Sprite *Sprite

	Callback func() bool
	// contains filtered or unexported fields
}

func (*SpriteItem) Activate

func (s *SpriteItem) Activate() bool

func (*SpriteItem) CheckState

func (s *SpriteItem) CheckState(x, y float64) bool

func (*SpriteItem) Draw

func (s *SpriteItem) Draw(ctx states.DrawContext)

func (*SpriteItem) Hidden

func (s *SpriteItem) Hidden() bool

func (*SpriteItem) Hovered

func (s *SpriteItem) Hovered() bool

func (*SpriteItem) SetHidden

func (s *SpriteItem) SetHidden(h bool)

type Sprites

type Sprites []*Sprite

type Text

type Text struct {
	Text         string
	X, Y         float64
	Scale        float64
	Outline      bool
	OutlineColor color.NRGBA
	Color        color.NRGBA
	Delay        time.Duration

	InDuration   time.Duration
	HoldDuration time.Duration
	OutDuration  time.Duration
	// contains filtered or unexported fields
}

func (*Text) Done

func (v *Text) Done() bool

func (*Text) ID

func (t *Text) ID() string

func (*Text) Process

func (v *Text) Process(ctx states.DrawContext, opts *ebiten.DrawImageOptions)

type TextItem

type TextItem struct {
	X, Y float64

	Text            string
	Underline       bool
	Callback        func() bool
	SelfRefCallback *func(*TextItem) bool
	// contains filtered or unexported fields
}

func (*TextItem) Activate

func (t *TextItem) Activate() bool

func (*TextItem) CheckState

func (t *TextItem) CheckState(x, y float64) bool

func (*TextItem) Draw

func (t *TextItem) Draw(ctx states.DrawContext)

func (*TextItem) Hidden

func (t *TextItem) Hidden() bool

func (*TextItem) Hovered

func (t *TextItem) Hovered() bool

func (*TextItem) SetHidden

func (t *TextItem) SetHidden(h bool)

type VFX

type VFX interface {
	Process(ctx states.DrawContext, opts *ebiten.DrawImageOptions)
	Done() bool
	ID() string
}

type VFXDef

type VFXDef struct {
	Type     string
	Duration time.Duration
}

type VFXList

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

func (*VFXList) Add

func (v *VFXList) Add(vfx VFX)

func (*VFXList) Empty

func (v *VFXList) Empty() bool

func (*VFXList) Items

func (v *VFXList) Items() []VFX

func (*VFXList) Process

func (v *VFXList) Process(ctx states.DrawContext, opts *ebiten.DrawImageOptions)

func (*VFXList) RemoveByID

func (v *VFXList) RemoveByID(s string)

func (*VFXList) SetMode

func (v *VFXList) SetMode(mode VFXListMode)

type VFXListMode

type VFXListMode int
const (
	Parallel VFXListMode = iota
	Sequential
)

Jump to

Keyboard shortcuts

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