-
Notifications
You must be signed in to change notification settings - Fork 5
ent.um
type Ent* = struct {
// used as a collider, used as backup when invalid image is supplied
r: rect.Rect
// used in drawing
i: image.Image
// used to transform and translate the image and rect
t: th.Transform
// used as a color of the rect and a color filter for the image
c: uint32
}
Entity is the main game object. It features drawing and collisions. Every entity has an image used for drawing and a rectangle used for collisions. It also has a transform used for transforming it's image and rectangle.
type Coll* = struct {
index: th.uu
pos: th.Vf2
}
Value returned by get coll. It contains a position where the collision happened and the index of the entity involved in said collision.
fn (e: ^Ent) draw*(c: rect.Rect) {
Draws the entity onto the screen in relaction to camera c.
fn mk*(img: image.Image = image.Image{}, t: th.Transform = th.Transform{ s: th.Vf2{1, 1} }): Ent {
ent's constructor
fn (e: ^Ent) getColl*(s: []^Ent, maxColls: th.uu): []Coll {
Checks collisions of e with entities in s. Checks at max maxColl collisions. If s contains e, the collision won't be returned.
fn (e: ^Ent) animate*(fps: int, frames: ^[]image.Image, t: int) {
Animates the entity's image with one of the anim
array. Won't begin on
the first frame. If you want that, use anim.Anim.
fn ysort*(ents: ^[]ent.Ent) {
Performs an y sort on entities.