game

package
v0.0.0-...-da61710 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2018 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Ally     collision.Label = iota << 4 // 00001 -> 010000
	Opposing                 = iota << 4 // 00010 -> 100000
	Stun                     = iota << 4 // 00011 -> 110000
)
View Source
const (
	SwordDashCooldown = 5 * time.Second
	WhipTwirlCooldown = 8 * time.Second
	SpearDashCooldown = 3 * time.Second
	NetTwirlCooldown  = 1 * time.Second
)

Variables

View Source
var (
	MoveForward  = NewAction((*Entity).moveForward, 0)
	MoveBackward = NewAction((*Entity).moveBack, 0)
	MoveRight    = NewAction((*Entity).moveRight, 0)
	MoveLeft     = NewAction((*Entity).moveLeft, 0)

	TeleportForward  = func(d float64) *Action { return NewAction(func(e *Entity) { e.teleportForward(d) }, 0) }
	TeleportBackward = func(d float64) *Action { return NewAction(func(e *Entity) { e.teleportBack(d) }, 0) }
	TeleportRight    = func(d float64) *Action { return NewAction(func(e *Entity) { e.teleportRight(d) }, 0) }
	TeleportLeft     = func(d float64) *Action { return NewAction(func(e *Entity) { e.teleportLeft(d) }, 0) }
)
View Source
var (
	SingleMelee           = EnemyDist{1, []float64{1.0, 0.0, 0.0}}
	SmallMeleeDist        = EnemyDist{8, []float64{1.0, 0.0, 0.0}}
	ModerateMeleeDist     = EnemyDist{16, []float64{1.0, 0.0, 0.0}}
	LargeMeleeDist        = EnemyDist{24, []float64{1.0, 0.0, 0.0}}
	SmallRangedDist       = EnemyDist{8, []float64{0.0, 1.0, 0.0}}
	ModerateRangedDist    = EnemyDist{16, []float64{0.0, 1.0, 0.0}}
	LargeRangedDist       = EnemyDist{24, []float64{0.0, 1.0, 0.0}}
	SmallSpecialDist      = EnemyDist{8, []float64{0.0, 0.0, 1.0}}
	ModerateSpecialDist   = EnemyDist{16, []float64{0.0, 0.0, 1.0}}
	LargeSpecialDist      = EnemyDist{24, []float64{0.0, 0.0, 1.0}}
	SmallBalancedDist     = EnemyDist{8, []float64{1.0, 1.0, 1.0}}
	ModerateBalancedDist  = EnemyDist{16, []float64{1.0, 1.0, 1.0}}
	LargeBalancedDist     = EnemyDist{24, []float64{1.0, 1.0, 1.0}}
	SmallNoMeleeDist      = EnemyDist{8, []float64{0.0, 1.0, 1.0}}
	ModerateNoMeleeDist   = EnemyDist{16, []float64{0.0, 1.0, 1.0}}
	LargeNoMeleeDist      = EnemyDist{24, []float64{0.0, 1.0, 1.0}}
	SmallNoSpecialDist    = EnemyDist{8, []float64{1.0, 1.0, 0.0}}
	ModerateNoSpecialDist = EnemyDist{16, []float64{1.0, 1.0, 0.0}}
	LargeNoSpecialDist    = EnemyDist{24, []float64{1.0, 1.0, 0.0}}
	SmallNoRangedDist     = EnemyDist{8, []float64{1.0, 0.0, 1.0}}
	ModerateNoRangedDist  = EnemyDist{16, []float64{1.0, 0.0, 1.0}}
	LargeNoRangedDist     = EnemyDist{24, []float64{1.0, 0.0, 1.0}}
)
View Source
var (
	Sword = Weapon{
			// contains filtered or unexported fields
	}
	Whip = Weapon{
			// contains filtered or unexported fields
	}
	Spear = Weapon{
			// contains filtered or unexported fields
	}
	Net = Weapon{
		// contains filtered or unexported fields
	}
)

Functions

func CleanupActiveOrgan

func CleanupActiveOrgan(cleared bool)

TODO: Refactor this name CleanupActiveOrgan cleans up when leaving an organ to return to body map

func CleanupEnemies

func CleanupEnemies()

func CleanupEntities

func CleanupEntities()

func CleanupTiles

func CleanupTiles()

CleanupTiles removes and undraws all tiles

func EnemySwordDash

func EnemySwordDash(p *Entity)

func FadeBy

func FadeBy(f float64) mod.Filter

func ImageTiles

func ImageTiles(rgba *image.RGBA) [][]Tile

func Init

func Init()

func LevelEnd

func LevelEnd() (nextScene string, result *oak.SceneResult)

func LevelInit

func LevelInit(prevScene string, inLevel interface{})

LevelInit sets up a level

func LevelLoop

func LevelLoop() bool

func NetLeft

func NetLeft(label collision.Label) func(*Entity)

func NetRight

func NetRight(label collision.Label) func(*Entity)

func NetRotateAbout

func NetRotateAbout(r *render.Reverting, pos, center physics.Vector, angle float64)

func NetTwirl

func NetTwirl(label collision.Label) func(*Entity)

func NewBasicOrgan

func NewBasicOrgan(x, y float64, w, h float64, r render.Modifiable, typ OrganType) *basicOrgan

NewBasicOrgan creates a new default organ

func NewVent

func NewVent(x, y int, r render.Renderable)

func NodeCenter

func NodeCenter(bn BodyNode) physics.Vector

TODO: Is this function in the right file? NodeCenter returns the center of a body node

func PlayAt

func PlayAt(s string, x, y float64)

func RotateAbout

func RotateAbout(r render.Modifiable, pos, center physics.Vector, angle float64)

func ShapeTiles

func ShapeTiles(sh shape.Shape, w, h int) [][]Tile

func Shoot

func Shoot(speed, accel float64, w int, c color.Color, label collision.Label, dur time.Duration, friction, mass float64, sfx string) func(e *Entity)

func SpearDash

func SpearDash(label collision.Label) func(*Entity)

func SpearJab

func SpearJab(label collision.Label) func(*Entity)

func SpearThrust

func SpearThrust(label collision.Label) func(*Entity)

func Summon

func Summon(ec EnemyCreation) func(*Entity)

func SwordDash

func SwordDash(label collision.Label) func(p *Entity)

func SwordLeft

func SwordLeft(label collision.Label) func(p *Entity)

func SwordRight

func SwordRight(label collision.Label) func(p *Entity)

func SwordRotateAbout

func SwordRotateAbout(r *render.Reverting, pos, center physics.Vector, angle float64)

func Vacuum

func Vacuum(p *Entity)

func WhipLeft

func WhipLeft(label collision.Label) func(p *Entity)

func WhipRight

func WhipRight(label collision.Label) func(p *Entity)

func WhipTwirl

func WhipTwirl(label collision.Label) func(p *Entity)

Types

type Action

type Action struct {
	Cooldown  time.Duration
	ReadyTime time.Time
	// contains filtered or unexported fields
}

func Move

func Move(dir Direction, n int) []*Action

func NewAction

func NewAction(a func(*Entity), cooldown time.Duration) *Action

func Teleport

func Teleport(dir Direction, distance float64) []*Action

func (*Action) Do

func (a *Action) Do(e HasE)

func (*Action) MustDo

func (a *Action) MustDo(e HasE)

type AttackSet

type AttackSet struct {
	NextAttack    time.Time
	WaitMillis    intrange.Range
	AttackWeights []float64
	Attacks       []*Action
}

func NewAttackSet

func NewAttackSet(wait intrange.Range, weights []float64, attacks []*Action) AttackSet

type Body

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

func Body1

func Body1() *Body

Body1 infection of the Lung Liver

func Body2

func Body2() *Body

Body2 infection of the (Liver Stomach) Heart RLung

func Body3

func Body3() *Body

Body3 infection of the (Stomach Heart Liver) Stomach

func Body4

func Body4() *Body

---------------------------- Body4 infection of the (Lung Stomach) (Brain Liver) Heart

func Body5

func Body5() *Body

Body5 infection of the (Liver Heart Stomach) (Brain Lung Lung Heart) (Brain)

func DemoBody

func DemoBody() *Body

func GetBody

func GetBody(level string) *Body

func (*Body) AddNodes

func (b *Body) AddNodes(ns ...BodyNode)

AddNodes adds a set of body nodes to the body, placing them in the graph

func (*Body) Connect

func (b *Body) Connect(a, c int) bool

