kapelo

package module
v0.0.0-...-f752f9b Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

README ¶

🧢 Kapelo (WIP)

A cool game development library for the Go programming language.

Kapelo is designed to be a simple base for things that are often needed when creating a video game. Things like managing objects in an inventory, tweening between two values, and other similar things are included in this library.

📦 Installation

To install the library, run the following command within your Go project:

go get -v -u github.com/AlexandrosKap/kapelo@main

📌 License

The project is released under the terms of the Apache-2.0 License. Please refer to the LICENSE file.

Documentation ¶

Index ¶

Constants ¶

View Source
const InventoryNoneId = -1

Variables ¶

This section is empty.

Functions ¶

func Ease ¶

func Ease(a, b, weight float64, f EaseFunc) float64

func EaseInCubic ¶

func EaseInCubic(x float64) float64

func EaseInOutCubic ¶

func EaseInOutCubic(x float64) float64

func EaseInOutQuad ¶

func EaseInOutQuad(x float64) float64

func EaseInOutQuart ¶

func EaseInOutQuart(x float64) float64

func EaseInOutSine ¶

func EaseInOutSine(x float64) float64

func EaseInQuad ¶

func EaseInQuad(x float64) float64

func EaseInQuart ¶

func EaseInQuart(x float64) float64

func EaseInSine ¶

func EaseInSine(x float64) float64

func EaseLinear ¶

func EaseLinear(x float64) float64

func EaseOutCubic ¶

func EaseOutCubic(x float64) float64

func EaseOutQuad ¶

func EaseOutQuad(x float64) float64

func EaseOutQuart ¶

func EaseOutQuart(x float64) float64

func EaseOutSine ¶

func EaseOutSine(x float64) float64

func Lerp ¶

func Lerp(a, b, weight float64) float64

Types ¶

type Anchor ¶

type Anchor byte
const (
	TopLeft Anchor = iota
	Top
	TopRight
	CenterLeft
	Center
	CenterRight
	BottomLeft
	Bottom
	BottomRight
)

func (Anchor) ToVec2 ¶

func (a Anchor) ToVec2() Vec2

type Circ ¶

type Circ struct {
	X float64
	Y float64
	R float64
}

func NewCirc ¶

func NewCirc(center Vec2, r float64) Circ

func (Circ) Center ¶

func (c Circ) Center() Vec2

func (Circ) Lerp ¶

func (c Circ) Lerp(to Circ, weight float64) Circ

func (*Circ) SetCenter ¶

func (c *Circ) SetCenter(center Vec2)

type EaseFunc ¶

type EaseFunc func(x float64) float64

type Inventory ¶

type Inventory struct {
	Items []InventoryItem
	Rows  int
	Cols  int
}

func NewInventory ¶

func NewInventory(rows, cols int) Inventory

func (*Inventory) Append ¶

func (inv *Inventory) Append(item InventoryItem)

func (*Inventory) AppendAndMerge ¶

func (inv *Inventory) AppendAndMerge(item InventoryItem)

func (*Inventory) Clean ¶

func (inv *Inventory) Clean()

func (Inventory) Count ¶

func (inv Inventory) Count() int

func (Inventory) CountArea ¶

func (inv Inventory) CountArea(row1, col1, row2, col2 int) int

func (Inventory) Item ¶

func (inv Inventory) Item(row, col int) *InventoryItem

func (*Inventory) Organize ¶

func (inv *Inventory) Organize()

func (*Inventory) Remove ¶

func (inv *Inventory) Remove(row, col int)

func (*Inventory) Swap ¶

func (inv *Inventory) Swap(row1, col1, row2, col2 int)

type InventoryItem ¶

type InventoryItem struct {
	Id    int
	Count int
}

func (*InventoryItem) Change ¶

func (t *InventoryItem) Change(id, count int)

func (InventoryItem) IsNone ¶

func (it InventoryItem) IsNone() bool

func (InventoryItem) IsSome ¶

func (it InventoryItem) IsSome() bool

func (*InventoryItem) MakeNone ¶

func (it *InventoryItem) MakeNone()

type Keyframe ¶

type Keyframe struct {
	Value float64
	Time  float64
}

type KeyframeSequence ¶

