Comments (6)
actually, I guess did this for my old project. I was searching for nearest enemy(or hero) in attack range on turn based game. It was a draft quality project but I'm going to try to find the code that I did. It might be useful.
from daabbcc.
Hi @8bitskull
Distance based shorting is on dev branch now. Please use this url as dependency:
https://github.com/selimanac/DAABBCC/archive/refs/heads/dev.zip
I'm going to clean up the code if works for you. I just did a few small sized tests but it is hard for me to test it on large scales as your game require.
I prefer to use separate functions since I don't want to implement an extra if-else check on the exist functions. Params are same. It is enough to add "_short"
at the end:
aabb.query_id_short(group_id, aabb_id)
aabb.query_short(group_id, x, y, w, h)
aabb.raycast_short(group_id, start_x, start_y, end_x, end_y)
I made a change on returning results. Now, they are returning IDs and Distances. This might cause you a lot of extra work.
If so, please let me know, I can remove the distance from results and just kept the ID as before. But it might be useful(double checking) to compering the distances between those results and your Lua results:
{ --[[0x10e32b530]]
1 = { --[[0x10e32b590]]
id = 3,
distance = 0
},
2 = { --[[0x10e32b630]]
id = 0,
distance = 39
}
}
Also I updated the example(it is the same but just in case)
I hope this cause a performance gain...
I don't have high hopes but I'm going to take a look at the other issue today.
from daabbcc.
I believe the only struggle here would be to extract the positions for given ids from the dynamic tree to calculate those distances, right? ;)
from daabbcc.
I believe the only struggle here would be to extract the positions for given ids from the dynamic tree to calculate those distances, right? ;)
Nope, this is the easiest part. It is possible to extract their center position and distance from given id. I already have those math functions. Most challenging part is the ordering the array by distance with ids. :) Unfortunately it is not simple as lua with C.
from daabbcc.
Thanks very much @selimanac.
I can confirm that it works as expected. It reduces my targeting function from 24 lines to 9 lines and produces much more robust results - before, my function was guessing the closest enemy within an error margin to save on performance. Now I get the actual closest enemy.
from daabbcc.
@8bitskull I made a typo on function names. All "_short"
-> "_sort
now. Sorry about that.
You can check out the 2.1 branch(default branch now). Also updated the readme.
I'm going to close this issue now, feel free to open a new issue if there is a problem.
from daabbcc.
Related Issues (9)
- Windows lib build
- DAABBCC Tilemap Collisions?
- Need more performance testing
- "Delete all from tree" must be added HOT 1
- Add a function to the documentation HOT 1
- Automate position updates (track game object position automatically) HOT 16
- Add fps limit HOT 1
- raycast / raycast_query crash when length of raycast is 0 HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from daabbcc.