quasilyte / ebitengine-input

A Godot-inspired action input handling system for Ebitengine
MIT License
66 stars 8 forks source link

Add tests for the virtual input #12

Open quasilyte opened 1 year ago

quasilyte commented 1 year ago

This is the easiest part of the library to test.

But also, it's a part that may be optimized later: right now it works under an assumption that simulated events are both rare (not happen often) and not numerous. If some game will spam simulated events inside a single frame, we'll end up with big slices. Big slices are an issue for our linear search algorithm.

Maybe we need to do a sorting inside System.Update() method of all current events and do a binary search. For the small number of events, like <10 it won't make much of a difference, but for the 1000+ events it will work much better. But maybe there is even a better solution.

Having tests and benchmarks would make optimizations/refactoring easier there.