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

Split GameObjectCollision into two classes #474

Closed
GregHib opened this issue Mar 10, 2024 · 0 comments · Fixed by #523
Closed

Split GameObjectCollision into two classes #474

GregHib opened this issue Mar 10, 2024 · 0 comments · Fixed by #523
Labels
enhancement New feature or request performance

Comments

@GregHib
Copy link
Owner

GregHib commented Mar 10, 2024

Having an instance dedicated to add and remove would remove the branching used and could come with some performance gains.

Also probably some other things to improve like

private fun modifyCardinal(x: Int, y: Int, level: Int, block: Int, add: Boolean) {
        val flags = collisions.flags[Zone.tileIndex(x, y, level)] ?: return
        val index = Tile.index(x, y)
        flags[index] = flags[index] or CollisionFlags.blocked[1 or block] or CollisionFlags.blocked[3 or block] or CollisionFlags.blocked[5 or block] or CollisionFlags.blocked[7 or block]
}

The 1,3, 5, 7 could be combined into a single array if block is replaced with some kind of ordinal value

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant