managers

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2020 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Overview

Package managers contains the managers for the engine

Index

Constants

View Source
const (
	DefaultLayer = float32(1000000) // DefaultLayer is the default layer depth
)

DeviceManager constants

Variables

This section is empty.

Functions

This section is empty.

Types

type CollisionManager added in v0.1.5

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

CollisionManager is a manager for manage collisions

func Collisions added in v0.1.5

func Collisions(sm *StorageManager) *CollisionManager

Collisions returns a CollisionManager

func (CollisionManager) SpriteAtContains added in v0.1.5

func (cm CollisionManager) SpriteAtContains(spr sprite.Sprite, at geometry.Point, point geometry.Point) bool

SpriteAtContains indicates if a sprite.Sprite at a given geometry.Point contains a geometry.Point

func (CollisionManager) SpritesCollides added in v0.1.7

func (cm CollisionManager) SpritesCollides(spr1 sprite.Sprite, at1 geometry.Point, spr2 sprite.Sprite, at2 geometry.Point) bool

SpritesCollides indicates if two sprite.Sprite collides

func (CollisionManager) SpritesCollidesFactor added in v0.1.8

func (cm CollisionManager) SpritesCollidesFactor(spr1 sprite.Sprite, at1 geometry.Point, spr2 sprite.Sprite, at2 geometry.Point,
	factor1 geometry.Point, factor2 geometry.Point) bool

SpritesCollidesFactor indicates if two sprite.Sprite collides with a factor

type DeviceManager

type DeviceManager interface {
	// Init the rendering device
	Init(opt options.Options)
	// End the rendering device
	End()
	// BeginFrame for rendering
	BeginFrame()
	// EndFrame for rendering
	EndFrame()
	// ShouldClose returns if th engine should close
	ShouldClose() bool
	// SetExitKey will set the exit key
	SetExitKey(key device.Key)
	// DisableExitKey will disable the exit key
	DisableExitKey()

	// GetScreenSize get the current screen size
	GetScreenSize() geometry.Size

	// GetMousePoint returns the current Point of the mouse
	GetMousePoint() geometry.Point
	// IsMouseRelease check if the given MouseButton has been release
	IsMouseRelease(button device.MouseButton) bool
	// IsMousePressed check if the given MouseButton has been pressed
	IsMousePressed(button device.MouseButton) bool

	// IsKeyPressed returns if given device.Key is pressed
	IsKeyPressed(key device.Key) bool
	// IsKeyReleased returns if given device.Key is released
	IsKeyReleased(key device.Key) bool

	// IsGamepadAvailable indicates if the game pad number is available
	IsGamepadAvailable(gamePad int32) bool
	// IsGamepadButtonPressed returns if given gamepad button is pressed
	IsGamepadButtonPressed(gamePad int32, button device.GamepadButton) bool
	// IsGamepadButtonReleased returns if given gamepad button is released
	IsGamepadButtonReleased(gamePad int32, button device.GamepadButton) bool
	// GetGamepadStickMovement return the movement, -1..1, for a given gamepad stick
	GetGamepadStickMovement(gamePad int32, stick device.GamepadStick) geometry.Point

	// GetFrameTime returns the time from the delta time for current frame
	GetFrameTime() float32

	// LoadTexture giving it file name into VRAM
	LoadTexture(fileName string) (components.TextureDef, error)
	// UnloadTexture from VRAM
	UnloadTexture(textureDef components.TextureDef)

	// LoadFont giving it file name into VRAM
	LoadFont(fileName string) (components.FontDef, error)
	// UnloadFont from VRAM
	UnloadFont(textureDef components.FontDef)

	// LoadMusic giving it file name into memory
	LoadMusic(fileName string) (components.MusicDef, error)
	// UnloadMusic giving it file from memory
	UnloadMusic(musicDef components.MusicDef)
	// PlayMusic plays the given components.MusicDef
	PlayMusic(musicDef components.MusicDef, volume float32)
	// PauseMusic pauses the given components.MusicDef
	PauseMusic(musicDef components.MusicDef)
	// StopMusic stop the given components.MusicDef
	StopMusic(musicDef components.MusicDef)
	// ResumeMusic resumes the given components.MusicDef
	ResumeMusic(musicDef components.MusicDef)
	// UpdateMusic update the stream of the given components.MusicDef
	UpdateMusic(musicDef components.MusicDef)
	// ChangeMusicVolume change the given components.MusicDef volume
	ChangeMusicVolume(musicDef components.MusicDef, volume float32)
	// LoadSound giving it file name into memory
	LoadSound(fileName string) (components.SoundDef, error)
	// UnloadSound giving it file from memory
	UnloadSound(soundDef components.SoundDef)
	// PlaySound plays the given components.SoundDef
	PlaySound(soundDef components.SoundDef, volume float32)
	// SetMasterVolume change the master volume
	SetMasterVolume(volume float32)
	// StopAllSounds currently playing
	StopAllSounds()

	// SetBackgroundColor changes the current background color.Solid
	SetBackgroundColor(color color.Solid)

	// DrawText will draw a text.Text in the given geometry.Point with the correspondent color.Color
	DrawText(ftd components.FontDef, txt ui.Text, pos geometry.Point, color color.Solid)
	// DrawSprite draws a sprite.Sprite in the given geometry.Point with the tint color.Color
	DrawSprite(def components.SpriteDef, sprite sprite.Sprite, pos geometry.Point, tint color.Solid) error
	// DrawBox draws a box outline with an color.Solid and a scale
	DrawBox(pos geometry.Point, box shapes.Box, solid color.Solid)
	// DrawSolidBox draws a solid box with an color.Solid and a scale
	DrawSolidBox(pos geometry.Point, box shapes.SolidBox, solid color.Solid)
	// DrawGradientBox draws a solid box with an color.Solid and a scale
	DrawGradientBox(pos geometry.Point, box shapes.SolidBox, gradient color.Gradient)
	// MeasureText return the geometry.Size of a string with a defined size
	MeasureText(fnt components.FontDef, str string, size float32) geometry.Size
	// DrawLine between from and to with a given thickness and color.Solid
	DrawLine(from, to geometry.Point, thickness float32, color color.Solid)
	// BeginScissor start a scissor draw (define screen area for following drawing)
	BeginScissor(from geometry.Point, size geometry.Size)
	// EndScissor end the current scissor
	EndScissor()
}

