This commit is contained in:
Andrey Parhomenko 2023-05-02 17:38:34 +03:00
parent 1e2e43ad2b
commit a6db4d1417

View file

@ -12,12 +12,14 @@ import (
// The type represents order of drawing. // The type represents order of drawing.
type Layer int type Layer int
// Window configuration type.
type WindowConfig struct { type WindowConfig struct {
Title string Title string
Width, Height int Width, Height int
FixedSize bool FixedSize bool
} }
// The main structure that represents current state of [game] engine.
type Engine struct { type Engine struct {
wcfg *WindowConfig wcfg *WindowConfig
layers *sparsex.Sparse[Layer, *poolx.Pool[Drawer]] layers *sparsex.Sparse[Layer, *poolx.Pool[Drawer]]
@ -30,18 +32,22 @@ type Engine struct {
type engine Engine type engine Engine
// Return current camera.
func (e *Engine) Camera() *Camera { func (e *Engine) Camera() *Camera {
return e.camera return e.camera
} }
// Set new current camera.
func (e *Engine) SetCamera(c *Camera) { func (e *Engine) SetCamera(c *Camera) {
e.camera = c e.camera = c
} }
// Get currently pressed keys.
func (e *Engine) Keys() []Key { func (e *Engine) Keys() []Key {
return e.keys return e.keys
} }
// Returns new empty Engine.
func New( func New(
cfg *WindowConfig, cfg *WindowConfig,
) *Engine { ) *Engine {
@ -77,6 +83,7 @@ func (e *Engine) Add(l Layer, b any) {
} }
} }
// Del object from Engine.
func (e *Engine) Del(b any) { func (e *Engine) Del(b any) {
drawer, ok := b.(Drawer) drawer, ok := b.(Drawer)
if ok { if ok {