type KeyframeSequence struct {
	Frames []Keyframe
	Time   float64
	F      EaseFunc
}

func NewKeyframeSequence ¶

func NewKeyframeSequence(count int) KeyframeSequence

func (KeyframeSequence) Duration ¶

func (k KeyframeSequence) Duration() float64

func (KeyframeSequence) HasFinished ¶

func (k KeyframeSequence) HasFinished() bool

func (KeyframeSequence) HasStarted ¶

func (k KeyframeSequence) HasStarted() bool

func (KeyframeSequence) Now ¶

func (k KeyframeSequence) Now() float64

func (KeyframeSequence) Progress ¶

func (k KeyframeSequence) Progress() float64

func (*KeyframeSequence) Update ¶

func (k *KeyframeSequence) Update(dt float64) float64

func (*KeyframeSequence) UpdateAndLoop ¶

func (k *KeyframeSequence) UpdateAndLoop(dt float64) float64

type KeyframeSequenceGroup ¶

type KeyframeSequenceGroup struct {
	Sequences []KeyframeSequence
}

func NewKeyframeSequenceGroup ¶

func NewKeyframeSequenceGroup(scount int, kcount int) KeyframeSequenceGroup

func (KeyframeSequenceGroup) Duration ¶

func (k KeyframeSequenceGroup) Duration() float64

func (KeyframeSequenceGroup) HasFinished ¶

func (k KeyframeSequenceGroup) HasFinished() bool

func (KeyframeSequenceGroup) HasStarted ¶

func (k KeyframeSequenceGroup) HasStarted() bool

func (KeyframeSequenceGroup) Progress ¶

func (k KeyframeSequenceGroup) Progress() float64

func (*KeyframeSequenceGroup) Update ¶

func (k *KeyframeSequenceGroup) Update(dt float64)

func (*KeyframeSequenceGroup) UpdateAndLoop ¶

func (k *KeyframeSequenceGroup) UpdateAndLoop(dt float64)

type Line ¶

type Line struct {
	X1 float64
	Y1 float64
	X2 float64
	Y2 float64
}

func NewLine ¶

func NewLine(a, b Vec2) Line

func (Line) Lerp ¶

func (l Line) Lerp(to Line, weight float64) Line

type Rect ¶

type Rect struct {
	X float64
	Y float64
	W float64
	H float64
}

func NewRect ¶

func NewRect(start, size Vec2) Rect

func (Rect) AnchorPoint ¶

func (r Rect) AnchorPoint(a Anchor) Vec2

func (Rect) Area ¶

func (r Rect) Area() float64

func (Rect) Bottom ¶

func (r Rect) Bottom(amount float64) Rect

func (Rect) Center ¶

func (r Rect) Center() Vec2

func (*Rect) CutBottom ¶

func (r *Rect) CutBottom(amount float64) Rect

func (*Rect) CutLeft ¶

func (r *Rect) CutLeft(amount float64) Rect

func (*Rect) CutRight ¶

func (r *Rect) CutRight(amount float64) Rect

func (*Rect) CutSide ¶

func (r *Rect) CutSide(from Anchor, amount float64) Rect

func (*Rect) CutTop ¶

func (r *Rect) CutTop(amount float64) Rect

func (Rect) End ¶

func (r Rect) End() Vec2

func (*Rect) Extend ¶

func (r *Rect) Extend(amount float64)

func (*Rect) ExtendBottom ¶

func (r *Rect) ExtendBottom(amount float64)

func (*Rect) ExtendLeft ¶

func (r *Rect) ExtendLeft(amount float64)

func (*Rect) ExtendRight ¶

func (r *Rect) ExtendRight(amount float64)

func (*Rect) ExtendSide ¶

func (r *Rect) ExtendSide(from Anchor, amount float64)

func (*Rect) ExtendTop ¶

func (r *Rect) ExtendTop(amount float64)

func (Rect) HasArea ¶

func (r Rect) HasArea() bool

func (Rect) HasPoint ¶

func (r Rect) HasPoint(p Vec2) bool

func (Rect) Intersection ¶

func (r Rect) Intersection(o Rect) Rect

func (Rect) IsIntersecting ¶

