Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebasing code to support data stacking and sprites #10

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

GridRL
Copy link

@GridRL GridRL commented Apr 25, 2024

Hi Peter!

This is a partially improved version of the stacking prototype I made few months ago.

Just like now, only username metadata is mandatory. Stacking happens on a parameter equal to envID if set, otherwise it's randomized, so it can still display agents without a declared envID.

Custom sprites are supported setting optional metadata sprite_id=0.

Automatic variable speed is supported and scales with packets sizes on a log2 scale. Default speed matches the current, which is kinda x8 from game. I added high hard-limits for a single batch of coordinates at 2048 and 10 packets. Everything above that limit will be discarded. Mostly for safety, without abuse or ultra fast environment, I don't think this is needed. I also maintained legacy low speeds for very small packets, mostly for debug.

Visual artifacts of warps are mitigated with two editing, disabling the sprite if coordinates delta is above 1 and Function clipping inside coordConversionFunc using map bounds.

Direction infering is still using global coordinates over local, but that's fixable later if necessary, also considering the feature is off by default.

Extra Hotkeys are added for:

  • [W] Wipe all agents
  • [S] Toggle the stacking mechanism (default on - stacking active, otherwise always randomize stackID to get a result comparable to the current version)
  • [D] Toggle directional sprites (default off - PIXI.TilingSprite is more GPU heavy and kinda niche)

I hope it's all good!

@PWhiddy
Copy link
Owner

PWhiddy commented Apr 25, 2024

Hey! I pulled down the code to run locally. when I press d to enable directional sprites I'm not seeing the directions change, am I doing something wrong maybe?

let texturesChars = [];
let texturesCharsDirectional = [];

for(let i = 0; i < 73; ++i){
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

73 is the number of sprites in the spritesheet?

@@ -47,15 +49,64 @@ function smoothstep(min, max, value) {
return x*x*(3 - 2*x);
}

const createLock = () => {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a little confused why a lock is implemented/used? JS is single threaded so all operations are going to be atomic by default.

@GridRL
Copy link
Author

GridRL commented Apr 26, 2024

All good on your end, when at the end I added buttons for directional sprites, I introduced a pythonic typo and used self over this, so the comparison of an undefined field will always be false! :p
Last commit should solve this, I also added a check to see if tilePosition is undefined to avoid runtime errors.
Yes, 73 is tied to the amount of sprites in the image. For the lock you are right, it's pretty useless on JS. It was mostly a comment, so it's safe to remove.

@PWhiddy
Copy link
Owner

PWhiddy commented May 2, 2024

Would be very cool to have this! with the current performance and the extra code though it's not ready for merge yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants