world

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: GPL-3.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ToolNone    ToolKind = "none"
	ToolGun              = "gun"
	ToolTurret           = "turret"
	ToolWall             = "wall"
	ToolDestroy          = "destroy"
)

Variables

View Source
var ScreenHeight int = 360
View Source
var ScreenWidth int = 640

FIXME: This is a sin.

Functions

func DrawTurret

func DrawTurret(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions, bodyAnimation Animation, headAnimation Animation, polarity data.Polarity)

func DrawWaves

func DrawWaves(w *World, screen *ebiten.Image, spawnerOp *ebiten.DrawImageOptions)

This is _not_ the place for this.

func GetDirection

func GetDirection(sx, sy, tx, ty float64) (float64, float64)

Takes two sets of coordinates Returns a normalized vector for the direction from s to t

func GetDistanceVector

func GetDistanceVector(sx, sy, tx, ty float64) (float64, float64)

Returns distance between two points on each axis

func GetMagnitude

func GetMagnitude(x, y float64) float64

Calculates the magnitude of a vector

func GetToolImage

func GetToolImage(t ToolKind, k string) *ebiten.Image

Retrieves the image for a toolkind TODO: perhaps intialize toolbelt items with these instead?

func IsWithinRadius

func IsWithinRadius(sx, sy, tx, ty, radius float64) bool

func Normalize

func Normalize(vX, vY, magnitude float64) (float64, float64)

func ObjectsNearest

func ObjectsNearest[K interface{ Physics() *PhysicsObject }](l []K, x, y float64) []K

func ObjectsWithPolarity

func ObjectsWithPolarity[K interface{ Physics() *PhysicsObject }](l []K, p data.Polarity) []K

func ObjectsWithinRadius

func ObjectsWithinRadius[K interface{ Physics() *PhysicsObject }](l []K, x, y, radius float64) []K

ObjectsWithinRadius is a generic function that can apply to a slice of any object that has a Physics() *PhysicsObject method.

Types

type ActorEntity

type ActorEntity struct {
	BaseEntity
	// contains filtered or unexported fields
}

func NewActorEntity

func NewActorEntity(player *Player, config data.EntityConfig) *ActorEntity

func (*ActorEntity) Draw

func (e *ActorEntity) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*ActorEntity) Update

func (e *ActorEntity) Update(world *World) (request Request, err error)

type Animation

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

Animation manages updating and iterating through a slice of images.

func NewAnimation

func NewAnimation(images []*ebiten.Image, frameTime, speed float64) *Animation

func (*Animation) Draw

func (a *Animation) Draw(screen *ebiten.Image, op *ebiten.DrawImageOptions)

Draw draws the current animation image to screen.

func (*Animation) Image

func (a *Animation) Image() *ebiten.Image

Image returns the current image frame.

func (*Animation) Iterate

func (a *Animation) Iterate()

Iterate steps through frames and updates the current image index.

func (*Animation) Update

func (a *Animation) Update()

Update updates the animation's current image index based upon elapsed ticks.

type BaseEntity

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

func (*BaseEntity) Action

func (e *BaseEntity) Action() EntityAction

func (*BaseEntity) Animation

func (e *BaseEntity) Animation() *Animation

func (*BaseEntity) CanPathfind

func (e *BaseEntity) CanPathfind() bool

func (*BaseEntity) IsCollided

func (e *BaseEntity) IsCollided(t Entity) bool

Check whether or not the provided entity collides Should probably use entity sprites or add hitboxes to physics object

func (*BaseEntity) IsProjectile

func (e *BaseEntity) IsProjectile() bool

func (*BaseEntity) IsWithinMagneticField

func (e *BaseEntity) IsWithinMagneticField(t Entity) bool

Check whether or not the provided entity is within magnetic field

func (*BaseEntity) NetID

func (e *BaseEntity) NetID() int

func (*BaseEntity) Physics

func (e *BaseEntity) Physics() *PhysicsObject

func (*BaseEntity) SetAction

func (e *BaseEntity) SetAction(a EntityAction)

func (*BaseEntity) SetNetID

func (e *BaseEntity) SetNetID(nid int)

func (*BaseEntity) SetSteps

func (e *BaseEntity) SetSteps(s []pathing.Step)

func (*BaseEntity) Trash

func (e *BaseEntity) Trash()

func (*BaseEntity) Trashed

func (e *BaseEntity) Trashed() bool

func (*BaseEntity) Turret

func (e *BaseEntity) Turret() *Turret

type BuildMode

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

