Documentation ¶
Index ¶
- func CheckCollision(col1 BoxCollider, col2 BoxCollider) bool
- func CheckOffsetCollision(col1 BoxCollider, col2 BoxCollider, offset Vector2) bool
- func LoadEmbeddedImage(assets embed.FS, path string) *ebiten.Image
- type BoxCollider
- type CollisionData
- type GameObject
- type SpriteLayout
- type SpriteSheet
- type Vector2
- func (vec Vector2) Add(vec2 Vector2) Vector2
- func (vec Vector2) Equals(vec2 Vector2) bool
- func (vec Vector2) Magnitude() float64
- func (vec Vector2) Mul(vec2 Vector2) Vector2
- func (vec Vector2) Mulf(f float64) Vector2
- func (vec Vector2) Normalized() Vector2
- func (vec Vector2) Sub(vec2 Vector2) Vector2
- func (vec Vector2) ToVector2i() Vector2i
- type Vector2i
- func (vec Vector2i) Add(vec2 Vector2i) Vector2i
- func (vec Vector2i) Equals(vec2 Vector2i) bool
- func (vec Vector2i) Magnitude() float64
- func (vec Vector2i) Mul(vec2 Vector2i) Vector2i
- func (vec Vector2i) Mulf(i int) Vector2i
- func (vec Vector2i) Normalized() Vector2i
- func (vec Vector2i) Sub(vec2 Vector2i) Vector2i
- func (vec Vector2i) ToVector2() Vector2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CheckCollision ¶
func CheckCollision(col1 BoxCollider, col2 BoxCollider) bool
func CheckOffsetCollision ¶
func CheckOffsetCollision(col1 BoxCollider, col2 BoxCollider, offset Vector2) bool
func LoadEmbeddedImage ¶
LoadEmbeddedImage loads a png from the embedded filesystem
Types ¶
type BoxCollider ¶
type CollisionData ¶
type CollisionData struct { GameObject1 *GameObject GameObject2 *GameObject }
type GameObject ¶
type GameObject struct { Position Vector2 CurrentSheet *SpriteSheet Speed float64 Collider *BoxCollider }
GameObject is the core component of ebitextras. It contains common information most objects in a game would need to have.
func (*GameObject) ChangeSheet ¶
func (gameObject *GameObject) ChangeSheet(newSheet *SpriteSheet)
func (*GameObject) DrawGameObject ¶
func (gameObject *GameObject) DrawGameObject(screen *ebiten.Image, ops ebiten.DrawImageOptions)
DrawGameObject draws the sub-image of the SpriteSheet for the current frame at the GameObject's position.
type SpriteLayout ¶
type SpriteLayout int
SpriteLayout defines whether a sprite sheet is formatted horizontally (rows are animations), or vertically (columns are animations).
const ( // Horizontal declares that a sprite sheet is formatted horizontally (rows are animations). Horizontal SpriteLayout = iota // Vertical declares that a sprite sheet is formatted vertically (columns are animations). Vertical )
type SpriteSheet ¶
type SpriteSheet struct { // Image the ebiten.Image of the sprite sheet, or just the sprite if it is not animated. Image *ebiten.Image // Animated is whether the SpriteSheet is animated or just a single static image. Animated bool // Cells defines how many rows and columns the sprite sheet contains. Cells Vector2i // Frame is the current sub-image of the animation. Frame int // DelayFrames is the number of frames each sub-image of the animation is shown before changing to // the next one. DelayFrames int // Layout specifies whether a sprite sheet is formatted in Horizontal (rows are animations) or // Vertical (columns are animations) form. Layout SpriteLayout // SelectedAnim specifies the row or column (based on the Layout) that is currently selected. SelectedAnim int // Flipped flips the image when drawn to the screen Flipped bool // contains filtered or unexported fields }
SpriteSheet stores the image of a sprite sheet and all necessary information to render and animate it. To use a non-animated static image, set Animated to false and do not call UpdateAnim on it. There is currently no support for animations composed of separate image files
func (*SpriteSheet) UpdateAnim ¶
func (spriteSheet *SpriteSheet) UpdateAnim()
UpdateAnim manages the timing and updating of a SpriteSheet. Call this during ebiten's Update function on each SpriteSheet that needs its animation to play.
type Vector2 ¶
Vector2 Utility struct to hold 2 floats.