Connect connects two bodyNodes on a body, and returns whether it succeeds. Failure indicates that the two nodes were already connected, or an input node did not exist

func (*Body) Infect

func (b *Body) Infect(i int)

Infect infects organs that have not previously been cleansed. If an organ is not already infected it is then added to the body's diseased organs list.

func (*Body) InfectionPattern

func (b *Body) InfectionPattern(pattern [][]int)

func (*Body) InfectionProgress

func (b *Body) InfectionProgress()

InfectionProgress is called when an organ is finished and is responsible for updating overall infection and level progress

func (*Body) InitVeins

func (b *Body) InitVeins()

func (*Body) IsAdjacent

func (b *Body) IsAdjacent(i, j int) bool

IsAdjacent returns whether the nodes at indices i and j in this graph are adjacent

func (*Body) Stats

func (b *Body) Stats() menu.LevelStats

func (*Body) VecIndex

func (b *Body) VecIndex(v physics.Vector) int

type BodyButton

type BodyButton struct {
	mouse.CollisionPhase
	*collision.Space
	// contains filtered or unexported fields
}

func NewBodyButton

func NewBodyButton(w, h float64) *BodyButton

func (*BodyButton) CenterPos

func (bb *BodyButton) CenterPos() physics.Vector

CenterPos

func (*BodyButton) Init

func (bb *BodyButton) Init() event.CID

Init aqcuires CID

func (*BodyButton) IsTravelerAdjacent

func (bb *BodyButton) IsTravelerAdjacent() bool

func (*BodyButton) SetPos

func (bb *BodyButton) SetPos(v physics.Vector)

SetPos sets the location for the BodyButton

type BodyNode

type BodyNode interface {
	Vec() physics.Vector
	Dims() (int, int)
	SetPos(physics.Vector)
	Organ() (Organ, bool)
	Infect(...float64) bool
	DiseaseLevel() float64
	Cleanse()
	R() render.Modifiable
}

BodyNode is a node on the body that can be traveled to

type BodyTraveler

type BodyTraveler struct {
	entities.Doodad
	// contains filtered or unexported fields
}

A BodyTraveler is an entity that travels along the veins of a body on the body layer

func NewBodyTraveler

func NewBodyTraveler(x, y float64) *BodyTraveler

NewBodyTraveler creates a BodyTraveler, binding the appropriate functions to a Sprite

func (*BodyTraveler) CenterPos

func (bt *BodyTraveler) CenterPos() physics.Vector

CenterPos returns a vector to the center of BodyTraveler

func (*BodyTraveler) Init

func (bt *BodyTraveler) Init() event.CID

Init obtains a CID for an entity

type Direction

type Direction int
const (
	Forward Direction = iota
	Backward
	Left
	Right
	Wait
)

func (Direction) Move

func (dir Direction) Move() *Action

func (Direction) Teleport

func (dir Direction) Teleport(distance float64) *Action

type Enemy

type Enemy struct {
	Entity
	Health int
	AttackSet
	MoveSet
	// contains filtered or unexported fields
}

func NewBoomer

func NewBoomer(x, y int, diff float64, summoned bool) *Enemy

func NewDasher

func NewDasher(x, y int, diff float64, summoned bool) *Enemy

func NewEnemy

func NewEnemy(x, y, w, h float64, r render.Renderable, friction, mass, speed, maxSpeed float64, summoned bool) (e *Enemy)

func NewMelee

func NewMelee(x, y int, diff float64, summoned bool) *Enemy

func NewRanged

func NewRanged(x, y int, diff float64, summoned bool) *Enemy

func NewSummoner

func NewSummoner(x, y int, diff float64, summoned bool) *Enemy

func NewVacuumer

func NewVacuumer(x, y int, diff float64, summoned bool) *Enemy

func NewWizard

func NewWizard(x, y int, diff float64, summoned bool) *Enemy

func (*Enemy) Cleanup

func (e *Enemy) Cleanup()

func (*Enemy) Destroy

func (e *Enemy) Destroy()

func (*Enemy) Init

func (e *Enemy) Init() event.CID

type EnemyCreation

type EnemyCreation func(x, y int, difficulty float64, summoned bool) *Enemy

type EnemyDist

type EnemyDist struct {
	N       int
	Chances []float64
}

func RandomDist

