Documentation ¶
Overview ¶
Package engine provides the "engine" that builds on top of ebiten and is used to implemente the game.
Index ¶
- Variables
- func InitLogger(debug bool)
- type Control
- func (c *Control) A() bool
- func (c *Control) B() bool
- func (c *Control) CheckGamepad()
- func (c *Control) Down() bool
- func (c *Control) IsGamepadDisconnected() bool
- func (c *Control) Left() bool
- func (c *Control) Right() bool
- func (c *Control) Select() bool
- func (c *Control) Start() bool
- func (c *Control) Up() bool
- type Loader
- type Scene
- type SceneManager
- func (s *SceneManager) Draw(screen *ebiten.Image)
- func (s *SceneManager) Layout(outsideWidth int, outsideHeight int) (int, int)
- func (s *SceneManager) PopScene() Scene
- func (s *SceneManager) PushScene(scene Scene)
- func (s *SceneManager) SetLayout(screenWidth int, screenHeight int)
- func (s *SceneManager) Update() error
Constants ¶
This section is empty.
Variables ¶
var (
Debug *log.Logger
)
Functions ¶
func InitLogger ¶
func InitLogger(debug bool)
Types ¶
type Control ¶
type Control struct {
// contains filtered or unexported fields
}
Control handles the control methods (keyboard and gamepad). Up, Down, ... methods will always report the keyboard state and, when available, the gamepad state.
func (*Control) CheckGamepad ¶
func (c *Control) CheckGamepad()
CheckGamepad checks when a gamepad is connected/disconnected. This should be run ideally once per frame.
func (*Control) IsGamepadDisconnected ¶
IsGamepadDisconnected will returh true if the gampad was disconnected. In order to return true, it had to be connected at some point.
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
Loader is a simple resource loader supporting files and zip achives.
func NewLoader ¶
NewLoader creates a new loader using path as location for the assets. If the path ends in ".pak", it will be opened as a zip archive.
func (*Loader) Close ¶
Close closes the loader. Only required if an archive is used. Once the loader is closed, it shouldn't be used again.
type Scene ¶
Scene interface describes a scene managed by the scene manager. It is similar to a ebiten.Game, only that the Layout method is not required.
Update doesn't need to call CheckGamepad on control, that happens on the manager itelf.
type SceneManager ¶
type SceneManager struct {
// contains filtered or unexported fields
}
SceneManager implement a wrapper around scenes. Implements a stack of scenes.
var (
SceneMan SceneManager
)
func (*SceneManager) Draw ¶
func (s *SceneManager) Draw(screen *ebiten.Image)
Draw calls update on current scene.
func (*SceneManager) Layout ¶
func (s *SceneManager) Layout(outsideWidth int, outsideHeight int) (int, int)
Layout will set the layout on ebiten.
func (*SceneManager) PopScene ¶
func (s *SceneManager) PopScene() Scene
PopScene removes the current scene.
func (*SceneManager) PushScene ¶
func (s *SceneManager) PushScene(scene Scene)
PushScene adds a scene to the stack. That scene is the new current (active) scene.
func (*SceneManager) SetLayout ¶
func (s *SceneManager) SetLayout(screenWidth int, screenHeight int)
SetLayout sets the with and height of the internal screen. screenWidth defaults to 320 pixels. screenHeight defaults to 240 pixels.
func (*SceneManager) Update ¶
func (s *SceneManager) Update() error
Update calls update on current scene. It calls control's CheckGamepad, so the Update method on the scene shouldn't need to call it.