game

package
v0.0.0-...-0e4f151 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MinWidth  = 80
	MinHeight = 25
)

Minimum width/height of console

View Source
const (
	EnterpriseMaxEnergy    = 5000
	EnterpriseMaxTorpedoes = 20
)

Constants related to player's ship

View Source
const (
	Quadrant = iota
	GalaxyMap
	LongRangeSensors
	Quitting
)

Constants for game UI state

Variables

This section is empty.

Functions

func CheckPercent

func CheckPercent(percentage int) bool

CheckPercent returns true/false based on random number weighted by percentage

func ClearScreen

func ClearScreen()

ClearScreen clears the screen

func CloseScreen

func CloseScreen()

CloseScreen releases the screen

func Distance

func Distance(x1, y1, x2, y2 int) float64

Distance calculates the distance between two points

func DrawBox

func DrawBox(x1, y1, x2, y2 int)

DrawBox draws a box

func EmitStr

func EmitStr(x, y int, str string)

EmitStr will print a string to the screen

func GetPercent

func GetPercent() int

GetPercent returns a number between 0 and 99

func InitScreen

func InitScreen() error

InitScreen initializes the screen

func PollForEvents

func PollForEvents() chan tcell.Event

PollForEvents : Call this once, then check return channel for events periodically

func RandomInt

func RandomInt(n int) int

RandomInt returns a random int between 0 and n-1, inclusive

func ShowScreen

func ShowScreen()

ShowScreen shows the screen

func Size

func Size() (int, int)

Size returns the screen's size

Types

type Game

type Game interface {
	GetStartingKlingons() int
	GetRemainingKlingons() int
	KlingonDestroyed()
	GetStartingStarbases() int
	GetRemainingStarbases() int
	StarbaseDestroyed()

	GetStardate() float64

	GetQuadrantSummary(x, y int) *QuadrantSummary

	SetGameState(state int)

	NavigateTo(x, y int)

	Draw()
}

Game is the global object with all the overall game state

type QuadrantSummary

type QuadrantSummary struct {
	X         int
	Y         int
	Klingons  int
	Starbases int
	Stars     int
	IsActive  bool
	Scanned   bool
}

QuadrantSummary gives summary of quadrant that is used to display galaxy map

Jump to

Keyboard shortcuts

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