52 lines
746 B
Go
52 lines
746 B
Go
package ax
|
|
|
|
import "surdeus.su/core/gg"
|
|
|
|
type Animation []*gg.Image
|
|
|
|
type RectIndex struct {
|
|
X, Y int
|
|
}
|
|
|
|
// The type is used
|
|
// to structurely define
|
|
// animations.
|
|
type AnimationDefine struct{
|
|
Id AnimationID
|
|
Indexes []RectIndex
|
|
}
|
|
|
|
// Animation define shortcut.
|
|
func AD(
|
|
id AnimationID,
|
|
indexes ...RectIndex,
|
|
) AnimationDefine {
|
|
return AnimationDefine{
|
|
Id: id,
|
|
Indexes: indexes,
|
|
}
|
|
}
|
|
|
|
func (ad AnimationDefine) DefRow(
|
|
y int, xs ...int,
|
|
) AnimationDefine {
|
|
for _, x := range xs {
|
|
ad.Indexes = append(
|
|
ad.Indexes,
|
|
RectIndex{x, y},
|
|
)
|
|
}
|
|
return ad
|
|
}
|
|
|
|
func (ad AnimationDefine) DefCol(
|
|
x int, ys ...int,
|
|
) AnimationDefine {
|
|
for _, y := range ys {
|
|
ad.Indexes = append(
|
|
ad.Indexes,
|
|
RectIndex{x, y},
|
|
)
|
|
}
|
|
return ad
|
|
}
|