Documentation
¶
Overview ¶
Package ebitenhelper is a small game engine built on Ebitengine.
It gives a game the parts which every 2D game needs: a level holding the actors, a game loop calling them, components for movement, collision, drawing, player input and enemy AI, a loader for Tiled maps, and a widget system for the HUD.
A game using it consists of three things: actors made of the components, the assets including the Tiled maps placing those actors, and one call to Run:
func main() {
err := ebitenhelper.Run(ebitenhelper.Options{
WindowTitle: "My Game",
ScreenSize: utility.NewPoint(1280, 704),
Assets: assets.FS,
Instance: &mygame.GameInstance{},
NewFirstLevel: mygame.NewStage1,
})
if err != nil {
log.Fatal(err)
}
}
The engine packages never depend on a specific game. Everything a game defines by itself lives in its own packages, and reaches the engine through the actor registry (actor.Register) and the interfaces of the utility package.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Options ¶
type Options struct {
// WindowTitle is shown on the title bar. It is optional.
WindowTitle string
// ScreenSize is the size of the game screen in pixels. It is optional, and the
// engine keeps its default size when it is not set.
ScreenSize utility.Point
// Assets is the filesystem holding the images, fonts, maps and widget files of
// the game. It is usually an embed.FS. It is required.
Assets fs.FS
// Instance receives the inputs which are not sent to a specific actor.
// It is optional.
Instance utility.GameInstancer
// NewFirstLevel creates the level the game starts with. It is called after the
// assets and the screen size are set, so it can load them safely. It is required.
NewFirstLevel func() (*utility.Level, error)
}
Options is the configuration of a game given to Run.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package actor provides the actors built into the engine and the registry which creates actors by name.
|
Package actor provides the actors built into the engine and the registry which creates actors by name. |
|
Package component provides the parts an actor is built from.
|
Package component provides the parts an actor is built from. |
|
Package tilemap builds levels from Tiled maps (https://www.mapeditor.org/).
|
Package tilemap builds levels from Tiled maps (https://www.mapeditor.org/). |
|
Package utility is the core of the engine.
|
Package utility is the core of the engine. |
|
Package widget draws the HUD of a game from an XML file.
|
Package widget draws the HUD of a game from an XML file. |