game

package
v0.0.0-...-a6bf7df Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2022 License: Unlicense Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Abort

func Abort(caught error)

Abort handles an error by checking for a nil value and panicing otherwise.

func EnableRendering

func EnableRendering(world World) *system.Rendering

func EnableScripting

func EnableScripting(world World) (*system.Scripting, *lua.LState)

func Lerp

func Lerp(a, b, distance float32) float32

Lerp is a linear interpolation implementation from many shader languages. Used to find a given distance between two known locations (coordinates).

The formula used here is taken from the Wikipedia article on the subject: https://en.wikipedia.org/wiki/Linear_interpolation#Programming_language_support

func RandomFloat32

func RandomFloat32(min, max int) float32

func RandomInt

func RandomInt(min, max int) int

func RandomInt32

func RandomInt32(min, max int) int32

func Spawn

func Spawn(world World, obj, tex string, x, y, z, scale float32) entity.Entity

func Storage

func Storage() *bolt.DB

Types

type Configuration

type Configuration struct {
	Database DatabaseConfiguration
	FPS      int32
	Window   WindowConfiguration
}

func Config

func Config() *Configuration

type DatabaseConfiguration

type DatabaseConfiguration struct {
	DSN string
}

type Library

type Library struct {
	World
}

func (Library) Spawn

func (lib Library) Spawn(state *lua.LState) int

type WindowConfiguration

type WindowConfiguration struct {
	Width      int32
	Height     int32
	Title      string
	Fullscreen bool
}

type World

type World interface {
	Update(name string, dt float32)

	System(name string) system.System

	// Component will return a component interface for the given entity and
	// component name. The caller will have to use type assertions to extract
	// the real value from the result.
	Component(entity entity.Entity, name string) component.Component

	// Entity will return the signature for the given entity ID.
	Entity(entity entity.Entity) *bitset.BitSet

	// Entities is a total count of entities living in the current world space.
	Entities() int

	// Destroy will remove the entity and all of it's dedicated component/system
	// resources from the world, freeing up room for another (new) entity.
	Destroy(entity entity.Entity)

	// RegisterComponent will reserve a new component ID with the given name.
	RegisterComponent(name string)

	// RegisterComponent will reserve a new component ID with the given name.
	RegisterSystem(system system.System, components ...string)

	// CreateEntity will add a new living entity to the world and return it.
	CreateEntity() entity.Entity

	// SignEntity will set the given entity's signature for the given component names.
	SignEntity(entity entity.Entity, components ...string)

	// AttachComponent will assign the given component name and data to the entity.
	AttachComponent(entity entity.Entity, component component.Component)
}

World instances act as coordinators between the entity, component, and system managers.

func CreateWorld

func CreateWorld() World

CreateWorld returns a pointer to an empty world in memory.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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