GitHubCommencer

La référence API provient des commentaires de documentation Go du code source et est rédigée en anglais.

package ui

import "github.com/nsgo-dev/game/pkg/pixelfx/ui"

Vue d’ensemble

Package ui is pixelfx's UI category: damage and crit numbers, combo counters, countdowns, coin counters, health bars, hearts, alerts, achievements, level-up banners and confetti, each a pixelfx.Effect registered as "ui/<name>" when the package is imported.

Index

Variables

var Achievement = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Achievement",
		Desc:     "A toast slides in on speed lines and settles; a gold medal pops onto it in a burst of sparkles, a shine sweeps the whole toast, then it slides away.",
		Tags:     []string{"ui", "achievement", "toast", "medal", "reward", "text", "one-shot"},
		Size:     [2]int{220, 72},
		Origin:   [2]int{110, 36},
		Duration: achDuration,
		FPS:      30,
		BG:       "dark",
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#2a1405", "#5c3008", "#9a5a0e", "#d48e18", "#f5b92c", "#ffde5e", "#fff4bc", "#ffffff")},
			{Name: "ribbon", Default: pixelfx.Palette("#0c1430", "#1f3a7a", "#2f66c4", "#5aa0f0", "#a6d4ff")},
			{Name: "title", Default: pixelfx.Text("ACHIEVEMENT")},
			{Name: "text", Default: pixelfx.Text("UNLOCKED")},
			{Name: "seed", Default: pixelfx.Num(9)},
		},
	},
	New: newAchievement,
}

Achievement is a toast that slides in on speed lines and settles while a gold medal pops onto it in a burst of sparkles, a shine sweeps the whole toast, then it slides away. It is registered as "ui/achievement".

var CoinCollect = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Coin collect",
		Desc:     "A coin bursts into a fountain of spinning coins that hang, then zip one by one into a HUD counter that pops and ticks up, glints and folds away.",
		Tags:     []string{"ui", "coins", "pickup", "reward", "hud", "counter", "one-shot"},
		Size:     [2]int{176, 116},
		Origin:   [2]int{60, 102},
		Duration: coinDuration,
		FPS:      30,
		BG:       "ground",
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#2a1405", "#5c3008", "#9a5a0e", "#d48e18", "#f5b92c", "#ffde5e", "#fff4bc", "#ffffff")},
			{Name: "count", Default: pixelfx.Num(10)},
			{Name: "from", Default: pixelfx.Num(12)},
			{Name: "seed", Default: pixelfx.Num(4)},
		},
	},
	New: newCoinCollect,
}

CoinCollect bursts a coin into a fountain of spinning coins that hang, then zip one by one into a HUD counter that pops and ticks up, glints and folds away. It is registered as "ui/coin-collect".

var ComboCounter = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Combo counter",
		Desc:     "x5 COMBO rockets in on streaming speed lines, smearing, and slams to a stop: a white flash, a ring, sparks; it pulses while a timer bar drains, then whooshes out.",
		Tags:     []string{"ui", "combo", "counter", "combat", "text", "one-shot"},
		Size:     [2]int{208, 100},
		Origin:   [2]int{104, 50},
		Duration: comboDuration,
		FPS:      30,
		BG:       "dark",
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#1a0516", "#3d0a33", "#701560", "#b0228f", "#f53cd1", "#ff86e6", "#ffd2f6", "#ffffff")},
			{Name: "count", Default: pixelfx.Num(5)},
			{Name: "label", Default: pixelfx.Text("COMBO")},
			{Name: "seed", Default: pixelfx.Num(6)},
		},
	},
	New: newComboCounter,
}

ComboCounter rockets "x5 COMBO" in on streaming speed lines, slams to a stop with a flash, ring and sparks, pulses while a timer bar drains, then whooshes out. It is registered as "ui/combo-counter".

var Confetti = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Confetti",
		Desc:     "Two party poppers bang one after the other: paper bits and curly streamers burst out, stall, then tumble and flutter down, flipping, and settle on the floor.",
		Tags:     []string{"ui", "celebration", "confetti", "party", "reward", "one-shot"},
		Size:     [2]int{200, 140},
		Origin:   [2]int{100, 126},
		Duration: confettiDuration,
		FPS:      30,
		BG:       "ground",
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#ff4a5a", "#ff9a2a", "#ffe03c", "#5ad84a", "#3cc8ff", "#7a6cff", "#f53cd1")},
			{Name: "seed", Default: pixelfx.Num(11)},
		},
	},
	New: newConfetti,
}

Confetti fires two party poppers one after the other so paper bits and curly streamers burst out, stall, tumble and flutter down, flipping, and settle on the floor. It is registered as "ui/confetti".

var Countdown = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Countdown",
		Desc:     "3, 2, 1 slam into a timer ring that drains like a burning fuse, throwing sparks; then GO! bursts out as the ring blows into a shockwave with rays.",
		Tags:     []string{"ui", "countdown", "start", "timer", "text", "one-shot"},
		Size:     [2]int{152, 136},
		Origin:   [2]int{76, 68},
		Duration: cdDuration,
		FPS:      30,
		BG:       "dark",
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#0a1030", "#142a66", "#1f4fae", "#2f86e6", "#5cc4ff", "#a8e8ff", "#e6fbff", "#ffffff")},
			{Name: "go", Default: pixelfx.Palette("#0b2410", "#16501c", "#22882a", "#3cc23a", "#7ee84c", "#c4ff8a", "#f0ffd6", "#ffffff")},
			{Name: "from", Default: pixelfx.Num(3)},
			{Name: "word", Default: pixelfx.Text("GO!")},
			{Name: "seed", Default: pixelfx.Num(5)},
		},
	},
	New: newCountdown,
}

Countdown slams 3, 2, 1 into a burning-fuse timer ring that throws sparks, then bursts into GO! with a shockwave and rays. It is registered as "ui/countdown".

var CritNumber = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Crit number",
		Desc:     "CRIT 128! slams in huge and white over a jagged starburst with a hard shake and speed lines, cools to fire, holds with a shine, then pops into sparks.",
		Tags:     []string{"ui", "critical", "damage", "number", "combat", "text", "one-shot"},
		Size:     [2]int{152, 120},
		Origin:   [2]int{76, 60},
		Duration: critDuration,
		FPS:      30,
		BG:       "dark",
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#2a0710", "#5e0f16", "#a3191c", "#e0401c", "#ff7b22", "#ffb93b", "#ffe68a", "#ffffff")},
			{Name: "text", Default: pixelfx.Text("128!")},
			{Name: "label", Default: pixelfx.Text("CRIT")},
			{Name: "seed", Default: pixelfx.Num(3)},
		},
	},
	New: newCritNumber,
}

CritNumber slams "CRIT 128!" in huge and white over a jagged starburst with a hard shake and speed lines, cools to fire, holds with a shine, then pops into sparks. It is registered as "ui/crit-number".

var DamageNumber = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Damage number",
		Desc:     "A red -27 punches out of a hit spark, white for a frame, arcs up, lands with a squash and a little hop, then fades as it lifts away.",
		Tags:     []string{"ui", "damage", "number", "combat", "text", "hit", "one-shot"},
		Size:     [2]int{76, 68},
		Origin:   [2]int{30, 52},
		Duration: dmgDuration,
		FPS:      30,
		BG:       "dark",
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#1a0508", "#4a0b12", "#8c1420", "#d42a2e", "#ff5a4a", "#ff9a86", "#ffd8cc", "#ffffff")},
			{Name: "text", Default: pixelfx.Text("-27")},
			{Name: "seed", Default: pixelfx.Num(2)},
		},
	},
	New: newDamageNumber,
}

DamageNumber punches a red "-27" out of a hit spark, arcs up, lands with a squash and a hop, then fades as it lifts away. It is registered as "ui/damage-number".

var Exclamation = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Exclamation",
		Desc:     "A bold ! springs up off the hero's head, stretching as it shoots up and squashing as it lands; surprise ticks flick out, it wobbles, then pops away.",
		Tags:     []string{"ui", "alert", "surprise", "emote", "character", "one-shot"},
		Size:     [2]int{84, 104},
		Origin:   [2]int{42, 92},
		Duration: exclDuration,
		FPS:      30,
		BG:       "ground",
		Actor:    2,
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#2a1405", "#6a2e06", "#b85a0a", "#f08c14", "#ffc23a", "#ffe580", "#fff6c8", "#ffffff")},
			{Name: "seed", Default: pixelfx.Num(3)},
		},
	},
	Act: &pixelfx.Act{
		Poses: []pixelfx.Key{
			{T: -0.08, Pose: pixelfx.Ready},
			{T: 0, Pose: exclStartled, How: "snap"},
			{T: 0.14, Pose: exclStartled.With(pixelfx.Y.Is(0), pixelfx.Crouch.Is(4), pixelfx.FFY.Is(-4), pixelfx.FBY.Is(-4), pixelfx.FY.Is(-26), pixelfx.BY.Is(-26)), How: "in"},
			{T: 0.3, Pose: exclHold},
			{T: 1.1, Pose: exclHold},
			{T: 1.4, Pose: pixelfx.Ready},
		},
		Dust: []pixelfx.DustKick{{T: 0.14, X: 0, N: 4}},
	},
	New: newExclamation,
}

Exclamation springs a bold "!" up off the hero's head, stretching as it shoots up and squashing as it lands, with surprise ticks and a wobble before popping away. It is registered as "ui/exclamation".

var HealthBarHit = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Health bar hit",
		Desc:     "A segmented health bar takes a hit: it jolts and dips, the lost chunk flashes white and sheds chips, holds, then drains away behind a sparking edge.",
		Tags:     []string{"ui", "health", "hud", "damage", "bar", "one-shot"},
		Size:     [2]int{160, 64},
		Origin:   [2]int{80, 30},
		Duration: hbDuration,
		FPS:      30,
		BG:       "dark",
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#1a0508", "#4a0b12", "#8c1420", "#d42a2e", "#ff5a4a", "#ff9a86", "#ffd8cc", "#ffffff")},
			{Name: "from", Default: pixelfx.Num(0.8)},
			{Name: "to", Default: pixelfx.Num(0.45)},
			{Name: "seed", Default: pixelfx.Num(3)},
		},
	},
	New: newHealthBarHit,
}

