Best Practices
This page lists some of the best practices for working with physics in Easel.
Use body
The body parameter is a very common parameter taken by many functions that work with bodies,
and so it is common to write use body=... at the top of any block that is going to be working with a body.
Now all functions can find the body from context, and you don't have to pass it in as a parameter every time.
Subspawn ship {
use body=ship
Body(pos=20*RandomVector)
PolygonCollider(category=Category:Ship, shape=Equilateral(radius=1, numPoints=3))
once Tick(5s) {
Velocity = @(20,20)
}
}
Sizes
You should design your game so your main character has approximately the radius of 1,
and then design the rest of your game around that.
There are two reasons for this.
First, various defaults in Easel are built around this scale,
including the tolerance parameters of PolygonCollider
and PolygonSprite,
Second, area is the square of distance.
If your main character has a size of 1, their area is 1, and you can move them with a force of 100,
which is a number that is easy to comprehend.
If your main character has a size of 100, then their area is 10000,
which means the forces you need to move them are in the scale of 1000000,
which is a number that is hard to comprehend.
Categories
You only have 32 categories to work with, so you should use them wisely.
For example, instead of having a different category for every type of projectile
(e.g. Category:Fireball and Category:Lightning),
just have a single Category:Projectile. You can have an unlimited number of fields
or properties on your entities, so if needed,
add a field like pub field projectile.IsFireball to distinguish between different types of projectiles.