utils

package
v0.0.0-...-d117184 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MenuWidth  = 50
	MenuHeight = 12

	// leaderboard files
	MarathonScoreFile = "internal/leaderboard/data/tetris_marathon_scores.csv"
	SprintScoreFile   = "internal/leaderboard/data/tetris_sprint_scores.csv"
	UltraScoreFile    = "internal/leaderboard/data/tetris_ultra_scores.csv"
	SnakeScoreFile    = "internal/leaderboard/data/snake_scores.csv"

	ExitScreenTickSpeed  = 2   // seconds
	LoadingTickSpeed     = 2   // milliseconds
	LoadingDotPulseSpeed = 500 // milliseconds

	// different types of screens for the arcade menus
	ScreenLoading = Screen(iota)
	ScreenMainMenu
	ScreenGameMenu
	ScreenScoreMenu
	ScreenLeaderboard

	// Colors for styling
	GopherColor       = "#00ADD8"
	DarkerGopherColor = "#0082A8"

	// Art for arcade machine
	GopherMascot = `` /* 2366-byte string literal not displayed */

	// due to weird formatting had to adjust the braille art here, so even though it looks weird here,
	// it looks *mostly* fine in the arcade machine
	GopherMascotSword = `` /* 3745-byte string literal not displayed */

	BuffGopher = `` /* 10749-byte string literal not displayed */

)

Variables

View Source
var (
	ErrInvalidTypeAssertion = errors.New("invalid type assertion")
)

Functions

func HuhIntRangeOptions

func HuhIntRangeOptions(lower, upper int) []huh.Option[int]

HuhIntRangeOptions creates a new slice of integer options using the lower and upper bound (inclusive).

func NormalizeWidth

func NormalizeWidth(ascii string) string

helper function to ensure the art for the gopher is always aligned properly

func Overlay

func Overlay(bg, overlay string, row, col int, ignoreMarginWhitespace bool) (string, error)

Overlay writes the overlay string onto the background string at the specified row and column. In this case, the row and column are zero indexed.

func OverlayCenter

func OverlayCenter(bg string, overlay string, ignoreMarginWhitespace bool) (string, error)

OverlayCenter writes the overlay string onto the background string such that the middle of the overlay string will be at the middle of the overlay will be at the middle of the background.

func UpdateTypedModel

func UpdateTypedModel[T tea.Model](model *T, msg tea.Msg) (tea.Cmd, error)

UpdateTypedModel performs an update on the model using the given msg. This enables easily storing models of a concrete type without having the clutter of frequent type assertions.

Types

type Screen

type Screen int

Jump to

Keyboard shortcuts

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