HealthBarHit shows a segmented health bar taking a hit: it jolts and dips, the lost chunk flashes white and sheds chips, holds, then drains away behind a sparking edge. It is registered as "ui/health-bar-hit".

var HeartLost = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Heart lost",
		Desc:     "A HUD heart is hit: it flashes white and jolts, a crack runs down it, it splits into two halves that tumble away, leaving an empty socket that fades.",
		Tags:     []string{"ui", "health", "heart", "hud", "damage", "one-shot"},
		Size:     [2]int{96, 88},
		Origin:   [2]int{48, 34},
		Duration: hlDuration,
		FPS:      30,
		BG:       "dark",
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#1a0508", "#4a0b12", "#8c1420", "#d42a2e", "#ff5a4a", "#ff9a86", "#ffd8cc", "#ffffff")},
			{Name: "seed", Default: pixelfx.Num(5)},
		},
	},
	New: newHeartLost,
}

HeartLost shows a HUD heart taking a hit, flashing white, cracking down the middle and splitting into two tumbling halves over a fading empty socket. It is registered as "ui/heart-lost".

var LevelUp = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Level up",
		Desc:     "Gold gathers at the feet and bursts up as a pillar of light round the hero; rings climb it, LEVEL UP! drops in letter by letter, a shine sweeps it, sparkles twinkle.",
		Tags:     []string{"ui", "level", "reward", "text", "light", "one-shot"},
		Size:     [2]int{176, 138},
		Origin:   [2]int{88, 114},
		Duration: luDuration,
		FPS:      30,
		BG:       "ground",
		Actor:    2,
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#2a1405", "#5c3008", "#9a5a0e", "#d48e18", "#f5b92c", "#ffde5e", "#fff4bc", "#ffffff")},
			{Name: "text", Default: pixelfx.Text("LEVEL UP!")},
			{Name: "seed", Default: pixelfx.Num(5)},
		},
	},
	Act: &pixelfx.Act{
		OnBody: true,
		Follow: pixelfx.Val(0),
		Poses: []pixelfx.Key{
			{T: -0.3, Pose: pixelfx.Ready},
			{T: 0.28, Pose: luCoil},
			{T: 0.3, Pose: luLeap, How: "snap"},
			{T: 0.46, Pose: luLeap.With(pixelfx.Y.Is(-19))},
			{T: 0.72, Pose: luLeap.With(pixelfx.Y.Is(0), pixelfx.FFY.Is(-4), pixelfx.FBY.Is(-4)), How: "in"},
			{T: 0.74, Pose: luCoil.With(pixelfx.Crouch.Is(5)), How: "snap"},
			{T: 0.95, Pose: luPump, How: "out"},
			{T: 1.2, Pose: luPump.With(pixelfx.Crouch.Is(1), pixelfx.FY.Is(-43))},
			{T: 1.45, Pose: luPump},
			{T: 2.3, Pose: luPump.With(pixelfx.FY.Is(-41))},
			{T: 2.8, Pose: pixelfx.Ready},
			{T: 3.2, Pose: pixelfx.Ready},
		},
		Hits: []pixelfx.Hit{{T: 0.28, Stop: 0.05, Shake: 0.14, Amp: pixelfx.Val(2)}},
		Dust: []pixelfx.DustKick{{T: 0.3, X: 0, N: 7}, {T: 0.74, X: 0, N: 6}},
	},
	New: newLevelUp,
}

LevelUp gathers gold at the hero's feet and bursts up as a pillar of light while rings climb it, LEVEL UP! drops in letter by letter, a shine sweeps it and sparkles twinkle. It is registered as "ui/level-up".

var QuestComplete = &pixelfx.Effect{
	Meta: pixelfx.Meta{
		Name:     "Quest complete",
		Desc:     "A stitched ribbon unrolls from the middle, QUEST COMPLETE types on letter by letter, a gold seal stamps down and ticks, stars pop; then it all rolls away.",
		Tags:     []string{"ui", "quest", "banner", "reward", "text", "one-shot"},
		Size:     [2]int{204, 92},
		Origin:   [2]int{102, 46},
		Duration: qcDuration,
		FPS:      30,
		BG:       "dark",
		Options: []pixelfx.Option{
			{Name: "palette", Default: pixelfx.Palette("#2a1405", "#5c3008", "#9a5a0e", "#d48e18", "#f5b92c", "#ffde5e", "#fff4bc", "#ffffff")},
			{Name: "ribbon", Default: pixelfx.Palette("#1e0608", "#45101a", "#7a1a26", "#ad2632", "#d8433f", "#f27a5e", "#ffb79a")},
			{Name: "text", Default: pixelfx.Text("QUEST COMPLETE")},
			{Name: "seed", Default: pixelfx.Num(8)},
		},
	},
	New: newQuestComplete,
}

QuestComplete unrolls a stitched ribbon from the middle, types QUEST COMPLETE on letter by letter, stamps down a gold seal that ticks, pops stars, then rolls away. It is registered as "ui/quest-complete".