core

package
v0.0.0-...-21c9ebe Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

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

func LoadEmbeddedImage(assets embed.FS, path string) *ebiten.Image

LoadEmbeddedImage loads a png from the embedded filesystem

Types

type BoxCollider

type BoxCollider struct {
	Enabled  bool
	Offset   Vector2i
	Position Vector2
	Size     Vector2i
}

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

type Vector2 struct {
	X float64
	Y float64
}

Vector2 Utility struct to hold 2 floats.

func (Vector2) Add

func (vec Vector2) Add(vec2 Vector2) Vector2

func (Vector2) Equals

func (vec Vector2) Equals(vec2 Vector2) bool

func (Vector2) Magnitude

func (vec Vector2) Magnitude() float64

func (Vector2) Mul

func (vec Vector2) Mul(vec2 Vector2) Vector2

func (Vector2) Mulf

func (vec Vector2) Mulf(f float64) Vector2

func (Vector2) Normalized

func (vec Vector2) Normalized() Vector2

func (Vector2) Sub

func (vec Vector2) Sub(vec2 Vector2) Vector2

func (Vector2) ToVector2i

func (vec Vector2) ToVector2i() Vector2i

type Vector2i

type Vector2i struct {
	X int
	Y int
}

Vector2i Utility struct to hold 2 ints.

func (Vector2i) Add

func (vec Vector2i) Add(vec2 Vector2i) Vector2i

func (Vector2i) Equals

func (vec Vector2i) Equals(vec2 Vector2i) bool

func (Vector2i) Magnitude

func (vec Vector2i) Magnitude() float64

func (Vector2i) Mul

func (vec Vector2i) Mul(vec2 Vector2i) Vector2i

func (Vector2i) Mulf

func (vec Vector2i) Mulf(i int) Vector2i

func (Vector2i) Normalized

func (vec Vector2i) Normalized() Vector2i

func (Vector2i) Sub

func (vec Vector2i) Sub(vec2 Vector2i) Vector2i

func (Vector2i) ToVector2

func (vec Vector2i) ToVector2() Vector2

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL