Documentation
¶
Index ¶
- Variables
- type FontOptions
- type IBgColor
- type ICamera
- type IGOMap
- type IGameBase
- type IPhysSystem
- type IRichText
- type IRigidbody
- type IScene
- type ISprite
- type ITileMap
- type ITransform
- type IUIButton
- type IUICollider
- type IUIText
- type PhysSettings
- type RBType
- type RichTextOptions
- type RunSide
- type SceneF
- type SpriteOptions
- type UIButtonClickEvent
- type UIButtonClickF
- type UIButtonHoverEvent
- type UIButtonHoverF
Constants ¶
This section is empty.
Variables ¶
View Source
var ( RBTypeStatic = RBType(box2d.B2BodyType.B2_staticBody) RBTypeKinematic = RBType(box2d.B2BodyType.B2_kinematicBody) RBTypeDynamic = RBType(box2d.B2BodyType.B2_dynamicBody) )
Functions ¶
This section is empty.
Types ¶
type FontOptions ¶
type ICamera ¶
type ICamera interface {
// Returns transform of the camera. Rotation doesn't
// implemented and will be ignored.
GetTransform() ITransform
// Returns layer limit (Z coordinate) at which the
// camera stops displaying the object.
GetViewRange() float64
// Set the layer limit (Z coordinate) at which the
// camera stops displaying the object.
SetViewRange(viewRange float64)
// Returns a width of the screen resolution.
// Measured in pixels.
GetResolutionWidth() int
// Returns a height of the screen resolution.
// Measured in pixels.
GetResolutionHeight() int
// Returns a vector with the screen resolution.
// Measured in pixels.
GetResolutionVector() *vector2.Vector2
// Set a resolution of the screen. Measured in
// pixels.
SetResolution(width int, height int)
// Set a width of the screen resolution. Measured in
// pixels.
SetResolutionWidth(width int)
// Set a height of the screen resolution. Measured in
//pixels.
SetResolutionHeight(height int)
// Get a screen offset of the camera. Offset -
// Is a vector thattakes into account the current
// camera coordinates and resolution size. Also takes into
// account the camera scale.
GetOffset() *vector2.Vector2
// * BE CAREFUL
//
// Set a offset of the camera. Offset - Is a vector
// thattakes into account the current camera coordinates
// and resolution size. Also takes into account the
// camera scale.
SetOffset(offset *vector2.Vector2)
// Implementation of the goi.Component
GetID() string
}
type IGOMap ¶
type IGOMap interface {
// Must be called before all the operations.
SetupGame(gameBase IGameBase)
// Tries to get the game object by given name.
Get(name string) (i interface{}, ok bool)
// Registers a new game object. If Awake() function implemented,
// it will be called. This will be applied to all the components
// of the game object.
Register(name string, gameObject interface{}) error
// Unregisters the game object. If Destroy() function implemented,
// it will be called. This will be applied to all the components
// of the game object.
Unregister(name string) error
// Calls Update(), PhysUpdate() functions.
Update() error
// Calls Draw(), DrawUI() functions, previously sorts it by
// priority.
Draw(screen *ebiten.Image) error
// One-time function, that must be called from Scene.Enter()
// only once. Starts all the queued startables, that implements
// StartableQueued interface.
StartQueuedStartables() error
// Unregisters all the game objects.
UnregisterAll() error
}
Not full implementation of the GOMap interface.
type IGameBase ¶
type IGameBase interface {
// Changes a current scene of the game.
SetScene(s IScene) error
// Returns current showing scene.
GetCurrentScene() IScene
// Returns true if debugging is enabled.
GetDebugMode() bool
// Changes the debug mode.
SetDebugMode(debug bool)
// Returns defined running side. Client \ Server \ Singleplayer.
GetRunSide() RunSide
Update() error
Draw(screen *ebiten.Image)
Layout(outsideWidth, outsideHeight int) (screenWidth, screenHeight int)
Run(windowSizeX int, windowSizeY int, title string) error
RunAsMobile()
}
type IPhysSystem ¶
type IPhysSystem interface {
// Returns new Box2D body that created in the Box2D
// world.
NewB2Body(def *box2d.B2BodyDef) *box2d.B2Body
// Registers the rigidbody in the rigidbodies registry.
// All the non-registered rigidbodies wouldn't be calculated.
RegisterRigidbody(rb IRigidbody)
// Unregisters the rigidbody.
UnregisterRigidbody(rb IRigidbody)
// Returns Box2D world.
GetB2World() *box2d.B2World
}
An interface over Box2D that defines all the physics in the scene.
type IRigidbody ¶
type IRigidbody interface {
// Returns a type of this rigidbody.
GetType() RBType
// Returns a transform that controlled by physics.
GetB2Body() *box2d.B2Body
// Returns a Box2D body.
GetFixture() *box2d.B2Fixture
// Retruns the physical system to which this rigidbody
// is attached.
GetPhysSystem() IPhysSystem
// Updates the transform according to physics.
// Called by PhysSystem with PhysUpdate().
UpdateTransform()
// Implementation of the goi.Component
GetID() string
}
type ISprite ¶
type ISprite interface {
// Returns the transform that this component is using.
GetTransform() ITransform
// Returns current image of the sprite.
GetImage() *ebiten.Image
// Set a image of the sprite.
SetImage(image *ebiten.Image)
// Returns options of the sprite.
GetOptions() *SpriteOptions
// Set options of the sprite.
SetOptions(opts *SpriteOptions)
// Returns a pivot of the sprite.
GetPivot() *vector2.Vector2
// Returns an opposite value of the sprite pivot.
GetPivotOpposite() *vector2.Vector2
// Returns a scaled pivot of the sprite. Mulitplies
// pivot by the scale of the transform.
GetPivotScaled() *vector2.Vector2
// Returns an scaled opposite value of the sprite pivot.
// Multiplies opposite value of the pivot by the scale
// of the transform.
GetPivotOppositeScaled() *vector2.Vector2
// Changes pivot of the sprite.
SetPivot(pivot *vector2.Vector2)
// Get size of the image.
GetImageSize() *vector2.Vector2
// Get the bounding box of the sprite.
GetBoudingBox() (bbA, bbB *vector2.Vector2)
// Changes visiblity of the sprite.
SetVisible(v bool)
// Changes color of the sprite. By default is white. This
// color doesn't changes the color of the image.
SetColor(c color.Color)
// Implementation of the goi.Component
GetID() string
}
type ITileMap ¶
type ITileMap[T any] interface { // Returns the transform used by this tilemap. GetTransform() ITransform // Places a tile at the given position. Returns the transform, // that must be set to this tile. PlaceTile(localX, localY int, localRot, localLayer float64, tile T) ITransform // Removes tile at the given position. RemoveTile(localX, localY int, localLayer float64) bool // Tries to get a tile with given position. If there is no // tile, ok is equals to "false". TileAt(localX, localY int, localLayer float64) (tile T, ok bool) // Converts given point to the tilemap coordinates system. OffsetVector2(point *vector2.Vector2) *vector2.Vector2 // Converts coordinates of the tilemap coordinates system to // the default coordinates. OffsetCoordinates(point *vector2.Vector2) (int, int) }
type ITransform ¶
type ITransform interface {
// Changes current position of the object.
SetPosition(pos *vector2.Vector2)
// Changes scale of the object.
SetScale(scale *vector2.Vector2)
// Changes rotation of the object.
SetRotation(rot float64)
// Changes displaying layer of the object. This
// also known as Z coordinate.
SetLayer(layer float64)
// Changes parent of the transform.
SetParent(parent ITransform)
// Returns current position of the object.
GetPosition() *vector2.Vector2
// Returns current scale of the object.
GetScale() *vector2.Vector2
// Returns rotation of the object.
GetRotation() float64
// Returns displaying layer of the object.
// Also known as Z coordinate.
GetLayer() float64
// Returns parent of the object. If there is no
// parent, nil will be returned.
GetParent() ITransform
// Returns the local position of the object.
GetLocalPosition() *vector2.Vector2
// Returns the local scale of the object.
GetLocalScale() *vector2.Vector2
// Returns the local rotation of the object.
GetLocalRotation() float64
// Returns the local position of the object.
GetLocalLayer() float64
// Changes a local position of the object.
SetLocalPosition(pos *vector2.Vector2)
// Changes a local scale of the object.
SetLocalScale(scale *vector2.Vector2)
// Changes a local rotation of the object.
SetLocalRotation(rot float64)
// Changes a local displaying layer of the object.
// This also known as Z coordinate.
SetLocalLayer(layer float64)
}
type IUIButton ¶
type IUIButton interface {
// is clicked. Know that here can be only
// one handler.
//
// * NOTE: function-handler can be called
// multiply times because of clicking
// different mouse buttons (left, right,
// center, etc.)
//
// Function must have this type:
//
// func(e interfaces.UIButtonClickEvent) error
OnClick(onClickF UIButtonClickF)
// When mouse button is released, this
// function-handler will be called. Know
// that here can be only one handler.
//
// * NOTE: function-handler can be called
// multiply times because of clicking
// different mouse buttons (left, right,
// center, etc.)
//
// Function must have this type:
//
// func(e interfaces.UIButtonClickEvent) error
ExitClick(exitClickF UIButtonClickF)
// When the cursor will be hovered on the
// button, i.e. will enter into the borders
// of the button then the function-handler
// will be called. Know that here can be
// only one handler.
//
// Function must have this type:
//
// func(e UIButtonHoverEvent) error
OnHover(onHover UIButtonHoverF)
// When the cursor exits from the borders
// of the button then function-handler
// will be called. Know that here can be
// only one handler.
//
// Function must have this type:
//
// func(e UIButtonHoverEvent) error
ExitHover(exitHover UIButtonHoverF)
// Implementation of the goi.Component
GetID() string
}
type IUICollider ¶
type IUICollider interface {
// Changes the size scalar of the collider. Because
// the collider is attached to a sprite, this value
// resizes relative to the size of the sprite. The default
// value is Vector2(1,1) which does not resize the collider
// relative to the sprite.
//
// Calculated by this algorithm:
// colliderSize := sprite.size * sizeScalar
SetSizeScalar(ss *vector2.Vector2)
// Returns the value of the size scalar. As the documentation
// for function SetSizeScalar() says, this value is relative
// to the size of the sprite.
//
// Calculated by this algorithm:
// colliderSize := sprite.size * sizeScalar
GetSizeScalar() *vector2.Vector2
// Changes the offset of the collider position relative to
// the sprite position. The default value is Vector(0,0) which
// does not changes the position of the collider.
//
// Calculates using this algorithm:
// colliderPosition := sprite.position + positionOffset
SetPositionOffset(posOffset *vector2.Vector2)
// Returns the position of the collider. As the documentation
// for function SetPositionOffset() says, this value is relative
// to the position of the sprite.
//
// Calculates using this algorithm:
// colliderPosition := sprite.position + positionOffset
GetPositionOffset() *vector2.Vector2
// Returns the sprite this collider is attached to.
GetSprite() ISprite
// Returns internal value of the polygon. This value is
// calculated each frame in the PhysUpdate() function.
// Used for use with collision2d API.
GetPolygon() *collision2d.Polygon
// Returns collider tags. Most common use is triggers
// when using a collider on Sprite.
GetCTags() *ctags.CTags
// Returns boxPolygon (internal value) at the given position.
// Main use is in PhysUpdate() function.
GetPolygonAtPosition(pos *vector2.Vector2) *collision2d.Polygon
GetID() string // Implementation of the goi.Component
}
type IUIText ¶
type IUIText interface {
// Returns GoTextFaceSource object (see ebiten/v2/text/v2).
GetFontFaceSource() *text.GoTextFaceSource
// Returns GoTextFace object (see ebiten/v2/text/v2).
GetFontFace() *text.GoTextFace
// Changes the displaying text.
SetText(text string)
// Changes the color of the text.
SetFontColor(fontColor color.Color)
// Sets a size of the font.
//
// * IMPORTANT: This function changes the value
// of the line spacing.
SetFontSize(fontSize float64)
// Sets the line spacing option directly.
//
// * BE CAREFUL!
SetLineSpacing(lineSpacing float64)
// Changes the multiplier of linespacing.
SetLineSpacingMultiplier(multiplier float64)
// Returns the transform used by this text object.
GetTransform() ITransform
// Returns current text.
GetText() string
// Returns the font options.
GetFontOptions() *FontOptions
// Changes the font options.
SetFontOptions(fontOptions *FontOptions)
// Directly install "font" value to the given font. It
// is bypasses "FontSize" parameter of the font options.
//
// This function useful for UIText interfaces, such as
// RichText.
//
// * BE CAREFUL!
SetFontDirectly(font *text.GoTextFace)
}
type PhysSettings ¶
type RichTextOptions ¶
Regulates some options of the rich text
type SpriteOptions ¶
type UIButtonClickEvent ¶
type UIButtonClickEvent struct {
GameBase IGameBase
Button IUIButton
MouseButton ebiten.MouseButton
}
type UIButtonClickF ¶
type UIButtonClickF func(e UIButtonClickEvent) error
type UIButtonHoverEvent ¶
type UIButtonHoverF ¶
type UIButtonHoverF func(e UIButtonHoverEvent) error
Click to show internal directories.
Click to hide internal directories.