piano

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Normal = iota
	Head
	Tail
	Body
)
View Source
const (
	Kool = iota
	Cool
	Good
	Miss
)

Variables

This section is empty.

Functions

func DefaultJudgments added in v0.6.0

func DefaultJudgments() []mode.Judgment

func Fingers added in v0.6.0

func Fingers(keyCount int, scratchMode ScratchMode) []int

Types

type Asset added in v0.6.0

type Asset struct {
	// asset that are not affected by key count
	ScoreSprites            [13]draws.Sprite // numbers with sign (. , %)
	ComboSprites            [10]draws.Sprite
	JudgmentAnimations      [4]draws.Animation
	DefaultHitSoundStreamer audios.StreamSeekCloser
	DefaultHitSoundFormat   audios.Format

	// asset for a field
	FieldSprite draws.Sprite
	HintSprite  draws.Sprite // bottom: hit position
	BarSprite   draws.Sprite // bottom: hit position

	// asset for each key
	KeyKindNoteTypeAnimations [][4]draws.Animation // bottom: hit position
	KeySprites                [][2]draws.Sprite    // top: hit position
	KeyLightingSprites        []draws.Sprite
	KeyLightingColors         []color.Color
	HitLightingAnimations     []draws.Animation
	HoldLightingAnimations    []draws.Animation
}

All names of fields in Asset ends with their types.

func NewAsset added in v0.6.0

func NewAsset(cfg *Config, fsys fs.FS, keyCount int, scratchMode ScratchMode) *Asset

Todo: should Scratch be excluded from fieldWidth?

type Bar

type Bar struct {
	Time int32 // Times are in milliseconds.

	Position float64
	Next     *Bar
	Prev     *Bar
}

func NewBars

func NewBars(ds []*mode.Dynamic, duration int32) (bs []*Bar)

type Chart

type Chart struct {
	mode.ChartHeader
	KeyCount int // same with ChartHeader.SubMode

	Dynamics []*mode.Dynamic
	Notes    []*Note
	Bars     []*Bar
}

func NewChart

func NewChart(cfg *Config, fsys fs.FS, name string) (*Chart, error)

NewXxx returns *Chart, while LoadXxx doesn't.

func (Chart) Difficulties

func (c Chart) Difficulties() (ds []float64)

func (Chart) Duration

func (c Chart) Duration() int32

type Config added in v0.6.0

type Config struct {
	// settings exported from parent configuration
	ScreenSize  *draws.Vector2
	MusicVolume *float64
	SoundVolume *float64
	MusicOffset *int32

	// logic-affecting settings
	Mods Mods

	KeySettings       map[int][]string
	SpeedScale        float64
	HitPosition       float64
	TailExtraDuration float64

	// others
	KeyKindWidths         [4]float64
	FieldWidthScales      map[int]float64
	NoteHeigth            float64 // Applies to all types of notes.
	FieldPosition         float64
	ComboPosition         float64
	JudgmentPosition      float64
	ScratchColor          color.NRGBA
	FieldOpacity          float64
	KeyKindLightingColors [4]color.NRGBA
	HitLightingOpacity    float64
	HoldLightingOpacity   float64

	ScoreSpriteScale    float64
	ComboSpriteScale    float64
	ComboDigitGap       float64
	JudgmentSpriteScale float64
	HintHeight          float64
	LightingSpriteScale float64
}

func NewConfig added in v0.6.0

func NewConfig(ScreenSize draws.Vector2) *Config

func (Config) FieldWidth added in v0.6.0

func (cfg Config) FieldWidth(keyCount int, sm ScratchMode) float64

func (Config) KeyWidths added in v0.6.0

func (cfg Config) KeyWidths(keyCount int, sm ScratchMode) []float64

func (Config) KeyXs added in v0.6.0

func (cfg Config) KeyXs(keyCount int, sm ScratchMode) []float64

KeyXs returns centered x positions.

func (Config) NoteExposureDuration added in v0.6.0

func (cfg Config) NoteExposureDuration(speed float64) int32

NoteExposureDuration returns time in milliseconds that cursor takes to move 1 logical pixel.

type KeyKind added in v0.6.0

type KeyKind int
const (
	One KeyKind = iota
	Two
	Mid
	Tip
)

func KeyKinds added in v0.6.0

func KeyKinds(keyCount int, scratchMode ScratchMode) []KeyKind

I'm personally proud of this code.

type Mods added in v0.6.0

type Mods struct{}

type Note

type Note struct {
	Time     int32
	Type     int
	Key      int
	Sample   mode.Sample
	Duration int32

	Position float64 // Scaled x or y value.
	Next     *Note
	Prev     *Note // For accessing to Head from Tail.

	Strain float64 // Strain is for calculating difficulty.
	// contains filtered or unexported fields
}

func NewNotes

func NewNotes(f any, keyCount int) (ns []*Note)

func (Note) Weight

func (n Note) Weight() float64

Weight is for Tail's variadic weight based on its length. For example, short long note does not require much strain to release. Todo: fine-tuning with replay data

type ScenePlay

type ScenePlay struct {
	*Config
	*Asset
	Mods
	*Chart

	mode.Timer

	*input.Keyboard
	input.KeyboardReader // for replay

	audios.SoundMap

	Scorer
	Dynamic *mode.Dynamic // Todo: Dynamic -> dynamic
	// contains filtered or unexported fields
}

func NewScenePlay

func NewScenePlay(cfg *Config, assets map[int]*Asset, fsys fs.FS, name string, replay *osr.Format) (s *ScenePlay, err error)

Todo: initialize s.Asset with s.KeyCount, then set s.Chart.

func (ScenePlay) ChartHeader added in v0.6.0

func (s ScenePlay) ChartHeader() mode.ChartHeader

func (ScenePlay) DebugString added in v0.6.0

func (s ScenePlay) DebugString() string

func (ScenePlay) Draw

func (s ScenePlay) Draw(screen draws.Image)

The name 'sprite' is used for local variable of Sprite instead of 's' to avoid confusion with the local variable of Scene.

func (ScenePlay) Finish added in v0.3.1

func (s ScenePlay) Finish() any

func (ScenePlay) IsPaused added in v0.6.0

func (s ScenePlay) IsPaused() bool

func (ScenePlay) Now added in v0.6.0

func (s ScenePlay) Now() int32

func (*ScenePlay) Pause added in v0.6.0

func (s *ScenePlay) Pause()

func (*ScenePlay) Resume added in v0.6.0

func (s *ScenePlay) Resume()

func (*ScenePlay) SetMusicOffset added in v0.6.0

func (s *ScenePlay) SetMusicOffset(offset int32)

func (ScenePlay) SetMusicVolume added in v0.6.0

func (s ScenePlay) SetMusicVolume(vol float64)

func (*ScenePlay) SetSpeedScale added in v0.6.0

func (s *ScenePlay) SetSpeedScale()

Need to re-calculate positions when Speed has changed.

func (ScenePlay) Speed

func (s ScenePlay) Speed() float64

func (*ScenePlay) Update

func (s *ScenePlay) Update() any

func (ScenePlay) WindowTitle added in v0.6.0

func (s ScenePlay) WindowTitle() string

type Scorer added in v0.6.0

type Scorer struct {
	Combo          int
	Score          float64
	JudgmentCounts []int
	// contains filtered or unexported fields
}

Todo: FlowPoint

type ScratchMode added in v0.6.0

type ScratchMode int
const (
	NoScratch ScratchMode = iota
	LeftScratch
	RightScratch
)

Jump to

Keyboard shortcuts

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