game

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2016 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultSpeed = 4

	// delay between pattern spawning (milliseconds)
	PatternDelayMillis = 1000

	// 'difficulty' constants for patterns?
	LowDifficulty    = "LOW"
	MediumDifficulty = "MEDIUM"
	HighDifficulty   = "HIGH"

	// Track constants
	UpperTrack = 1
	LowerTrack = 2

	// shape constants
	TriangleType = 1
	CircleType   = 2
	SquareType   = 3

	// triangle movement state constants
	TriangleBeforeSwap = 1
	TriangleDuringSwap = 2
	TriangleAfterSwap  = 3

	// space (in pixels, I guess?) between the two tracks
	UpperTrackYAxis = 150
	LowerTrackYAxis = 250

	// x constants for sides and player
	PlayerX   = 60
	LeftSide  = 50
	RightSide = 375
	// this should be screen width probably, not a constant 400
	TrackLength = 400

	// default angle values IN DEGREES!!!! (go math requires radians but degrees make more sense...)
	DefaultCircleAngleOfDescent   float64 = 35
	DefaultTriangleAngleOfDescent float64 = 45

	JumpHeight    = LowerTrackYAxis - UpperTrackYAxis
	JumpUpSpeed   = 5
	JumpDownSpeed = 3

	StartingUpperSpeedLimit = 4
	MinimumSpeed            = 4

	ScreenWidth  = 400
	ScreenHeight = 400

	// difficulty unlock points
	MediumDifficultyUnlockSeconds = 60
	HighDifficultyUnlockSeconds   = 120
	ColorSwapUnlockSeconds        = 240

	// difficulty lock points
	LowDifficultyLockSeconds    = 150
	MediumDifficultyLockSeconds = 180
)

Variables

View Source
var (
	Debug = false
	// slice of all shape types
	ShapeTypes = [...]int{TriangleType, CircleType, SquareType}

	// slice of all difficulties
	DifficultyTypes = [...]string{LowDifficulty, MediumDifficulty, HighDifficulty}

	// track mappings so you can use the track ID to get the track's position on the y axis
	TrackMappings = map[int]int{
		UpperTrack: UpperTrackYAxis,
		LowerTrack: LowerTrackYAxis,
	}

	// subsequent track shows us what track comes after the one we're currently on.
	SubsequentTracks = map[int]int{
		UpperTrack: LowerTrack,
		LowerTrack: UpperTrack,
	}

	PersonStandingImage *ebiten.Image
	PersonJumpingImage  *ebiten.Image
	PlatformImage       *ebiten.Image
	SquareImage         *ebiten.Image
	TriangleImage       *ebiten.Image
	CircleImage         *ebiten.Image
	UpperTrackLine      *ebiten.Image
	LowerTrackLine      *ebiten.Image
	TitleImage          *ebiten.Image
	EndImage            *ebiten.Image

	UpperTrackOpts *ebiten.DrawImageOptions
	LowerTrackOpts *ebiten.DrawImageOptions

	ShapeImageMap  map[int][]*ebiten.Image
	HitboxImageMap map[int]*ebiten.Image

	// color mapping constants
	DefaultSquareColorMap   ebiten.ColorM
	DefaultCircleColorMap   ebiten.ColorM
	DefaultTriangleColorMap ebiten.ColorM

	// shape to default color map
	ColorMappings map[int]ebiten.ColorM
	Font          *truetype.Font

	// pattern collection
	GamePatternCollection *PatternCollection
)
View Source
var (
	AudioContext *audio.Context
)

Functions

func Load

func Load(lg zap.Logger)

func PauseBGM

func PauseBGM() error

func PlayBGM

func PlayBGM(bgm BGM) error

func PlaySE

func PlaySE(se SE) error

func ResumeBGM

func ResumeBGM(bgm BGM) error

func SetBGMVolume

func SetBGMVolume(volume float64)

Types

type BGM

type BGM string
const (
	BGM0 BGM = "Dub_Star.ogg"
)

type BaseShape

type BaseShape struct {
	Track     int
	Center    *coord
	BaseSpeed int
	// contains filtered or unexported fields
}

func NewBaseShape

func NewBaseShape(track int, centerX int, baseSpeed int, image *ebiten.Image, colorMap ebiten.ColorM) *BaseShape

func (*BaseShape) CenterCoord

func (s *BaseShape) CenterCoord() *coord

func (*BaseShape) Draw

func (s *BaseShape) Draw(screen *ebiten.Image)

func (*BaseShape) Dst

func (s *BaseShape) Dst(i int) (x0, y0, x1, y1 int)

func (*BaseShape) Image

func (s *BaseShape) Image() *ebiten.Image

func (*BaseShape) IsExpired

func (s *BaseShape) IsExpired() bool

func (*BaseShape) Len

func (s *BaseShape) Len() int

func (*BaseShape) RgbaImage

func (s *BaseShape) RgbaImage() *image.RGBA

func (*BaseShape) Scored

func (s *BaseShape) Scored() bool

func (*BaseShape) SetScore

func (s *BaseShape) SetScore(b bool)

func (*BaseShape) Src

func (s *BaseShape) Src(i int) (x0, y0, x1, y1 int)

type Circle

type Circle struct {
	*BaseShape
	// this is expected to be degrees.
	TravelAngle      float64
	DestinationTrack int
}

func NewCircle

func NewCircle(base *BaseShape) *Circle

default initializer for Circle. this sets TravelAngle to a default of 45 degrees

func NewCircleNonStandardAngle

func NewCircleNonStandardAngle(base *BaseShape, travelAngle float64) *Circle

if you want a different angle of descent, use this initializer

func (*Circle) Update

func (c *Circle) Update()

type Drawable

type Drawable interface {
	Draw(screen *ebiten.Image)
	Image() *ebiten.Image
	RgbaImage() *image.RGBA
	CenterCoord() *coord
	Update()
	Len() int
	Dst(int) (int, int, int, int)
	Src(int) (int, int, int, int)
	IsExpired() bool
	Scored() bool
	SetScore(bool)
}

type Loop

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

func NewLoop

func NewLoop(stream audio.ReadSeekCloser, size int64) *Loop

func (*Loop) Close

func (l *Loop) Close() error

func (*Loop) Read

func (l *Loop) Read(b []byte) (int, error)

func (*Loop) Seek

func (l *Loop) Seek(offset int64, whence int) (int64, error)

type Pattern

type Pattern struct {
	SpawnGroups []*SpawnGroup
}

func NewPattern

func NewPattern(spawnGroups []*SpawnGroup) *Pattern

type PatternCollection

type PatternCollection struct {
	Patterns map[string][]*Pattern
}

func PatternCollectionFromJSON

func PatternCollectionFromJSON(data []byte) *PatternCollection

type PlayerCharacter

type PlayerCharacter struct {
	Center   *coord
	Collided bool
	// contains filtered or unexported fields
}

func NewPlayerCharacter

func NewPlayerCharacter(name string, image *ebiten.Image, jimage *ebiten.Image, keyboardWrapper *keyboard.KeyboardWrapper) *PlayerCharacter

func (*PlayerCharacter) CheckCollision

func (pc *PlayerCharacter) CheckCollision(sc *ShapeCollection)

func (*PlayerCharacter) CheckScore

func (pc *PlayerCharacter) CheckScore(sc *ShapeCollection)

func (*PlayerCharacter) Draw

func (pc *PlayerCharacter) Draw(screen *ebiten.Image)

func (*PlayerCharacter) Dst

func (pc *PlayerCharacter) Dst(i int) (x0, y0, x1, y1 int)

func (*PlayerCharacter) Image

func (pc *PlayerCharacter) Image() *ebiten.Image

func (*PlayerCharacter) Len

func (pc *PlayerCharacter) Len() int

func (*PlayerCharacter) RgbaImage

func (pc *PlayerCharacter) RgbaImage() *image.RGBA

func (*PlayerCharacter) Score

func (pc *PlayerCharacter) Score() int

func (*PlayerCharacter) Src

func (pc *PlayerCharacter) Src(i int) (x0, y0, x1, y1 int)

func (*PlayerCharacter) Update

func (pc *PlayerCharacter) Update() error

type SE

type SE string
const (
	SE_JUMP SE = "jump.wav"
)

type ShapeCollection

type ShapeCollection struct {
	Stop bool
	// contains filtered or unexported fields
}

func NewShapeCollection

func NewShapeCollection() *ShapeCollection

func (*ShapeCollection) Add

func (s *ShapeCollection) Add(g Drawable)

func (*ShapeCollection) Draw

func (s *ShapeCollection) Draw(screen *ebiten.Image)

func (*ShapeCollection) Update

func (s *ShapeCollection) Update()

type Spawn

type Spawn struct {
	ShapeType int
	Track     int
	Speed     int
}

func NewSpawn

func NewSpawn(shapeType int, track int, speed int) *Spawn

func NewSpawnDefaultSpeed

func NewSpawnDefaultSpeed(shapeType int, track int) *Spawn

type SpawnGroup

type SpawnGroup struct {
	Spawns []*Spawn
	// how long since the start of the pattern to spawn this group of shapes
	SpawnTimeMillis int
}

func NewSpawnGroup

func NewSpawnGroup(spawns []*Spawn, spawnTimeMillis int) *SpawnGroup

type Square

type Square struct {
	*BaseShape
}

func NewSquare

func NewSquare(base *BaseShape) *Square

func (*Square) Update

func (s *Square) Update()

type Stationary

type Stationary struct {
	Image *ebiten.Image
	X     int
	Y     int
}

func (*Stationary) Draw

func (s *Stationary) Draw(screen *ebiten.Image)

func (*Stationary) Dst

func (s *Stationary) Dst(i int) (x0, y0, x1, y1 int)

func (*Stationary) Len

func (s *Stationary) Len() int

func (*Stationary) Src

func (s *Stationary) Src(i int) (x0, y0, x1, y1 int)

type Triangle

type Triangle struct {
	*BaseShape
	// this is expected to be degrees.
	TravelAngle      float64
	DestinationTrack int
	// contains filtered or unexported fields
}

func NewTriangle

func NewTriangle(base *BaseShape) *Triangle

func NewTriangleNonStandardAngle

func NewTriangleNonStandardAngle(base *BaseShape, travelAngle float64) *Triangle

func (*Triangle) Update

func (t *Triangle) Update()

Jump to

Keyboard shortcuts

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