data

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NegativePolarity Polarity = -1
	NeutralPolarity           = 0
	PositivePolarity          = 1
)

Variables

View Source
var (
	// Images for drawing lines.
	EmptyImage    *ebiten.Image
	EmptySubImage *ebiten.Image

	// I'm sorry for violating our principles.
	OrbTinyImages   []*ebiten.Image
	OrbSmallImages  []*ebiten.Image
	OrbMediumImages []*ebiten.Image
	OrbLargeImages  []*ebiten.Image

	CellWidth, CellHeight int
	NormalFace, BoldFace  font.Face
)
View Source
var Images map[string]*ebiten.Image = make(map[string]*ebiten.Image)

Images is the map of all loaded images.

View Source
var SFX = SoundPlayer{
	// contains filtered or unexported fields
}
View Source
var Sounds map[string]*Sound = make(map[string]*Sound)

Sounds is the map of all loaded sounds.

Functions

func CurrentlyReceivingInput

func CurrentlyReceivingInput() bool

Are there any active inputs

func DrawStaticText

func DrawStaticText(txt string, font font.Face, x, y int, color color.Color, screen *ebiten.Image, shouldCenter bool)

func FormatTrackName

func FormatTrackName(p string) string

func GetImage

func GetImage(p string) (*ebiten.Image, error)

GetImage returns the image matching the given file name. IT ALSO LOADS IT.

func GetPathFiles

func GetPathFiles(p string) ([]string, error)

func GetPolarityColor

func GetPolarityColor(p Polarity) color.RGBA

Returns raw RGB values for provided polarity

func GetPolarityColorScale

func GetPolarityColorScale(p Polarity) (float64, float64, float64, float64)

Returns the scale to apply to existing color for provided polarity

func LoadConfigurations

func LoadConfigurations() error

func LoadData

func LoadData() error

LoadData loads some data.

func ReadFile

func ReadFile(p string) ([]byte, error)

func ReadImage

func ReadImage(p string) (image.Image, error)

func ReadImagesByPrefix

func ReadImagesByPrefix(prefix string) ([]image.Image, error)

Types

type BGMIcon

type BGMIcon struct {
	Clickable
}

func NewBGMIcon

func NewBGMIcon() *BGMIcon

func (*BGMIcon) Draw

func (bgm *BGMIcon) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*BGMIcon) Update

func (bgm *BGMIcon) Update()

type Button

type Button struct {
	Clickable

	OffsetX, OffsetY int // Forgive me.
	Active           bool
	Bold             bool
	Underline        bool
	Hover            bool
	// contains filtered or unexported fields
}

func NewButton

func NewButton(x, y int, txt string, onClick func()) *Button

func (*Button) Draw

func (b *Button) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*Button) IsClicked

func (b *Button) IsClicked() bool

func (*Button) IsHit

func (b *Button) IsHit() bool

func (*Button) Text

func (b *Button) Text() string

func (*Button) Update

func (b *Button) Update()

type Cell

type Cell struct {
	Kind     CellKind
	Polarity Polarity
}

type CellKind

type CellKind int
const (
	NoneCell CellKind = iota
	PlayerCell
	PathCell
	CoreCell
	BlockedCell
	EmptyCell
	NorthSpawnCell
	SouthSpawnCell
	EnemyPositiveCell // for testing
	EnemyNegativeCell // for testing
)

type Clickable

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

Implements UIComponent interface

func (*Clickable) Draw

func (c *Clickable) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*Clickable) Image

func (c *Clickable) Image() *ebiten.Image

func (*Clickable) IsClicked

func (c *Clickable) IsClicked() bool

func (*Clickable) SetPos

func (c *Clickable) SetPos(x, y int)

func (*Clickable) Update

func (c *Clickable) Update()

type Config

type Config interface {
	LoadFromFile(p string)
}

type EntityConfig

type EntityConfig struct {
	Title            string
	Points           int
	Health           int
	Speed            float64
	Radius           float64
	Damage           int
	AttackRange      float64
	AttackRate       float64
	AttackType       string
	ProjecticleNum   int
	ProjecticleSpeed float64
	Polarity         Polarity
	Magnetic         bool
	MagnetStrength   float64
	MagnetRadius     float64
	Images           []*ebiten.Image
	LossImages       []*ebiten.Image
	VictoryImages    []*ebiten.Image
	WalkImages       []*ebiten.Image
	HeadImages       []*ebiten.Image
	ColorMultiplier  [3]float64
	ToolbeltOrder    int
	Description      string
}
var (
	PlayerInit    EntityConfig
	Player2Init   EntityConfig
	CoreConfig    EntityConfig
	TurretConfigs map[string]EntityConfig
	EnemyConfigs  map[string]EntityConfig
)

func NewCoreConfig

func NewCoreConfig() (EntityConfig, error)

func NewEnemyConfig

func NewEnemyConfig(p string) (EntityConfig, error)

func NewPlayerConfig

func NewPlayerConfig(i int) (EntityConfig, error)

func NewTurretConfig

func NewTurretConfig(p string) (EntityConfig, error)

func (*EntityConfig) LoadFromFile

func (e *EntityConfig) LoadFromFile(p string) error

type Level

type Level struct {
	LevelConfig
}

func NewLevel

func NewLevel(path string) (Level, error)