func (r Rect) IsIntersecting(o Rect) bool

func (Rect) Left ¶

func (r Rect) Left(amount float64) Rect

func (Rect) Lerp ¶

func (r Rect) Lerp(to Rect, weight float64) Rect

func (Rect) Merger ¶

func (r Rect) Merger(o Rect) Rect

func (Rect) OutBottom ¶

func (r Rect) OutBottom(amount float64) Rect

func (Rect) OutLeft ¶

func (r Rect) OutLeft(amount float64) Rect

func (Rect) OutRight ¶

func (r Rect) OutRight(amount float64) Rect

func (Rect) OutSide ¶

func (r Rect) OutSide(from Anchor, amount float64) Rect

func (Rect) OutTop ¶

func (r Rect) OutTop(amount float64) Rect

func (Rect) Right ¶

func (r Rect) Right(amount float64) Rect

func (*Rect) SetCenter ¶

func (r *Rect) SetCenter(center Vec2)

func (*Rect) SetEnd ¶

func (r *Rect) SetEnd(end Vec2)

func (*Rect) SetSize ¶

func (r *Rect) SetSize(size Vec2)

func (*Rect) SetStart ¶

func (r *Rect) SetStart(start Vec2)

func (Rect) Side ¶

func (r Rect) Side(from Anchor, amount float64) Rect

func (Rect) Size ¶

func (r Rect) Size() Vec2

func (Rect) Start ¶

func (r Rect) Start() Vec2

func (Rect) Top ¶

func (r Rect) Top(amount float64) Rect

type Tween ¶

type Tween struct {
	A        float64
	B        float64
	Time     float64
	Duration float64
	F        EaseFunc
}

func NewTween ¶

func NewTween(a, b, duration float64, f EaseFunc) Tween

func (*Tween) Change ¶

func (t *Tween) Change(a, b float64)

func (Tween) HasFinished ¶

func (t Tween) HasFinished() bool

func (Tween) HasStarted ¶

func (t Tween) HasStarted() bool

func (Tween) Now ¶

func (t Tween) Now() float64

func (Tween) Progress ¶

func (t Tween) Progress() float64

func (*Tween) Update ¶

func (t *Tween) Update(dt float64) float64

func (*Tween) UpdateAndLoop ¶

func (t *Tween) UpdateAndLoop(dt float64) float64

type TweenGroup ¶

type TweenGroup struct {
	Tweens []Tween
}

func NewTweenGroup ¶

func NewTweenGroup(count int, duration float64, f EaseFunc) TweenGroup

func (TweenGroup) HasFinished ¶

func (t TweenGroup) HasFinished() bool

func (TweenGroup) HasStarted ¶

func (t TweenGroup) HasStarted() bool

func (TweenGroup) Progress ¶

func (t TweenGroup) Progress() float64

func (*TweenGroup) Update ¶

func (t *TweenGroup) Update(dt float64)

func (*TweenGroup) UpdateAndLoop ¶

func (t *TweenGroup) UpdateAndLoop(dt float64)

type Vec2 ¶

type Vec2 struct {
	X float64
	Y float64
}

func (Vec2) Abs ¶

func (v Vec2) Abs() Vec2

func (Vec2) Add ¶

func (v Vec2) Add(rhs Vec2) Vec2

func (Vec2) Ceil ¶

func (v Vec2) Ceil() Vec2

func (Vec2) Div ¶

func (v Vec2) Div(rhs Vec2) Vec2

func (Vec2) Floor ¶

func (v Vec2) Floor() Vec2

func (Vec2) Length ¶

func (v Vec2) Length() float64

func (Vec2) LengthSquared ¶

func (v Vec2) LengthSquared() float64

func (Vec2) Lerp ¶

func (v Vec2) Lerp(to Vec2, weight float64) Vec2

func (Vec2) Mul ¶

func (v Vec2) Mul(rhs Vec2) Vec2

func (Vec2) Normalized ¶

func (v Vec2) Normalized() Vec2

func (Vec2) Round ¶

func (v Vec2) Round() Vec2

func (Vec2) Sub ¶

func (v Vec2) Sub(rhs Vec2) Vec2

Jump to

Keyboard shortcuts

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