internal

package
v0.0.0-...-bc3edf9 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2022 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultAperture = 3
)

Variables

View Source
var (
	TitleStyle    = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("10"))
	ViewStyle     = lipgloss.NewStyle().MarginTop(1).MarginBottom(1)
	ViewportStyle = lipgloss.NewStyle().Border(lipgloss.RoundedBorder()).BorderForeground(lipgloss.Color("236"))
	GameOverStyle = lipgloss.NewStyle().Foreground(lipgloss.Color("9"))
)

Functions

func Execute

func Execute()

Types

type KeyMap

type KeyMap struct {
	Up   key.Binding
	Quit key.Binding
}

func (KeyMap) FullHelp

func (k KeyMap) FullHelp() [][]key.Binding

func (KeyMap) ShortHelp

func (k KeyMap) ShortHelp() []key.Binding

type Location

type Location struct {
	X, Y int
}

type Model

type Model struct {
	// Keys holds key bindings.
	Keys KeyMap
	// Obstacles is a data structure containing obstacles.
	Obstacles Obstacles
	// Cursor is the location of the cursor.
	Cursor Location
	// Score is the number of obstacles avoided.
	Score int
	// Help contains the Bubble Tea help model.
	Help help.Model
	// Viewport is the size of the game area.
	Viewport Location
	// Over is true when the player has lost.
	Over bool
	// Pressed is used to lock the cursor from moving until the next tick.
	Pressed bool
	// Layouted tracks whether the initial layout has been performed.
	Layouted bool
}

func NewModel

func NewModel() Model

func (Model) Frame

func (m Model) Frame() (tea.Model, tea.Cmd)

func (Model) Init

func (m Model) Init() tea.Cmd

func (Model) Update

func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd)

func (Model) View

func (m Model) View() string

type Obstacle

type Obstacle struct {
	// Aperture is the size of the opening in the obstacle.
	// Must be odd. Even values will be rounded up to the next odd value.
	Aperture int
	*Location
}

func NewObstacle

func NewObstacle(aperture int, l *Location) *Obstacle

func (*Obstacle) Collides

func (o *Obstacle) Collides(l Location) bool

type Obstacles

type Obstacles []*Obstacle

func NewObstacles

func NewObstacles(obstacles ...*Obstacle) Obstacles

func (*Obstacles) Add

func (ol *Obstacles) Add(obst *Obstacle)

func (Obstacles) Index

func (ol Obstacles) Index(i int) *Obstacle

func (*Obstacles) Remove

func (ol *Obstacles) Remove()

func (Obstacles) Rightmost

func (ol Obstacles) Rightmost() *Obstacle

type TickMsg

type TickMsg time.Time

Jump to

Keyboard shortcuts

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