BuildMode leads to Wave mode.

func (*BuildMode) Draw

func (m *BuildMode) Draw(w *World, screen *ebiten.Image)

func (*BuildMode) Init

func (m *BuildMode) Init(w *World) error

func (*BuildMode) Local

func (m *BuildMode) Local() bool

func (BuildMode) String

func (m BuildMode) String() string

func (BuildMode) Type

func (m BuildMode) Type() net.TypedMessageType

func (*BuildMode) Update

func (m *BuildMode) Update(w *World) (next WorldMode, err error)

type CollectOrbRequest

type CollectOrbRequest struct {
	Worth     int    `json:"w"`
	Collector string `json:"c"`
	// contains filtered or unexported fields
}

func (CollectOrbRequest) Type

type CoreEntity

type CoreEntity struct {
	BaseEntity
	// contains filtered or unexported fields
}

func NewCoreEntity

func NewCoreEntity(config data.EntityConfig) *CoreEntity

func (*CoreEntity) Draw

func (e *CoreEntity) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*CoreEntity) Update

func (e *CoreEntity) Update(world *World) (request Request, err error)

type DamageCoreRequest

type DamageCoreRequest struct {
	ID     int `json:"i"` // The ID of the core that took damage.
	Damage int `json:"d"` // The Damage value.
}

func (DamageCoreRequest) Type

type DummyRequest

type DummyRequest struct {
}

DummyRequest is used to prevent action passthrough.

func (DummyRequest) Type

type EnemyEntity

type EnemyEntity struct {
	BaseEntity
	// contains filtered or unexported fields
}

func NewEnemyEntity

func NewEnemyEntity(config data.EntityConfig) *EnemyEntity

func (*EnemyEntity) CanPathfind

func (e *EnemyEntity) CanPathfind() bool

func (*EnemyEntity) Draw

func (e *EnemyEntity) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*EnemyEntity) SetSteps

func (e *EnemyEntity) SetSteps(s []pathing.Step)

func (*EnemyEntity) Update

func (e *EnemyEntity) Update(world *World) (request Request, err error)

type Entity

type Entity interface {
	Physics() *PhysicsObject
	Turret() *Turret
	Animation() *Animation
	Trashed() bool
	Trash()
	Update(world *World) (Request, error)
	Draw(screen *ebiten.Image, op *ebiten.DrawImageOptions) // Eh, might as well allow the entities to draw themselves.
	Action() EntityAction
	SetAction(a EntityAction)
	IsCollided(t Entity) bool
	IsWithinMagneticField(t Entity) bool
	// Why not.
	CanPathfind() bool
	SetSteps(p []pathing.Step)
	NetID() int
	SetNetID(nid int)
	IsProjectile() bool
}

type EntityAction

type EntityAction interface {
	// Replaceble returns if the action can be immediately replaced by another.
	Replaceable() bool
	// Complete returns if the action is completed. If it is, then it is removed by the entity.
	Complete() bool
	GetNext() EntityAction
	Type() net.TypedMessageType
}

EntityAction is the interface to represent an entity's desired action.

type EntityActionMove

type EntityActionMove struct {
	// x and y represents the target position to move to.
	X float64 `json:"x"`
	Y float64 `json:"y"`
	// distance represents the distance from the target that should be considered valid.
	Distance float64 `json:"d"`

	//
	Next EntityAction `json:"n"`
	// contains filtered or unexported fields
}

EntityActionMove represents an action that should move the entity towards a target location.

func (*EntityActionMove) Complete

func (a *EntityActionMove) Complete() bool

func (*EntityActionMove) GetNext

func (a *EntityActionMove) GetNext() EntityAction

func (*EntityActionMove) Replaceable

func (a *EntityActionMove) Replaceable() bool

func (EntityActionMove) Type

Here be code to add network support to above actions.

type EntityActionPlace

type EntityActionPlace struct {
	// x and y are cell positions to place at.
	X int
	Y int

	Tool     ToolKind      `json:"t"`
	Kind     string        `json:"k"`
	Polarity data.Polarity `json:"p"`
	// contains filtered or unexported fields
}

func (*EntityActionPlace) Complete

func (a *EntityActionPlace) Complete() bool

func (*EntityActionPlace) GetNext

func (a *EntityActionPlace) GetNext() EntityAction

func (*EntityActionPlace) Replaceable

func (a *EntityActionPlace) Replaceable() bool

func (EntityActionPlace) Type

type EntityActionShoot