type LevelConfig

type LevelConfig struct {
	Title   string
	Next    string
	Tileset string
	Width   int
	Height  int
	Cells   [][]Cell
	Waves   []*Wave
	Points  int
}

func (*LevelConfig) LoadFromFile

func (l *LevelConfig) LoadFromFile(p string) (err error)

type MusicPlayer

type MusicPlayer struct {
	Muted bool
	// contains filtered or unexported fields
}
var BGM MusicPlayer = MusicPlayer{
	// contains filtered or unexported fields
}

func (*MusicPlayer) GetAllTracks

func (mp *MusicPlayer) GetAllTracks() []string

func (*MusicPlayer) GetCurrentTrack

func (mp *MusicPlayer) GetCurrentTrack() string

func (*MusicPlayer) Play

func (mp *MusicPlayer) Play(s *Sound)

func (*MusicPlayer) Set

func (mp *MusicPlayer) Set(p string)

func (*MusicPlayer) SetVolume

func (mp *MusicPlayer) SetVolume(v float64)

func (*MusicPlayer) Stop

func (mp *MusicPlayer) Stop()

func (*MusicPlayer) ToggleMute

func (mp *MusicPlayer) ToggleMute()

func (*MusicPlayer) Update

func (mp *MusicPlayer) Update()

type Options

type Options struct {
	Handshaker string  `` /* 131-byte string literal not displayed */
	Host       string  `short:"h" long:"host" description:"Directly hosting on an address"`
	Join       string  `short:"j" long:"join" description:"Directly join an address"`
	Search     string  `short:"s" long:"search" description:"Search for a given user using external handshaking"`
	Await      bool    `short:"a" long:"await" description:"Await for a player search"`
	Map        string  `short:"m" long:"map" description:"Map to start the game on" default:"001"`
	Name       string  `short:"n" long:"name" description:"Name to user in multiplayer"`
	Speed      float64 `short:"S" long:"speed" description:"Game speed multiplier" default:"1.0"`
	NoMusic    bool    `long:"nomusic" description:"Disable in-game music"`
	NoSound    bool    `long:"nosound" description:"Disable in-game sound"`
	NoMenu     bool    `long:"nomenu" description:"Disable main menu and immediately start game"`
	SyncRate   int     `long:"syncrate" description:"How frequently in ticks network information should be synchronized" default:"100"`
}

type Polarity

type Polarity int

func (*Polarity) Reverse

func (p *Polarity) Reverse()

type SFXIcon

type SFXIcon struct {
	Clickable
}

func NewSFXIcon

func NewSFXIcon() *SFXIcon

func (*SFXIcon) Draw

func (sfx *SFXIcon) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*SFXIcon) Update

func (sfx *SFXIcon) Update()

type Sound

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

func GetMusic

func GetMusic(p string) (*Sound, error)

func GetSound

func GetSound(p string) (*Sound, error)

GetSound returns the sound matching the given file name. IT ALSO LOADS IT.

func NewSound

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

func ReadMusic

func ReadMusic(p string) (*Sound, error)

func ReadSound

func ReadSound(p string) (*Sound, error)

func (*Sound) Play

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

Play constructs a new ebiten audio player, starts playing, and returns it. Volume is 0-1.

type SoundPlayer

type SoundPlayer struct {
	Muted bool
	// contains filtered or unexported fields
}

func (*SoundPlayer) Play

func (sp *SoundPlayer) Play(p string) *audio.Player

Wraps sound in SoundPlayer context to set muted and volume

func (*SoundPlayer) PlaySound

func (sp *SoundPlayer) PlaySound(s *Sound) *audio.Player

func (*SoundPlayer) ToggleMute

func (sp *SoundPlayer) ToggleMute()

type SpawnList

type SpawnList struct {
	Kinds     []string
	Count     int
	Spawnrate int
	Next      *SpawnList
}

SpawnList contains a list of spawns and the next spawns list.

func (*SpawnList) Clone

func (sl *SpawnList) Clone() *SpawnList

Clone clones our spawn list, wow.

type TextInput

type TextInput struct {
	Clickable

	OnChange func(s string)
	// contains filtered or unexported fields
}

Implements UIComponent interface

func NewTextInput

func NewTextInput(label, placeholder string, maxLength, x, y int) *TextInput

func (*TextInput) Draw

func (ti *TextInput) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*TextInput) GetInput

func (ti *TextInput) GetInput() string

func (*TextInput) IsClicked

func (ti *TextInput) IsClicked() bool

func (*TextInput) Update

func (ti *TextInput) Update()

type TileSet

type TileSet struct {
	OpenPositiveImage *ebiten.Image
	OpenNeutralImage  *ebiten.Image
	OpenNegativeImage *ebiten.Image
	BlockedImage      *ebiten.Image
	BackgroundImages  []*ebiten.Image
}

func LoadTileSet

func LoadTileSet(n string) (TileSet, error)

type UIComponent

type UIComponent interface {
	SetPos(x, y int)
	Image() *ebiten.Image
	Update()
	Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)
	IsClicked() bool
}

type Wave

type Wave struct {
	Spawns *SpawnList
	Next   *Wave
}

Wave contains a spawn list and the next wave.

func (*Wave) Clone

func (w *Wave) Clone() *Wave

Clone clones or wave, crazy.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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