Documentation
¶
Index ¶
- Variables
- func EntityMatchesSystem(entity *Entity, system ISystem) bool
- func GetInputAxis(negative, positive []ebiten.Key) int
- func KeyJustPressed(key ebiten.Key) bool
- func KeyJustReleased(key ebiten.Key) bool
- func KeyPressed(key ebiten.Key) bool
- func LoadImage(path string) *ebiten.Image
- func LoadScene(scene *Scene)
- func MouseButtonJustPressed(button ebiten.MouseButton) bool
- func MouseButtonJustReleased(button ebiten.MouseButton) bool
- func MouseButtonPressed(button ebiten.MouseButton) bool
- func PlaySoundFromFile(path string)
- func RGBA(r, g, b, a uint8) color.RGBA
- func SetDrawPosition(options *ebiten.DrawImageOptions, position Vector2)
- func Start(windowWidth, windowHeight, screenScale int, windowTitle string, ...)
- func TimeSinceStart() float64
- func ToggleFPS()
- type Entity
- func (e *Entity) AddChild(entity *Entity)
- func (e *Entity) AddChildren(entities []*Entity)
- func (e *Entity) AddComponent(component IComponent)
- func (e *Entity) AddComponents(components []IComponent)
- func (e *Entity) AddTag(tag string)
- func (e *Entity) AddTags(tags []string)
- func (e *Entity) Destroy()
- func (e *Entity) GetChildren() []*Entity
- func (e *Entity) GetComponent(id string) IComponent
- func (e *Entity) GetComponentInChildren(id string) IComponent
- func (e *Entity) GetComponentInParent(id string) IComponent
- func (e *Entity) GetComponents(id string) []IComponent
- func (e *Entity) GetComponentsInChildren(id string) []IComponent
- func (e *Entity) GetComponentsInParent(id string) []IComponent
- func (e *Entity) GetParent() *Entity
- func (e *Entity) HasComponent(id string) bool
- func (e *Entity) HasTag(tag string) bool
- func (e *Entity) RemoveChild(entity *Entity)
- func (e *Entity) RemoveChildAt(index int)
- func (e *Entity) SetParent(entity *Entity)
- type IComponent
- type ISystem
- type Scene
- func (s *Scene) AddEntities(entities []*Entity)
- func (s *Scene) AddEntity(entity *Entity)
- func (s *Scene) AddSystem(system ISystem)
- func (s *Scene) AddSystems(systems []ISystem)
- func (s *Scene) Draw(screen *ebiten.Image)
- func (s *Scene) FindComponent(id string) IComponent
- func (s *Scene) FindComponents(id string) []IComponent
- func (s *Scene) FindEntitiesOfType(id string) []*Entity
- func (s *Scene) FindEntityOfType(id string) *Entity
- func (s *Scene) GetEntitiesWithTag(tag string) []*Entity
- func (s *Scene) GetEntityWithID(id string) *Entity
- func (s *Scene) GetEntityWithTag(tag string) *Entity
- func (s *Scene) RemoveEntity(index int)
- func (s *Scene) Update()
- type Vector2
- func GetMousePosition() Vector2
- func GetScreenSize() Vector2
- func Normalized(v Vector2) Vector2
- func Vector2Add(vector Vector2, other interface{}) Vector2
- func Vector2Divide(vector Vector2, other interface{}) Vector2
- func Vector2Floor(vector Vector2) Vector2
- func Vector2Multiply(vector Vector2, other interface{}) Vector2
- func Vector2Subtract(vector Vector2, other interface{}) Vector2
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func EntityMatchesSystem ¶
Returns a bool on whether or not an entity meets the requirements of the system
func GetInputAxis ¶
func GetInputAxis(negative, positive []ebiten.Key) int
Returns an integer and is -1 if one of the negative keys specified is pressed, and returns 1 if any of the positive keys specified is pressed. Returns 0 if both or none are pressed.
func KeyJustPressed ¶
func KeyJustPressed(key ebiten.Key) bool
Returns true or false if key was just pressed this frame
func KeyJustReleased ¶
func KeyJustReleased(key ebiten.Key) bool
Returns true or false if key was just released this frame
func LoadImage ¶
func LoadImage(path string) *ebiten.Image
A helper function for getting an Ebiten image
func MouseButtonJustPressed ¶
func MouseButtonJustPressed(button ebiten.MouseButton) bool
Returns true or false if mouse button was just pressed this frame
func MouseButtonJustReleased ¶
func MouseButtonJustReleased(button ebiten.MouseButton) bool
Returns true or false if mouse button was just released this frame
func MouseButtonPressed ¶
func MouseButtonPressed(button ebiten.MouseButton) bool
Returns true or false when mouse button is being held
func PlaySoundFromFile ¶ added in v1.0.8
func PlaySoundFromFile(path string)
func SetDrawPosition ¶
func SetDrawPosition(options *ebiten.DrawImageOptions, position Vector2)
Helper function for setting a ebiten.DrawImageOptions.GeoM position (resets GeoM before doing so because Ebiten ¯\_(ツ)_/¯)
func Start ¶
func Start(windowWidth, windowHeight, screenScale int, windowTitle string, backgroundColor color.Color, onStart function)
Call this to start Pearl! :D
func TimeSinceStart ¶ added in v1.0.8
func TimeSinceStart() float64
Returns the time since the program started
Types ¶
type Entity ¶
type Entity struct { // The name / ID of the entity ID string // Whether or not the Entity is destroyed Destroyed bool // contains filtered or unexported fields }
The struct that all entities are
func (*Entity) AddChildren ¶
Adds Entities to child list
func (*Entity) AddComponent ¶
func (e *Entity) AddComponent(component IComponent)
Adds component specified to entity's component list
func (*Entity) AddComponents ¶
func (e *Entity) AddComponents(components []IComponent)
Adds each of the components specified to entity's component list
func (*Entity) Destroy ¶
func (e *Entity) Destroy()
Flags entity as destroyed and will destroy it in the next update loop
func (*Entity) GetComponent ¶
func (e *Entity) GetComponent(id string) IComponent
Returns the component with the id specified, but returns nil if entity doesn't a component with that id
func (*Entity) GetComponentInChildren ¶
func (e *Entity) GetComponentInChildren(id string) IComponent
Checks each child for component with id and returns the first one found. Returns nil if not found
func (*Entity) GetComponentInParent ¶
func (e *Entity) GetComponentInParent(id string) IComponent
Returns the component in the parent with id specified. Returns nil if parent doesn't have component
func (*Entity) GetComponents ¶
func (e *Entity) GetComponents(id string) []IComponent
Returns a slice of components found on entity, returns an empty slice if none found
func (*Entity) GetComponentsInChildren ¶
func (e *Entity) GetComponentsInChildren(id string) []IComponent
Returns slice of all components with id found in each children, returns empty slice if none found
func (*Entity) GetComponentsInParent ¶
func (e *Entity) GetComponentsInParent(id string) []IComponent
Returns a slice of components with id specified found in the parent. Returns empty list if none found
func (*Entity) HasComponent ¶
Returns bool on wether or not the entity has the component
func (*Entity) RemoveChild ¶
Removes Entity from child list, but does nothing if entity specified isn't a child of entity
func (*Entity) RemoveChildAt ¶
Removes Entity at index from child list, but does nothing if entity specified isn't a child of entity
type IComponent ¶
type IComponent interface { // Returns name / ID of component ID() string }
The interface all components will implement
type ISystem ¶
type ISystem interface { // Your update loop (called 60 times per second) before draw Update(entity *Entity, scene *Scene) // Your draw loop (called 60 times per second) after update Draw(entity *Entity, scene *Scene, screen *ebiten.Image, options *ebiten.DrawImageOptions) // Should return a slice of strings that have the IDs of all components required GetRequirements() []string }
The interface all systems will implement
type Scene ¶
type Scene struct { // The Scene's name / ID ID string // A list of the Scene's Entities Entities []*Entity // A list of the Scene's Systems Systems []ISystem }
The struct that all Scenes are
func (*Scene) AddEntities ¶
Adds Entities specified to Scene's entity list
func (*Scene) AddSystems ¶
Adds Systems specified to Scene's System list
func (*Scene) Draw ¶
func (s *Scene) Draw(screen *ebiten.Image)
This is automatically called, and it draws all Entities and Systems
func (*Scene) FindComponent ¶
func (s *Scene) FindComponent(id string) IComponent
Returns the first component found on the first entity found, returns nil if not found
func (*Scene) FindComponents ¶
func (s *Scene) FindComponents(id string) []IComponent
Returns a slice of Components found, returns empty slice if none found
func (*Scene) FindEntitiesOfType ¶
Returns a slice of Entities found with Component
func (*Scene) FindEntityOfType ¶
Returns the first Entity found with specified component, but if none found returns nil
func (*Scene) GetEntitiesWithTag ¶
Returns a slice of Entities found with the specified tag
func (*Scene) GetEntityWithID ¶
Returns Entity from Scene's entity list with ID specified, and returns nil if Scene doesn't have an Entity with that ID
func (*Scene) GetEntityWithTag ¶
Returns first Entity found with tag, but returns nil if not found
func (*Scene) RemoveEntity ¶
Removes Entity at index (might cause problems if you use this. It's best to just call Destroy() and let Pearl handle it, but you do you XD)
type Vector2 ¶
The Vector2 struct
func Normalized ¶
Returns a copy of the Vector2 normalized (doesn't change Vector2)
func Vector2Add ¶
Adds b to vector. returns result
func Vector2Divide ¶
Divides a and b (doesn't change variables)
func Vector2Floor ¶
Returns Vector2 floored (doesn't change Vector2)
func Vector2Multiply ¶
Multiplies a and b (doesn't change variables)
func Vector2Subtract ¶
Subtracts a and b (doesn't change variables)
func (*Vector2) Add ¶
func (v *Vector2) Add(other interface{})
Adds Vector2 and other (changes Vector2)
func (*Vector2) Divide ¶
func (v *Vector2) Divide(other interface{})
Divides Vector2 and other (changes Vector2)
func (*Vector2) Multiply ¶
func (v *Vector2) Multiply(other interface{})
Multiplies Vector2 and other (changes Vector2)