Closed supercobra closed 1 year ago
Ah yes, I've noted this myself - the collision detection logic could be improved, here.
Currently, sprites move with "vX" and "vY" velocities - e.g., gunfire might move 8 pixels on the X axis per frame. To optimize and reduce CPU use (and/or be lazy), I only check for collision at the new position, e.g., from 32 to 40 pixels; I don't "step" through each pixel traveled between frames. This has been OK for most cases, but gunfire -> parachute is a good example of where things can clearly miss and shouldn't.
I could probably get away with adding a "half-point" collision check, or maybe splitting it into thirds. This could apply to and improve the accuracy of all munitions - bombs, smart missiles and such.
This turned out to be easier than I thought, assuming I got it right. 😅 Bullets can collide with bullets mid-air, and that seems to be happening more now with this check. Additionally, infantry and parachutes ("paratroopers") should be hit more reliably now. Let me know if you're still seeing bullets flying through, missing or skipping over.
When trying to shoot a pilot with a parachute, it seems that many bullets go through him before taking him down. Maybe it is a visual effect only not sure.
MacOS Ventura + Safari.