type EntityActionShoot struct {
	// targetX and targetY represent the position to fire at.
	TargetX  float64       `json:"x"`
	TargetY  float64       `json:"y"`
	Polarity data.Polarity `json:"p"`

	Next EntityAction `json:"n"`
	// contains filtered or unexported fields
}

func (*EntityActionShoot) Complete

func (a *EntityActionShoot) Complete() bool

func (*EntityActionShoot) GetNext

func (a *EntityActionShoot) GetNext() EntityAction

func (*EntityActionShoot) Replaceable

func (a *EntityActionShoot) Replaceable() bool

func (EntityActionShoot) Type

type EntityPropertySync

type EntityPropertySync struct {
	X, Y   float64
	Health int `json:"h"`
	NetID  int `json:"i"`
}

func (EntityPropertySync) Type

type Game

type Game interface {
	Players() []*Player
	GetPlayerByName(p string) *Player
	Net() *net.Connection
	GetOptions() *data.Options
}

type LiveCell

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

LiveCell is a position in a live level.

func (*LiveCell) IsOpen

func (c *LiveCell) IsOpen() bool

IsOpen does what you think it does.

type LossMode

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

LossMode represents when the core 'splodes. Leads to a restart of the current.

func (*LossMode) Draw

func (m *LossMode) Draw(w *World, screen *ebiten.Image)

func (*LossMode) Init

func (m *LossMode) Init(w *World) error

func (*LossMode) Local

func (m *LossMode) Local() bool

func (LossMode) String

func (m LossMode) String() string

func (LossMode) Type

func (m LossMode) Type() net.TypedMessageType

func (*LossMode) Update

func (m *LossMode) Update(w *World) (next WorldMode, err error)

type MultiRequest

type MultiRequest struct {
	Requests []Request `json:"r"`
}

MultiRequest is a container for multiple requests.

func (MultiRequest) Type

Here be code for networking again.

type OrbEntity

type OrbEntity struct {
	BaseEntity
	// contains filtered or unexported fields
}

func NewOrbEntity

func NewOrbEntity(worth int) *OrbEntity

func (*OrbEntity) Draw

func (e *OrbEntity) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*OrbEntity) Update

func (e *OrbEntity) Update(world *World) (request Request, err error)

The orb ponders

type PhysicsObject

type PhysicsObject struct {
	// X and Y position in the world.
	X, Y float64

	// This is a bad, but I need collision offsets.
	OffsetX, OffsetY float64
	// contains filtered or unexported fields
}

func SplitVectorByDegree

func SplitVectorByDegree(spreadArc, vX, vY float64, num int) (vectors []PhysicsObject)

Returns a list of length num populated with vectors that span the given spread centered about vX and vY

func (*PhysicsObject) GetMagneticAffect

func (p *PhysicsObject) GetMagneticAffect(polarity data.Polarity, magnitude float64) float64

Retrieve the strength of the magnetic field based on distance to target

func (*PhysicsObject) GetMagneticVector

func (p *PhysicsObject) GetMagneticVector(t PhysicsObject) (float64, float64)

Retrieve the attractive/repulsive/neutral vector

type PlaySoundRequest

type PlaySoundRequest struct {
	Sound string `json:"s"`
}

func (PlaySoundRequest) Type

type Player

type Player struct {
	//
	Local bool
	// entity is the player-controlled entity.
	Entity Entity
	// I suppose the toolbelt should be here.
	Toolbelt Toolbelt
	// ReadyForWave means the players are done building and ready to start the waves.
	ReadyForWave bool
	// Name is acquired from the initial connection name.
	Name string
	//
	HoveringPlacement     bool
	HoveringPlace         EntityActionPlace
	HoverColumn, HoverRow int // X and Y hover coordinate in terms of columns/rows
	// Current points the player has.
	Points int
}

Player represents a player that controls an entity. It handles input and makes the entity dance.

func NewPlayer

func NewPlayer() *Player

func (*Player) Update

func (p *Player) Update(w *World) (EntityAction, error)

Arglebargle

type PointsSync

type PointsSync struct {
	Points map[string]int `json:"p"`
}

func (PointsSync) Type

func (r PointsSync) Type() net.TypedMessageType

type PostGameMode

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

PostGameMode is... the final victory...?

func (*PostGameMode) Draw

func (m *PostGameMode) Draw(w *World, screen *ebiten.Image)

func (*PostGameMode) Init

func (m *PostGameMode) Init(w *World) error

func (*PostGameMode) Local

func (m *PostGameMode) Local() bool

