austineast / echo Goto Github PK
View Code? Open in Web Editor NEWSimple Physics Library written in Haxe
Home Page: https://austineast.dev/echo
License: MIT License
Simple Physics Library written in Haxe
Home Page: https://austineast.dev/echo
License: MIT License
So I want to add a isOnFloor
data to the body using your example
--macro echo.Macros.add_data("isOnFloor", "Bool")
But when I try to access it just spits an error
This is the hxml if it will help
-cp src
-lib heaps
-lib hlsdl
-lib deepnightLibs
-lib ldtk-haxe-api
-lib echo
-hl bin/Test.hl
-main Main
-D windowSize=1024x576
--macro echo.Macros.add_data("entity", "objects.Entity")
--macro echo.Macros.add_data("isOnFloor", "Bool")
Tests on the JS build are very performant, getting a stable 60 fps with a large amount of colliding bodies. But doing the same tests on a Hashlink Build cause a LOT of slowdown, with fps easily getting in the teens.
I believe that this is due to too much garbage collection, but a full investigation is needed.
I will be trying to profile the samples (maybe making some OpenFL samples that compile with hxcpp and profiling with hxscout), but any help optimizing is appreciated :)
I've tried linux and html5 builds, enter and exit callbacks are not called at all.
A brief investigation shown that echo.Listener.last_collisions is always the same object as echo.Listener.collisions, so condition
listener.last_collisions.find((f) -> return f.a == c.a && f.b == c.b || f.a == c.b && f.b == c.a) == null
in Collision.hx:118 and Collision.hx:128 is always false.
A possible fix is to revert commit 8c3b101
Is there a sync function to check the colission between 2 bodies?
Hi there! Your website is down very often.
Suggestion: Maybe you could host your content (demo/api) on GitHub pages?
https://austineast.dev/echo is down
need to set up some logic/test to ensure memory is managed for the world state history. adding IPool
integration into History
a possible solution
There should be Unit tests to help prevent regressions as progress on the library continue.
Hi, I've noticed that the contacts
variable from CollisionData
is not really being used. So, is there any other way currently to obtain the contact point(s) from the collision of shapes?
Line 22 in eda082b
Remove unneeded square root calcs.
Could there possibly be an implementation of an anchor property for bodies?
Integrating the library in Top/Left anchored engines is a bit of a hassle and needs a lot of unnecessary code ala:
pos.x = x - bounds.width/2;
I know it would 'break' centered polygons, but if the anchors are 0.5 by default, it would be up to the implementer to make it work correctly.
Line 88 in 794b0ee
Need to test and document this!
None of the samples (nice job having samples!) showcase any rotation - they all show simple translation movement. It makes me wonder whether the engine supports rotational forces.
Gave the API a quick browse... there seem to be fields named "rotation" -- so I yes? If so, it'd be great if an example showed it.
There is a bug linecasting. I added a new body at runtime, and if the world instance was passed into linecast, it would always set new bodies to 0, 0
public function tick(Delta: Float) {
if (!enabled) return;
if (linecastBodies.length == 0) return;
try {
var rayResult = ray.linecast(linecastBodies, /** world **/); // passing the world instance in here produces the bug
if (rayResult != null && !rayResult.data[0].inverse_normal) {
result = rayResult;
} else {
result = null;
}
}
catch (e) {
//
}
}
Hey, I'm wondering why body.layers
and layer_mask
are hidden by default and then not directly used in world.listen()
. It doesn't have to copy Nape or anything, but I'm trying to see if maintaining arrays of bodies is the intended approach. For instance:
/// constructor
players = [];
enemies = [];
pAttacks = [];
eAttacks = [];
platforms = [];
/// listener setup
world.listen(players, platforms, playerPlatformParams);
// etc for every pair of interacting arrays with unique callbacks
/// on new body, with custom type field
if (body.type == E_ATTACK) eAttacks.push(body);
// etc for every type
Even still, I currently plan to use layers to not interact in some cases where the listener condition
would get a bit ugly.
I am trying to collide a rectangle body that grows in size.
To grow the rectangle I use body.shape.scale_y
and offset the y
position so that the body appears to grow in height only (rather than what it is actually doing, growing in both directions from the center).
It looks like collision is based on the original size of the rectangle rather than the scaled, see the video. I would expect collision when the top of the vertical rectangle meets the horizontal rectangle (as shown in the second video).
The following video shows the body colliding normally (with no scale applied).
I've attached the code I was using to debug this, which extends BaseState from the samples project so can easily be dropped into there to test after renaming to GrowRectangle.hx
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.