DeviceManager is the interface for our device manager

func Device

func Device() DeviceManager

Device return the DeviceManager

type Manager

type Manager interface{}

Manager can have world.System or world.Listener

type StorageManager

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

StorageManager allows to store assets for our engine

func Storage

func Storage(dm DeviceManager) *StorageManager

Storage returns a new managers.StorageManager

func (*StorageManager) Clear

func (sm *StorageManager) Clear()

Clear all loaded data

func (*StorageManager) GetFontDef

func (sm *StorageManager) GetFontDef(name string) (components.FontDef, error)

GetFontDef returns the components.FontDef for a font

func (*StorageManager) GetMusicDef

func (sm *StorageManager) GetMusicDef(name string) (components.MusicDef, error)

GetMusicDef returns the components.MusicDef for a music stream

func (*StorageManager) GetSoundDef

func (sm *StorageManager) GetSoundDef(name string) (components.SoundDef, error)

GetSoundDef returns the components.SoundDef for a wave sound

func (StorageManager) GetSpriteDef

func (sm StorageManager) GetSpriteDef(sheet string, name string) (components.SpriteDef, error)

GetSpriteDef returns the components.SpriteDef for an sprite

func (StorageManager) GetSpriteSize

func (sm StorageManager) GetSpriteSize(sheet string, name string) (geometry.Size, error)

GetSpriteSize returns the geometry.Size of a given sprite

func (*StorageManager) GetTiledMapDef

func (sm *StorageManager) GetTiledMapDef(name string) (components.TiledMapDef, error)

GetTiledMapDef returns the components.TiledMapDef for a tiled map

func (*StorageManager) LoadFont

func (sm *StorageManager) LoadFont(name string) (err error)

LoadFont preloads a font

func (*StorageManager) LoadMusic

func (sm *StorageManager) LoadMusic(name string) (err error)

LoadMusic preload a music stream

func (*StorageManager) LoadSingleSprite

func (sm *StorageManager) LoadSingleSprite(sheet string, name string, pivot geometry.Point) error

LoadSingleSprite preloads a sprite.Sprite in a sheet

func (*StorageManager) LoadSound

func (sm *StorageManager) LoadSound(name string) (err error)

LoadSound preload a sound wave

func (*StorageManager) LoadSpriteSheet

func (sm *StorageManager) LoadSpriteSheet(name string) (err error)

LoadSpriteSheet preloads a sprite.Sprite sheet

func (*StorageManager) LoadTiledMap

func (sm *StorageManager) LoadTiledMap(name string) (err error)

LoadTiledMap preload a tiled map

type WithListener

type WithListener interface {
	// Listener is a world.Listener
	Listener(world *goecs.World, signal interface{}, delta float32) error
	// Signals indicates what signals thi Listener listen to
	Signals() []reflect.Type
}

WithListener have a world.Listener

func Sounds

Sounds returns a managers.WithListener that handle audio waves

type WithSystem

type WithSystem interface {
	// System is a world.System
	System(world *goecs.World, delta float32) error
}

WithSystem have a world.System

func Animation

func Animation() WithSystem

Animation returns a managers.WithSystem for handling animations

func Effects

func Effects() WithSystem

Effects is manager.WithSystem that handle effects

func Rendering

func Rendering(dm DeviceManager, sm *StorageManager) WithSystem

Rendering returns a managers.WithSystem that will handle rendering

func TiledMaps

func TiledMaps(sm *StorageManager) WithSystem

TiledMaps returns a managers.WithSystem that handle tiled maps

type WithSystemAndListener

type WithSystemAndListener interface {
	// System is a world.System
	System(world *goecs.World, delta float32) error
	// Listener is a world.Listener
	Listener(world *goecs.World, signal interface{}, delta float32) error
	// Signals indicates what signals thi Listener listen to
	Signals() []reflect.Type
}

WithSystemAndListener have a world.System and a world.Listener

func Events

Events returns a managers.WithSystem that will handle signals

func Music

Music returns a managers.WithSystemAndListener that handle music stream

func UI

UI returns a managers.WithSystemAndListener that handle ui components

Directories

Path Synopsis
Package ray is the managers.Device implementation using raylib
Package ray is the managers.Device implementation using raylib

Jump to

Keyboard shortcuts

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