mode

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: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScoreDot = iota + 10
	ScoreComma
	ScorePercent
)
View Source
const (
	ModePiano = iota
	ModeDrum
	ModeSing
)
View Source
const (
	DelayedModeExp = iota // aka DelayedModeConverge
	DelayedModeLinear
)
View Source
const (
	Kool = iota
	Cool
	Good
	Miss // Its window is used for judging too early hit.
)

the ideal number of Judgments is: 3 + 1

View Source
const ModeAll = -1

Variables

View Source
var DefaultSample = Sample{Filename: "", Volume: 0.5}

Functions

func BPMs

func BPMs(ds []*Dynamic, duration int32) (main, min, max float64)

BPM with longest duration will be main BPM. When there are multiple BPMs with same duration, larger one will be main BPM.

func BeatTimes added in v0.6.0

func BeatTimes(ds []*Dynamic, duration int32, meter int) (times []int32)

func DifficultyPieceTimes added in v0.6.0

func DifficultyPieceTimes(dys []*Dynamic, chartDuration int32) (times []int32, durations []int32)

func Hash added in v0.6.0

func Hash(r io.Reader) ([16]byte, error)

func Level

func Level(c Chart) float64

func NewComboDrawer added in v0.6.0

func NewComboDrawer(sprites [10]draws.Sprite, src *int, timer *draws.Timer, digitGap float64, bounce float64) func(draws.Image)

Each number has different width. Number 0's width is used as standard. ComboDrawer's Draw draws each number at constant x regardless of their widths.

func NewScoreDrawer

func NewScoreDrawer(sprites [13]draws.Sprite, score *float64, digitGap float64) func(draws.Image)

Name of a function which returns closure ends with "-er".

func NewScoreSprites added in v0.6.0

func NewScoreSprites(fsys fs.FS, ScreenSize draws.Vector2, scale float64) [13]draws.Sprite

func SetTPS added in v0.6.0

func SetTPS(new float64)

func ToSecond added in v0.6.0

func ToSecond(ms int32) float64

func ToTick

func ToTick(ms int32) int

func ToTime

func ToTime(tick int) int32

Types

type Chart

type Chart interface {
	Duration() int32
	Difficulties() []float64
}

type ChartHeader

type ChartHeader struct {
	SetID int32 // Compatibility for osu.
	ID    int32 // Compatibility for osu.

	MusicName     string
	MusicUnicode  string
	Artist        string
	ArtistUnicode string
	MusicSource   string
	ChartName     string
	Charter       string
	CharterID     int32
	HolderID      int32 // When the chart is uploaded by non-charter.
	Tags          []string

	PreviewTime        int32
	MusicFilename      string // Filename is fine to use. (cf. FileName; Filepath)
	BackgroundFilename string
	VideoFilename      string
	VideoTimeOffset    int32

	Mode    int
	SubMode int

	// Hash works as id in database.
	// Hash is not exported to file.
	ChartHash [16]byte // MD5

	// MusicHash is used to check for music updates.
	// A player may replace the music file with another,
	// such as a higher-quality version.
	MusicHash [16]byte // MD5
}

ChartHeader contains non-play information. Changing ChartHeader's data will not affect integrity of the chart. Mode-specific fields are located to each Chart struct.

func NewChartHeader

func NewChartHeader(f any) (c ChartHeader)

func (ChartHeader) WindowTitle

func (c ChartHeader) WindowTitle() string

type Delayed added in v0.6.0

type Delayed struct {
	Mode     int
	Feedback float64

	Target  float64
	Delayed float64
	// contains filtered or unexported fields
}

For displaying score with scrolling effect.

func NewDelayed added in v0.6.0

func NewDelayed(src *float64) Delayed

func (*Delayed) Update added in v0.6.0

func (d *Delayed) Update()

type Dynamic added in v0.6.0

type Dynamic struct {
	Time    int32
	BPM     float64
	Speed   float64
	Meter   int
	NewBeat bool // NewBeat draws a bar.

	Volume    float64 // Used when sample volume is 0.
	Highlight bool

	Position float64
	// Next and Prev are used in each mode too, hence exported.
	Next *Dynamic
	Prev *Dynamic
}

Except Volume, all fields in Dynamic are related in beat, or 'Pace'. Tempo: Allergo, Adagio Rhythm: confusing with pattern Measure: aka BPM Meter: confusing with field 'Meter'

func NewDynamics added in v0.6.0

func NewDynamics(f any) []*Dynamic

func NextDynamics added in v0.6.0

func NextDynamics(d *Dynamic, now int32) *Dynamic

func (Dynamic) BeatDuration added in v0.6.0

func (d Dynamic) BeatDuration(meter int) float64

0: Use default meter.

type Judgment

type Judgment struct {
	Window int32
	Weight float64
}

func Evaluate added in v0.6.0

func Evaluate(js []Judgment, e int32) Judgment

func Judge

func Judge(js []Judgment, e int32, a input.KeyActionType) Judgment

Judge judges in normal style: Whether a player hits a key in time. Late hit makes negative time error.

func (Judgment) Is

func (j Judgment) Is(j2 Judgment) bool

Is returns whether two Judgments are equal.

func (Judgment) IsBlank added in v0.6.0

func (j Judgment) IsBlank() bool

type Sample

type Sample struct {
	Filename string
	Volume   float64
}

func NewSample

func NewSample(f any) (s Sample)

type ScenePlay added in v0.6.0

type ScenePlay interface {
	ChartHeader() ChartHeader
	WindowTitle() string
	// int32 is enough for dealing with scene time in millisecond.
	// Maximum duration with int32 is around 24 days.
	Now() int32
	Speed() float64
	IsPaused() bool
	DebugString() string

	SetMusicVolume(float64)
	SetSpeedScale()
	SetMusicOffset(int32)

	Update() any
	Pause()
	Resume()
	Finish() any
	Draw(screen draws.Image)
}

Interface is also used when it uses the unknown struct.

type Timer

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

func NewTimer

func NewTimer(musicOffset int32, wait time.Duration) Timer

func (Timer) IsPaused added in v0.6.0

func (t Timer) IsPaused() bool

func (Timer) Now

func (t Timer) Now() int32

func (*Timer) Pause added in v0.6.0

func (t *Timer) Pause()

func (*Timer) Resume added in v0.6.0

func (t *Timer) Resume()

func (*Timer) SetMusicOffset added in v0.6.0

func (t *Timer) SetMusicOffset(new int32)

TL;DR: If you tend to hit early, set positive offset. It leads to delayed music / early start time.

func (*Timer) SetMusicPlayed added in v0.6.0

func (t *Timer) SetMusicPlayed(now time.Time)

No update t.startTime here. Notes would look like they suddenly teleport at the beginning.

func (Timer) StartTime

func (t Timer) StartTime() time.Time

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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