func (PostGameMode) String

func (m PostGameMode) String() string

func (PostGameMode) Type

func (*PostGameMode) Update

func (m *PostGameMode) Update(w *World) (next WorldMode, err error)

type PreGameMode

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

PreGame leads to Build mode.

func (*PreGameMode) Draw

func (m *PreGameMode) Draw(w *World, screen *ebiten.Image)

func (*PreGameMode) Init

func (m *PreGameMode) Init(w *World) error

func (*PreGameMode) Local

func (m *PreGameMode) Local() bool

func (PreGameMode) String

func (m PreGameMode) String() string

func (PreGameMode) Type

func (m PreGameMode) Type() net.TypedMessageType

func (*PreGameMode) Update

func (m *PreGameMode) Update(w *World) (next WorldMode, err error)

type ProgressBar

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

func NewProgressBar

func NewProgressBar(width, height int, barColor color.RGBA) *ProgressBar

func (*ProgressBar) Draw

func (pb *ProgressBar) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*ProgressBar) Update

func (pb *ProgressBar) Update()

type ProjecticleEntity

type ProjecticleEntity struct {
	BaseEntity
	// contains filtered or unexported fields
}

func NewProjecticleEntity

func NewProjecticleEntity() *ProjecticleEntity

func (*ProjecticleEntity) Draw

func (e *ProjecticleEntity) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*ProjecticleEntity) IsProjectile

func (e *ProjecticleEntity) IsProjectile() bool

func (*ProjecticleEntity) Update

func (e *ProjecticleEntity) Update(world *World) (request Request, err error)

type Request

type Request interface {
	Type() net.TypedMessageType
}

Request represents results from an entity's action completion.

type SelectToolbeltItemRequest

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

SelectToolbeltItemRequest selects a given toolbelt item

func (SelectToolbeltItemRequest) Type

type SpawnEnemyRequest

type SpawnEnemyRequest struct {
	X        float64
	Y        float64
	Polarity data.Polarity `json:"p"`

	Kind  string `json:"k"`
	NetID int    `json:"i"`
	// contains filtered or unexported fields
}

func (SpawnEnemyRequest) Type

type SpawnOrbRequest

type SpawnOrbRequest struct {
	X     float64
	Y     float64
	Worth int `json:"w"`
	NetID int `json:"i"`
}

func (SpawnOrbRequest) Type

type SpawnProjecticleRequest

type SpawnProjecticleRequest struct {
	X, Y float64 // Position

	NetID    int `json:"i"`
	VX, VY   float64
	Polarity data.Polarity `json:"p"`
	Damage   int           `json:"d"`
	// contains filtered or unexported fields
}

SpawnProjecticleRequest attempts to spawn a projecticle at given location with given direction

func (SpawnProjecticleRequest) Type

type SpawnToolEntityRequest

type SpawnToolEntityRequest struct {
	X, Y     int
	Tool     ToolKind      `json:"t"`
	Kind     string        `json:"k"`
	Polarity data.Polarity `json:"p"`
	NetID    int           `json:"i"`
}

SpawnToolEntityRequest is used to tell the client to spawn an entity tied to a tool.

func (SpawnToolEntityRequest) Type

type SpawnerEntity

type SpawnerEntity struct {
	BaseEntity
	// contains filtered or unexported fields
}

func NewSpawnerEntity

func NewSpawnerEntity(p data.Polarity) *SpawnerEntity

func (*SpawnerEntity) CanPathfind

func (e *SpawnerEntity) CanPathfind() bool

func (*SpawnerEntity) Draw

func (e *SpawnerEntity) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*SpawnerEntity) SetSteps

func (e *SpawnerEntity) SetSteps(s []pathing.Step)

func (*SpawnerEntity) Update

func (e *SpawnerEntity) Update(world *World) (request Request, err error)

type StartModeRequest

type StartModeRequest struct {
}

func (StartModeRequest) Type

type ToolKind

type ToolKind string

type Toolbelt

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

Toolbelt is the interface for containing user actions for placing turrets and similar.

func (*Toolbelt) ActivateItem

func (t *Toolbelt) ActivateItem(item *ToolbeltItem)

func (*Toolbelt) CheckHit

func (t *Toolbelt) CheckHit(x, y int) bool

func (*Toolbelt) Draw

func (t *Toolbelt) Draw(screen *ebiten.Image)

func (*Toolbelt) Position

func (t *Toolbelt) Position()

Position positions the toolbelt and all its tools.

func (*Toolbelt) ScrollItem

