
I thought to ask about this on Shmups Forum because I've seen some folks here very educated on VSync input lag (and this sub is surprisingly active for a niche of a niche, wow). So, I'm building a danmaku engine and am looking at doing everything within my power to make "VSync On" the default (and therefore making sure input lag is negligible). I have a solution in mind, but it feels...too easy, and too obvious, like I'm missing some drawback.
The idea is this (abstracted) loop of events:
1. Process bullets
1a. Move bullets
1b. First pass of bullet collision detection (quick spatial check to eliminate ~95% of bullets)
2. Wait for screen refresh
3. Screen refresh
4. Fetch player input
4a. Move player
5. Second pass of bullet collision detection (precise check for remaining ~5% of bullets)
6. Respond to collisions
The idea being that collision is always visible on monitor before the collision is actually detected by the engine; the player has a full frame (plus some negligibly small number of microseconds between step #3 and step #4) to react to impending bullets.
The drawback I see is that there can be a visible collision after step #3 that the player moves away from in step #4a, leaving a false positive collision visible on monitor for a full frame. But for me that's okay, since the joy of danmaku is escaping from close shaves.
What other drawbacks do you see? Is there something insurmountable? Or something that can be improved on? TIA!
EDIT: Alternate idea I'm thinking of:
Spoiler
1. Process bullets
1a. Move bullets
1b. First pass of bullet collision detection (quick spatial check to eliminate ~95% of bullets)
2. Fetch player input
2a. Move player
3. Fetch player input again at regular intervals while waiting for screen refresh
3a. Update/change player movement accordingly
4. Screen refresh
5. Fetch player input one last time
5a. Update/change player movement one last time
6. Second pass of bullet collision detection (precise check for remaining ~5% of bullets)
7. Respond to collisions
1a. Move bullets
1b. First pass of bullet collision detection (quick spatial check to eliminate ~95% of bullets)
2. Fetch player input
2a. Move player
3. Fetch player input again at regular intervals while waiting for screen refresh
3a. Update/change player movement accordingly
4. Screen refresh
5. Fetch player input one last time
5a. Update/change player movement one last time
6. Second pass of bullet collision detection (precise check for remaining ~5% of bullets)
7. Respond to collisions