func RandomDist(enemyCount int) EnemyDist

func (EnemyDist) Poll

func (ed EnemyDist) Poll() []EnemyType

type EnemyType

type EnemyType int
const (
	Melee EnemyType = iota
	Ranged
	Special
)

type Entity

type Entity struct {
	entities.Interactive
	physics.Mass
	Dir physics.Vector
	// contains filtered or unexported fields
}

func NewEntity

func NewEntity(x, y, w, h float64, r render.Renderable, id event.CID,
	friction, mass float64) *Entity

func (*Entity) CenterPos

func (e *Entity) CenterPos() physics.Vector

func (*Entity) Cleanup

func (e *Entity) Cleanup()

func (*Entity) E

func (e *Entity) E() *Entity

func (*Entity) Init

func (e *Entity) Init() event.CID

type HasE

type HasE interface {
	E() *Entity
}

type Infectable

type Infectable struct {
	Disease float64
	// contains filtered or unexported fields
}

func (*Infectable) Cleanse

func (i *Infectable) Cleanse()

func (*Infectable) DiseaseLevel

func (i *Infectable) DiseaseLevel() float64

func (*Infectable) Infect

func (i *Infectable) Infect(fs ...float64) bool

func (*Infectable) R

func (i *Infectable) R() render.Modifiable

type MoveSet

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

func NewMoveSet

func NewMoveSet(weights []float64, actions ...[]*Action) MoveSet

type Organ

type Organ interface {
	BodyNode
	Place()
	Waves(...Wave) Organ
}

func NewBrain

func NewBrain(x, y float64) Organ

func NewHeart

func NewHeart(x, y float64) Organ

func NewLiver

func NewLiver(x, y float64) Organ

func NewLung

func NewLung(x, y float64) Organ

func NewRLung

func NewRLung(x, y float64) Organ

func NewStomach

func NewStomach(x, y float64) Organ

type OrganType

type OrganType int
const (
	Liver OrganType = iota
	Lung
	Heart
	Stomach
	Brain
)

type Player

type Player struct {
	Entity
	Weapon
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer() *Player

func (*Player) Init

func (p *Player) Init() event.CID

type Shot

type Shot struct {
	Entity
	// contains filtered or unexported fields
}

func MakeShot

func MakeShot(pos physics.Vector, dir physics.Vector, speed, accel float64, w int, c color.Color,
	label collision.Label, dur time.Duration, friction, mass float64) *Shot

func (*Shot) Init

func (s *Shot) Init() event.CID

type Tile

type Tile int
const (
	Open Tile = iota
	Blocked
	Exit
	PlayerStart
	Anchor
	PressureFan
	Ventricle
	Acid
	LowDamage
	HighDamage
)

func (Tile) Place

func (t Tile) Place(x, y int, typ OrganType)

type Vein

type Vein struct {
	*render.Sprite
}

A Vein is a graphical connection between nodes on the body

func NewVein

func NewVein(n1, n2 BodyNode, b *Body) *Vein

NewVein creates a Vein

func (*Vein) Refresh

func (v *Vein) Refresh(n1, n2 BodyNode, b *Body)

type VeinNode

type VeinNode struct {
	physics.Vector
	*BodyButton
	Infectable
}

VeinNode is a simple node that is NOT an Organ

func NewVeinNode

func NewVeinNode(x, y float64, veinColor color.Color) *VeinNode

NewVeinNode creates a vein node

func NewVeinNodes

func NewVeinNodes(veinColor color.Color, positions ...float64) []*VeinNode

NewVeinNodes returns a set of vein nodes, pairing together adjacent float inputs as x,y pairs

func (*VeinNode) Dims

func (vn *VeinNode) Dims() (int, int)

Dims returns a static size for all veins

func (*VeinNode) Organ

func (vn *VeinNode) Organ() (Organ, bool)

Organ returns that vein is not an organ

func (*VeinNode) SetPos

func (vn *VeinNode) SetPos(v physics.Vector)

SetPos sets the position of the vein

type Vent

type Vent struct {
	event.CID
	// contains filtered or unexported fields
}

func (*Vent) Init

func (v *Vent) Init() event.CID

type Wave

type Wave struct {
	EnemyDist
	Difficulty float64
	Timelimit  time.Duration
}

type Weapon

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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