func (t *Toolbelt) ScrollItem(dir int)

func (*Toolbelt) Update

func (t *Toolbelt) Update() (request Request)

Update updates the toolbelt. This seems a bit silly, but oh well.

type ToolbeltItem

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

ToolbeltItem is a toolbelt entry.

func (*ToolbeltItem) Cycle

func (t *ToolbeltItem) Cycle()

Cycles through available selections for the toolbelt item

func (*ToolbeltItem) Draw

func (t *ToolbeltItem) Draw(screen *ebiten.Image)

func (*ToolbeltItem) DrawSlot

func (t *ToolbeltItem) DrawSlot(screen *ebiten.Image)

func (*ToolbeltItem) Position

func (t *ToolbeltItem) Position(sx, sy *int)

Position assigns the center position for the toolbelt item.

func (*ToolbeltItem) Update

func (t *ToolbeltItem) Update() (request Request)

type TouchContainer

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

type TrashEntityRequest

type TrashEntityRequest struct {
	NetID int `json:"i"`
	// contains filtered or unexported fields
}

TrashEntityRequest is send from the server to client(s) to let them know to delete the given entity.

func (TrashEntityRequest) Type

type Turret

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

func (*Turret) CanFire

func (t *Turret) CanFire(speed float64) bool

If we have a reset tick counter, we can fire and start the tick counter

func (*Turret) Tick

func (t *Turret) Tick(speed float64)

Keep track of ticks for fire rate

type TurretBeamEntity

type TurretBeamEntity struct {
	TurretEntity
	// contains filtered or unexported fields
}

func NewTurretBeamEntity

func NewTurretBeamEntity(config data.EntityConfig) *TurretBeamEntity

func (*TurretBeamEntity) AcquireTarget

func (e *TurretBeamEntity) AcquireTarget(world *World)

Finds the closest entity of same polarity within attack radius and sets the current target if found.

func (*TurretBeamEntity) Draw

func (e *TurretBeamEntity) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*TurretBeamEntity) Update

func (e *TurretBeamEntity) Update(world *World) (request Request, err error)

type TurretEntity

type TurretEntity struct {
	BaseEntity
	// contains filtered or unexported fields
}

func NewTurretEntity

func NewTurretEntity(config data.EntityConfig) *TurretEntity

func (*TurretEntity) AcquireTarget

func (e *TurretEntity) AcquireTarget(world *World)

Finds the closest entity within attack radius and sets the current target if found

func (*TurretEntity) Draw

func (e *TurretEntity) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*TurretEntity) Update

func (e *TurretEntity) Update(world *World) (request Request, err error)

type UseToolRequest

type UseToolRequest struct {
	X, Y     int
	Tool     ToolKind      `json:"t"`
	Kind     string        `json:"k"`
	Polarity data.Polarity `json:"p"`
	NetID    int           `json:"i"` // Yeah, yeah, we shouldn't have NetID here, but it's easier to reuse UseToolRequest rather than implement some new SpawnTurret/SpawnWall/RemoveWall Request set.
	Owner    string        `json:"o"` // The owner's name. This is a little excessive to send, but it's easier than mucking about with client/server index checking. Also enables more players if we ever want that.
	// contains filtered or unexported fields
}

UseToolRequest attempts to use the tool at a given cell.

func (UseToolRequest) Type

type VictoryMode

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

VictoryMode represents when all waves are finished. Leads to Travel state.

func (*VictoryMode) Draw

func (m *VictoryMode) Draw(w *World, screen *ebiten.Image)

func (*VictoryMode) Init

func (m *VictoryMode) Init(w *World) error

func (*VictoryMode) Local

func (m *VictoryMode) Local() bool

func (VictoryMode) String

func (m VictoryMode) String() string

func (VictoryMode) Type

func (m VictoryMode) Type() net.TypedMessageType

func (*VictoryMode) Update

func (m *VictoryMode) Update(w *World) (next WorldMode, err error)

type WallEntity

type WallEntity struct {
	BaseEntity
	// contains filtered or unexported fields
}

func NewWallEntity

func NewWallEntity() *WallEntity

func (*WallEntity) Draw

func (e *WallEntity) Draw(screen *ebiten.Image, screenOp *ebiten.DrawImageOptions)

func (*WallEntity) Update

func (e *WallEntity) Update(world *World) (request Request, err error)

type WaveMode

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

WaveMode leads to Wave, Loss, Victory, or PostGame.

func (*WaveMode) Draw

func (m *WaveMode) Draw(w *World, screen *ebiten.Image)

func (*WaveMode) Init

func (m *WaveMode) Init(w *World) error

func (*WaveMode) Local

func (m *WaveMode) Local() bool

func (WaveMode) String

func (m WaveMode) String() string

func (WaveMode) Type

func (m WaveMode) Type() net.TypedMessageType

func (*WaveMode) Update

func (m *WaveMode) Update(w *World) (next WorldMode, err error)

type World

type World struct {
	Game Game // Ewwww x2
	Mode WorldMode

	CameraX, CameraY float64

	CurrentWave int
	MaxWave     int

	// Overall game speed
	Speed float64
	// contains filtered or unexported fields
}

World is a struct for our cells and entities.

func (*World) AreCoresDead

func (w *World) AreCoresDead() bool

AreCoresDead returns true if all cores are dead.

func (*World) AreEnemiesDead

func (w *World) AreEnemiesDead() bool

func (*World) ArePlayersReady

func (w *World) ArePlayersReady() bool

ArePlayersReady returns true if all players are ready to start.

func (*World) AreSpawnersHolding

func (w *World) AreSpawnersHolding() bool

* WAVES *

func (*World) AreWavesComplete

func (w *World) AreWavesComplete() bool

func (*World) BuildFromLevel

func (w *World) BuildFromLevel(level data.Level) error

BuildFromLevel builds the world's cells and entities from a given base level.

func (*World) CollectOrb

func (w *World) CollectOrb(r CollectOrbRequest)

func (*World) DamageCore

func (w *World) DamageCore(r DamageCoreRequest)

func (*World) Draw

func (w *World) Draw(screen *ebiten.Image)

Draw draws the world, wow.

func (*World) GetCell

func (w *World) GetCell(x, y int) *LiveCell

func (*World) GetClosestCellPosition

func (w *World) GetClosestCellPosition(x, y int) (int, int)

func (*World) GetCursorPosition

func (w *World) GetCursorPosition() (x, y int)

GetCursorPosition returns the cursor position relative to the map.

func (*World) GetNextNetID

func (w *World) GetNextNetID() int

func (*World) HandleToolRequest

func (w *World) HandleToolRequest(r UseToolRequest) Entity

???

func (*World) IsPlacementValid

func (w *World) IsPlacementValid(placeX, placeY int) bool

func (*World) PlaceEntityAt

func (w *World) PlaceEntityAt(e Entity, x, y float64)

PlaceEntityAt places the entity into the world at the given specific coordinates.

func (*World) PlaceEntityInCell

func (w *World) PlaceEntityInCell(e Entity, x, y int)

PlaceEntity places the entity into the world, aligned by cell and centered within a cell.

func (*World) ProcessNetMessage

func (w *World) ProcessNetMessage(msg net.Message) error

func (*World) ProcessRequest

func (w *World) ProcessRequest(r Request)

func (*World) SendPlayerPoints

func (w *World) SendPlayerPoints()

func (*World) SetMode

func (w *World) SetMode(m WorldMode)

SetMode sets the current game mode to the one indicated. If we're a client and the mode set is local, this does nothing.

func (*World) SetWaves

func (w *World) SetWaves()

func (*World) SpawnEnemyEntity

func (w *World) SpawnEnemyEntity(r SpawnEnemyRequest) *EnemyEntity

func (*World) SpawnOrbEntity

func (w *World) SpawnOrbEntity(r SpawnOrbRequest) *OrbEntity

func (*World) SpawnProjecticleEntity

func (w *World) SpawnProjecticleEntity(r SpawnProjecticleRequest) *ProjecticleEntity

func (*World) SplitPoints

func (w *World) SplitPoints(value int)

func (*World) SyncEntity

func (w *World) SyncEntity(r EntityPropertySync)

func (*World) SyncPoints

func (w *World) SyncPoints(r PointsSync)

SyncPoints synchronizes the players' points to match the provided data.

func (*World) Update

func (w *World) Update() error

Update updates the world.

func (*World) UpdateEntityPathing

func (w *World) UpdateEntityPathing(e Entity)

func (*World) UpdatePathing

func (w *World) UpdatePathing()

* PATHING *

type WorldMode

type WorldMode interface {
	Type() net.TypedMessageType
	Init(w *World) error
	Update(w *World) (WorldMode, error)
	Draw(w *World, screen *ebiten.Image)
	String() string
	Local() bool
}

WorldMode represents the type for representing the current game mode

Jump to

Keyboard shortcuts

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